From d183c56736aa02b52e600e8b13051fbd7694f4ec Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Thu, 3 Oct 2024 15:50:25 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20[WIP/TEST]=20Device=E3=81=AE?= =?UTF-8?q?=E8=87=AA=E5=8B=95=E5=A4=89=E6=9B=B4=E3=81=AB=E5=AF=BE=E5=BF=9C?= =?UTF-8?q?=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 検出処理を修正、たまに変化を検出しても応答しない場合がある --- .../transcription/transcription_utils.py | 37 +++++++------------ src-python/webui_controller.py | 4 +- 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/src-python/models/transcription/transcription_utils.py b/src-python/models/transcription/transcription_utils.py index 0d2ac050..d1f0cc62 100644 --- a/src-python/models/transcription/transcription_utils.py +++ b/src-python/models/transcription/transcription_utils.py @@ -140,7 +140,6 @@ class DeviceManager: self.default_speaker_device = buffer_default_speaker_device def checkUpdate(self): - printLog("checkUpdate") if self.prev_default_mic_device["device"]["name"] != self.default_mic_device["device"]["name"]: printLog("checkUpdate: default_mic_device") self.update_flag_default_mic_device = True @@ -176,34 +175,26 @@ class DeviceManager: while self.monitoring_flag is True: try: comtypes.CoInitialize() - self.cb = Client() - self.enumerator = AudioUtilities.GetDeviceEnumerator() - self.enumerator.RegisterEndpointNotificationCallback(self.cb) - while self.cb.loop is True: - printLog("Monitoring Loop") + cb = Client() + enumerator = AudioUtilities.GetDeviceEnumerator() + enumerator.RegisterEndpointNotificationCallback(cb) + while cb.loop is True: sleep(1) - self.enumerator.UnregisterEndpointNotificationCallback(self.cb) + enumerator.UnregisterEndpointNotificationCallback(cb) + comtypes.CoUninitialize() + self.runProcessBeforeUpdateDevices() + sleep(2) + self.update() + self.checkUpdate() + self.noticeUpdateDevices() + self.runProcessAfterUpdateDevices() except Exception as e: printLog("Device Monitoring: ", e) finally: printLog("Device Monitoring Finally Init") - comtypes.CoUninitialize() - - printLog("Run Process Before Update Devices") - self.runProcessBeforeUpdateDevices() - while True: - sleep(2) - self.update() - if self.checkUpdate() is True: - break - printLog("Notice Update Devices") - self.noticeUpdateDevices() - printLog("Run Process After Update Devices") - self.runProcessAfterUpdateDevices() - except Exception as e: - printLog("Device Monitoring Exception: ", e) - printLog("Device Monitoring End") + printLog("Device Monitoring End Exception: ", e) + def startMonitoring(self): self.monitoring_flag = True diff --git a/src-python/webui_controller.py b/src-python/webui_controller.py index 07c56284..7b055401 100644 --- a/src-python/webui_controller.py +++ b/src-python/webui_controller.py @@ -76,9 +76,9 @@ class Controller: def stopAccessDevices(self) -> None: if config.ENABLE_TRANSCRIPTION_SEND is True: - model.stopMicTranscript() + self.stopThreadingTranscriptionSendMessage() if config.ENABLE_TRANSCRIPTION_RECEIVE is True: - model.stopSpeakerTranscript() + self.stopThreadingTranscriptionReceiveMessage() if config.ENABLE_CHECK_ENERGY_SEND is True: model.stopCheckMicEnergy() if config.ENABLE_CHECK_ENERGY_RECEIVE is True: