From ae986b215ec68e5898fe5cad9fc581aca7d5ffbd Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Tue, 17 Oct 2023 13:16:04 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B[bugfix]=20Model=20:=20speaker=5Fde?= =?UTF-8?q?vice=E3=81=AE=E8=A8=AD=E5=AE=9A=E3=82=92=E9=96=93=E9=81=95?= =?UTF-8?q?=E3=81=88=E3=81=9F=E3=81=AE=E3=81=A7=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 14 +------------- controller.py | 11 ----------- model.py | 10 ++++++---- 3 files changed, 7 insertions(+), 28 deletions(-) diff --git a/config.py b/config.py index e00f73f0..b3761a9d 100644 --- a/config.py +++ b/config.py @@ -7,7 +7,7 @@ import tkinter as tk from tkinter import font from languages import selectable_languages from models.translation.translation_languages import translatorEngine -from models.transcription.transcription_utils import getInputDevices, getDefaultInputDevice, getDefaultOutputDevice +from models.transcription.transcription_utils import getInputDevices, getDefaultInputDevice json_serializable_vars = {} def json_serializable(var_name): @@ -337,17 +337,6 @@ class Config: self._INPUT_MIC_WORD_FILTER = value saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value) - @property - @json_serializable('CHOICE_SPEAKER_DEVICE') - def CHOICE_SPEAKER_DEVICE(self): - return self._CHOICE_SPEAKER_DEVICE - - @CHOICE_SPEAKER_DEVICE.setter - def CHOICE_SPEAKER_DEVICE(self, value): - if getDefaultOutputDevice()["name"] == value: - self._CHOICE_SPEAKER_DEVICE = value - saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value) - @property @json_serializable('INPUT_SPEAKER_ENERGY_THRESHOLD') def INPUT_SPEAKER_ENERGY_THRESHOLD(self): @@ -553,7 +542,6 @@ class Config: self._INPUT_MIC_PHRASE_TIMEOUT = 3 self._INPUT_MIC_MAX_PHRASES = 10 self._INPUT_MIC_WORD_FILTER = [] - self._CHOICE_SPEAKER_DEVICE = getDefaultOutputDevice()["name"] self._INPUT_SPEAKER_ENERGY_THRESHOLD = 300 self._INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD = False self._INPUT_SPEAKER_RECORD_TIMEOUT = 3 diff --git a/controller.py b/controller.py index 8717746b..228e55ed 100644 --- a/controller.py +++ b/controller.py @@ -108,7 +108,6 @@ def receiveSpeakerMessage(message): model.logger.info(f"[RECEIVED] {message}{translation}") def startTranscriptionReceiveMessage(): - config.CHOICE_SPEAKER_DEVICE = model.getOutputDefaultDevice() model.startSpeakerTranscript(receiveSpeakerMessage, view.printToTextbox_TranscriptionReceiveNoDeviceError) view.setMainWindowAllWidgetsStatusToNormal() @@ -129,7 +128,6 @@ def stopThreadingTranscriptionReceiveMessage(): th_stopTranscriptionReceiveMessage.start() def startTranscriptionReceiveMessageOnCloseConfigWindow(): - config.CHOICE_SPEAKER_DEVICE = model.getOutputDefaultDevice() model.startSpeakerTranscript(receiveSpeakerMessage, view.printToTextbox_TranscriptionReceiveNoDeviceError) @@ -474,14 +472,6 @@ def callbackSetMicWordFilter(value): model.resetKeywordProcessor() model.addKeywords() -# Transcription Tab (Speaker) -# def callbackSetSpeakerDevice(value): -# print("callbackSetSpeakerDevice", value) -# config.CHOICE_SPEAKER_DEVICE = value - -# model.stopCheckSpeakerEnergy() -# view.replaceSpeakerThresholdCheckButton_Passive() - def callbackSetSpeakerEnergyThreshold(value): print("callbackSetSpeakerEnergyThreshold", value) if value == "": return @@ -512,7 +502,6 @@ def callbackCheckSpeakerThreshold(is_turned_on): print("callbackCheckSpeakerThreshold", is_turned_on) if is_turned_on is True: view.replaceSpeakerThresholdCheckButton_Disabled() - config.CHOICE_SPEAKER_DEVICE = model.getOutputDefaultDevice() model.startCheckSpeakerEnergy( setProgressBarSpeakerEnergy, view.initProgressBar_SpeakerEnergy, diff --git a/model.py b/model.py index 08e0a528..da78a9a5 100644 --- a/model.py +++ b/model.py @@ -344,7 +344,8 @@ class Model: self.mic_energy_recorder = None def startSpeakerTranscript(self, fnc, error_fnc=None): - if config.CHOICE_SPEAKER_DEVICE == "NoDevice": + speaker_device = getDefaultOutputDevice() + if speaker_device["name"] == "NoDevice": try: error_fnc() except: @@ -358,7 +359,7 @@ class Model: record_timeout = phase_timeout self.speaker_audio_recorder = SelectedSpeakerRecorder( - device=config.CHOICE_SPEAKER_DEVICE , + device=speaker_device, energy_threshold=config.INPUT_SPEAKER_ENERGY_THRESHOLD, dynamic_energy_threshold=config.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD, record_timeout=record_timeout, @@ -391,7 +392,8 @@ class Model: self.speaker_audio_recorder = None def startCheckSpeakerEnergy(self, fnc, end_fnc, error_fnc=None): - if config.CHOICE_SPEAKER_DEVICE == "NoDevice": + speaker_device = getDefaultOutputDevice() + if speaker_device["name"] == "NoDevice": try: error_fnc() except: @@ -408,7 +410,7 @@ class Model: # sleep(0.01) speaker_energy_queue = Queue() - self.speaker_energy_recorder = SelectedSpeakeEnergyRecorder(config.CHOICE_SPEAKER_DEVICE) + self.speaker_energy_recorder = SelectedSpeakeEnergyRecorder(speaker_device) self.speaker_energy_recorder.recordIntoQueue(speaker_energy_queue) self.speaker_energy_plot_progressbar = threadFnc(sendSpeakerEnergy, end_fnc=end_fnc) self.speaker_energy_plot_progressbar.daemon = True