diff --git a/controller.py b/controller.py index dab14af3..df38e1ec 100644 --- a/controller.py +++ b/controller.py @@ -491,12 +491,12 @@ def callbackSetMicWordFilter(value): model.addKeywords() # Transcription Tab (Speaker) -def callbackSetSpeakerDevice(value): - print("callbackSetSpeakerDevice", value) - config.CHOICE_SPEAKER_DEVICE = value +# def callbackSetSpeakerDevice(value): +# print("callbackSetSpeakerDevice", value) +# config.CHOICE_SPEAKER_DEVICE = value - model.stopCheckSpeakerEnergy() - view.replaceSpeakerThresholdCheckButton_Passive() +# model.stopCheckSpeakerEnergy() +# view.replaceSpeakerThresholdCheckButton_Passive() def callbackSetSpeakerEnergyThreshold(value): print("callbackSetSpeakerEnergyThreshold", value) @@ -708,7 +708,7 @@ def createMainWindow(): "callback_set_mic_word_filter": callbackSetMicWordFilter, # Transcription Tab (Speaker) - "callback_set_speaker_device": callbackSetSpeakerDevice, + # "callback_set_speaker_device": callbackSetSpeakerDevice, "list_speaker_device": model.getListOutputDevice(), "callback_set_speaker_energy_threshold": callbackSetSpeakerEnergyThreshold, "callback_set_speaker_dynamic_energy_threshold": callbackSetSpeakerDynamicEnergyThreshold, diff --git a/model.py b/model.py index 9ba41389..93ad8882 100644 --- a/model.py +++ b/model.py @@ -13,6 +13,7 @@ from requests import get as requests_get import webbrowser from flashtext import KeywordProcessor +import pyaudiowpatch from models.translation.translation_translator import Translator from models.transcription.transcription_utils import getInputDevices, getOutputDevices, getDefaultInputDevice, getDefaultOutputDevice from models.osc.osc_tools import sendTyping, sendMessage, sendTestAction, receiveOscParameters @@ -311,13 +312,6 @@ class Model: def getListOutputDevice(): return [device["name"] for device in getOutputDevices()] - @staticmethod - def checkSpeakerStatus(choice=config.CHOICE_SPEAKER_DEVICE): - speaker_device = [device for device in getOutputDevices() if device["name"] == choice][0] - if getDefaultOutputDevice()["index"] == speaker_device["index"]: - return True - return False - def startMicTranscript(self, fnc): if config.CHOICE_MIC_HOST == "NoHost" or config.CHOICE_MIC_DEVICE == "NoDevice": return @@ -392,10 +386,11 @@ class Model: self.mic_energy_recorder = None def startSpeakerTranscript(self, fnc): + speaker_device = getDefaultOutputDevice() + config.CHOICE_SPEAKER_DEVICE = speaker_device["name"] if config.CHOICE_SPEAKER_DEVICE == "NoDevice": return speaker_audio_queue = Queue() - speaker_device = [device for device in getOutputDevices() if device["name"] == config.CHOICE_SPEAKER_DEVICE][0] record_timeout = config.INPUT_SPEAKER_RECORD_TIMEOUT phase_timeout = config.INPUT_SPEAKER_PHRASE_TIMEOUT @@ -436,6 +431,8 @@ class Model: self.speaker_audio_recorder = None def startCheckSpeakerEnergy(self, fnc, end_fnc): + speaker_device = getDefaultOutputDevice() + config.CHOICE_SPEAKER_DEVICE = speaker_device["name"] if config.CHOICE_SPEAKER_DEVICE == "NoDevice": return @@ -448,7 +445,6 @@ class Model: pass # sleep(0.01) - speaker_device = [device for device in getOutputDevices() if device["name"] == config.CHOICE_SPEAKER_DEVICE][0] speaker_energy_queue = Queue() self.speaker_energy_recorder = SelectedSpeakeEnergyRecorder(speaker_device) self.speaker_energy_recorder.recordIntoQueue(speaker_energy_queue)