👍️[Update] Model : Deviceの変更監視処理を追加
マイク/スピーカーの別々のスレッドの処理を一つにまとめたら動いた
This commit is contained in:
@@ -69,6 +69,7 @@ class Model:
|
||||
|
||||
def init(self):
|
||||
self.logger = None
|
||||
self.th_check_device = None
|
||||
self.mic_print_transcript = None
|
||||
self.mic_audio_recorder = None
|
||||
self.mic_energy_recorder = None
|
||||
@@ -422,8 +423,8 @@ class Model:
|
||||
def getListOutputDevice():
|
||||
return [device["name"] for device in getOutputDevices()]
|
||||
|
||||
def startAutomaticMicSelection(self, fnc):
|
||||
def checkMicDevice(fnc):
|
||||
def startAutomaticDeviceSelection(self, fnc_mic, fnc_speaker):
|
||||
def checkDevice(fnc_mic, fnc_speaker):
|
||||
if config.ENABLE_MIC_AUTOMATIC_SELECTION is True:
|
||||
default_device = getDefaultInputDevice()
|
||||
mic_host_name = default_device["host"]["name"]
|
||||
@@ -431,36 +432,26 @@ class Model:
|
||||
if mic_host_name != config.CHOICE_MIC_HOST or mic_device_name != config.CHOICE_MIC_DEVICE:
|
||||
config.CHOICE_MIC_HOST = mic_host_name
|
||||
config.CHOICE_MIC_DEVICE = mic_device_name
|
||||
fnc(config.CHOICE_MIC_DEVICE)
|
||||
sleep(2)
|
||||
fnc_mic(config.CHOICE_MIC_DEVICE)
|
||||
|
||||
self.th_check_mic_device = threadFnc(checkMicDevice, args=(fnc,))
|
||||
self.th_check_mic_device.daemon = True
|
||||
self.th_check_mic_device.start()
|
||||
|
||||
def stopAutomaticMicSelection(self):
|
||||
if isinstance(self.th_check_mic_device, threadFnc):
|
||||
self.th_check_mic_device.stop()
|
||||
self.th_check_mic_device = None
|
||||
|
||||
def startAutomaticSpeakerSelection(self, fnc):
|
||||
def checkSpeakerDevice(fnc):
|
||||
if config.ENABLE_SPEAKER_AUTOMATIC_SELECTION is True:
|
||||
default_device = getDefaultOutputDevice()
|
||||
speaker_device_name = default_device["device"]["name"]
|
||||
if speaker_device_name != config.CHOICE_SPEAKER_DEVICE:
|
||||
config.CHOICE_SPEAKER_DEVICE = speaker_device_name
|
||||
fnc(config.CHOICE_SPEAKER_DEVICE)
|
||||
sleep(2)
|
||||
fnc_speaker(config.CHOICE_SPEAKER_DEVICE)
|
||||
sleep(1)
|
||||
|
||||
self.th_check_speaker_device = threadFnc(checkSpeakerDevice, args=(fnc,))
|
||||
self.th_check_speaker_device.daemon = True
|
||||
self.th_check_speaker_device.start()
|
||||
if isinstance(self.th_check_device, threadFnc) is False:
|
||||
self.th_check_device = threadFnc(checkDevice, args=(fnc_mic, fnc_speaker,))
|
||||
self.th_check_device.daemon = True
|
||||
self.th_check_device.start()
|
||||
|
||||
def stopAutomaticSpeakerSelection(self):
|
||||
if isinstance(self.th_check_speaker_device, threadFnc):
|
||||
self.th_check_speaker_device.stop()
|
||||
self.th_check_speaker_device = None
|
||||
def stopAutomaticDeviceSelection(self):
|
||||
if config.ENABLE_MIC_AUTOMATIC_SELECTION is False and config.ENABLE_SPEAKER_AUTOMATIC_SELECTION is False:
|
||||
if isinstance(self.th_check_device, threadFnc):
|
||||
self.th_check_device.stop()
|
||||
self.th_check_device = None
|
||||
|
||||
def startMicTranscript(self, fnc):
|
||||
if config.ENABLE_MIC_AUTOMATIC_SELECTION is True:
|
||||
|
||||
Reference in New Issue
Block a user