From 304d97ae224b296fbcadb9e99481a1d15cbe9c73 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Fri, 27 Sep 2024 02:07:32 +0900 Subject: [PATCH 1/6] =?UTF-8?q?=F0=9F=91=8D=EF=B8=8F[Update]=20Controller?= =?UTF-8?q?=20:=20class=E3=81=8B=E3=82=89=E9=96=A2=E6=95=B0=E3=81=AB?= =?UTF-8?q?=E5=A4=89=E5=8C=96=E3=81=97=E3=81=9F=E9=83=A8=E5=88=86=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-python/webui_controller.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src-python/webui_controller.py b/src-python/webui_controller.py index b449aaf8..43088f9f 100644 --- a/src-python/webui_controller.py +++ b/src-python/webui_controller.py @@ -125,7 +125,6 @@ class Controller: ) elif isinstance(message, str) and len(message) > 0: - # addSentMessageLog(message) translation = [] transliteration = [] if model.checkKeywords(message): @@ -245,7 +244,6 @@ class Controller: id = data["id"] message = data["message"] if len(message) > 0: - # addSentMessageLog(message) translation = [] transliteration = [] if config.ENABLE_TRANSLATION is False: @@ -1415,8 +1413,7 @@ class Controller: th_stopTranscriptionSendMessage.join() def startTranscriptionSendMessageOnCloseConfigWindow(self) -> None: - mic_message = self.MicMessage(self) - model.startMicTranscript(mic_message.send) + model.startMicTranscript(self.micMessage) @staticmethod def stopTranscriptionSendMessageOnOpenConfigWindow() -> None: @@ -1451,8 +1448,7 @@ class Controller: th_stopTranscriptionReceiveMessage.join() def startTranscriptionReceiveMessageOnCloseConfigWindow(self) -> None: - speaker_message = self.SpeakerMessage(self) - model.startSpeakerTranscript(speaker_message.receive) + model.startSpeakerTranscript(self.speakerMessage) @staticmethod def stopTranscriptionReceiveMessageOnOpenConfigWindow() -> None: From 98f53d4866ef12ae7e604a0fed81875054cdc330 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Fri, 27 Sep 2024 02:10:24 +0900 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=91=8D=EF=B8=8F[Update]=20Controller?= =?UTF-8?q?=20:=20=E7=BF=BB=E8=A8=B3=E3=82=A8=E3=83=B3=E3=82=B8=E3=83=B3?= =?UTF-8?q?=E3=81=8C=E5=AF=BE=E5=BF=9C=E3=81=97=E3=81=A6=E3=81=84=E3=81=AA?= =?UTF-8?q?=E3=81=84=E5=A0=B4=E5=90=88=E3=81=ABCTranslate2=E3=82=92?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-python/webui_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-python/webui_controller.py b/src-python/webui_controller.py index 43088f9f..b1936e69 100644 --- a/src-python/webui_controller.py +++ b/src-python/webui_controller.py @@ -1508,7 +1508,7 @@ class Controller: engine = config.SELECTED_TRANSLATION_ENGINES[config.SELECTED_TAB_NO] engines = self.getTranslationEngines()["result"] if engine not in engines: - engine = engines[0] + engine = "CTranslate2" config.SELECTED_TRANSLATION_ENGINES[config.SELECTED_TAB_NO] = engine self.run(200, self.run_mapping["selected_translation_engines"], config.SELECTED_TRANSLATION_ENGINES) self.run(200, self.run_mapping["translation_engines"], engines) From 0611ed21e3400feb1725eeacd9d0cdf7d1820871 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Fri, 27 Sep 2024 02:45:20 +0900 Subject: [PATCH 3/6] =?UTF-8?q?=F0=9F=91=8D=EF=B8=8F[Update]=20Controller?= =?UTF-8?q?=20:=20=E6=96=87=E5=AD=97=E8=B5=B7=E3=81=93=E3=81=97=E5=87=A6?= =?UTF-8?q?=E7=90=86=E3=81=AE=E3=83=87=E3=83=90=E3=82=A4=E3=82=B9=E8=87=AA?= =?UTF-8?q?=E5=8B=95=E8=A8=AD=E5=AE=9A=E6=A9=9F=E8=83=BD=E3=81=AB=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-python/config.py | 10 ++++++ src-python/webui_controller.py | 60 +++++++++++++--------------------- 2 files changed, 32 insertions(+), 38 deletions(-) diff --git a/src-python/config.py b/src-python/config.py index bc61ccd5..25748b7f 100644 --- a/src-python/config.py +++ b/src-python/config.py @@ -170,6 +170,15 @@ class Config: if isinstance(value, bool): self._ENABLE_CHECK_ENERGY_RECEIVE = value + @property + def IS_OPENED_CONFIG_WINDOW(self): + return self._IS_OPENED_CONFIG_WINDOW + + @IS_OPENED_CONFIG_WINDOW.setter + def IS_OPENED_CONFIG_WINDOW(self, value): + if isinstance(value, bool): + self._IS_OPENED_CONFIG_WINDOW = value + # @property # def SENT_MESSAGES_LOG(self): # return self._SENT_MESSAGES_LOG @@ -1000,6 +1009,7 @@ class Config: self._ENABLE_FOREGROUND = False self._ENABLE_CHECK_ENERGY_SEND = False self._ENABLE_CHECK_ENERGY_RECEIVE = False + self._IS_OPENED_CONFIG_WINDOW = False # self._SENT_MESSAGES_LOG = [] # self._CURRENT_SENT_MESSAGES_LOG_INDEX = 0 diff --git a/src-python/webui_controller.py b/src-python/webui_controller.py index b1936e69..0d14543d 100644 --- a/src-python/webui_controller.py +++ b/src-python/webui_controller.py @@ -58,6 +58,14 @@ class Controller: def updateSelectedMicDevice(self, host, device) -> None: config.SELECTED_MIC_HOST = host config.SELECTED_MIC_DEVICE = device + if config.IS_OPENED_CONFIG_WINDOW is False: + if config.ENABLE_TRANSCRIPTION_SEND is True: + model.stopMicTranscript() + model.startMicTranscript() + else: + if config.ENABLE_CHECK_ENERGY_SEND is True: + model.stopCheckMicEnergy() + model.startCheckMicEnergy self.run( 200, self.run_mapping["selected_mic_device"], @@ -66,6 +74,14 @@ class Controller: def updateSelectedSpeakerDevice(self, device) -> None: config.SELECTED_SPEAKER_DEVICE = device + if config.IS_OPENED_CONFIG_WINDOW is False: + if config.ENABLE_TRANSCRIPTION_RECEIVE is True: + model.stopSpeakerTranscript() + model.startSpeakerTranscript() + else: + if config.ENABLE_CHECK_ENERGY_RECEIVE is True: + model.stopCheckSpeakerEnergy() + model.startCheckSpeakerEnergy() self.run( 200, self.run_mapping["selected_speaker_device"], @@ -366,22 +382,24 @@ class Controller: return {"status":200, "result":config.ENABLE_FOREGROUND} def setEnableConfigWindow(self, *args, **kwargs) -> dict: + config.IS_OPENED_CONFIG_WINDOW = True if config.ENABLE_TRANSCRIPTION_SEND is True: - self.stopThreadingTranscriptionSendMessageOnOpenConfigWindow() + self.stopThreadingTranscriptionSendMessage() if config.ENABLE_TRANSCRIPTION_RECEIVE is True: - self.stopThreadingTranscriptionReceiveMessageOnOpenConfigWindow() + self.stopThreadingTranscriptionReceiveMessage() return {"status":200, "result":True} def setDisableConfigWindow(self, *args, **kwargs) -> dict: + config.IS_OPENED_CONFIG_WINDOW = False model.stopCheckMicEnergy() model.stopCheckSpeakerEnergy() if config.ENABLE_TRANSCRIPTION_SEND is True: - self.startThreadingTranscriptionSendMessageOnCloseConfigWindow() + self.startThreadingTranscriptionSendMessage() if config.ENABLE_TRANSCRIPTION_RECEIVE is True: sleep(2) if config.ENABLE_TRANSCRIPTION_RECEIVE is True: - self.startThreadingTranscriptionReceiveMessageOnCloseConfigWindow() + self.startThreadingTranscriptionReceiveMessage() return {"status":200, "result":True} @staticmethod @@ -1412,23 +1430,6 @@ class Controller: th_stopTranscriptionSendMessage.start() th_stopTranscriptionSendMessage.join() - def startTranscriptionSendMessageOnCloseConfigWindow(self) -> None: - model.startMicTranscript(self.micMessage) - - @staticmethod - def stopTranscriptionSendMessageOnOpenConfigWindow() -> None: - model.stopMicTranscript() - - def startThreadingTranscriptionSendMessageOnCloseConfigWindow(self) -> None: - th_startTranscriptionSendMessage = Thread(target=self.startTranscriptionSendMessageOnCloseConfigWindow) - th_startTranscriptionSendMessage.daemon = True - th_startTranscriptionSendMessage.start() - - def stopThreadingTranscriptionSendMessageOnOpenConfigWindow(self) -> None: - th_stopTranscriptionSendMessage = Thread(target=self.stopTranscriptionSendMessageOnOpenConfigWindow) - th_stopTranscriptionSendMessage.daemon = True - th_stopTranscriptionSendMessage.start() - def startTranscriptionReceiveMessage(self) -> None: model.startSpeakerTranscript(self.speakerMessage) @@ -1447,23 +1448,6 @@ class Controller: th_stopTranscriptionReceiveMessage.start() th_stopTranscriptionReceiveMessage.join() - def startTranscriptionReceiveMessageOnCloseConfigWindow(self) -> None: - model.startSpeakerTranscript(self.speakerMessage) - - @staticmethod - def stopTranscriptionReceiveMessageOnOpenConfigWindow() -> None: - model.stopSpeakerTranscript() - - def startThreadingTranscriptionReceiveMessageOnCloseConfigWindow(self) -> None: - th_startTranscriptionReceiveMessage = Thread(target=self.startTranscriptionReceiveMessageOnCloseConfigWindow) - th_startTranscriptionReceiveMessage.daemon = True - th_startTranscriptionReceiveMessage.start() - - def stopThreadingTranscriptionReceiveMessageOnOpenConfigWindow(self) -> None: - th_stopTranscriptionReceiveMessage = Thread(target=self.stopTranscriptionReceiveMessageOnOpenConfigWindow) - th_stopTranscriptionReceiveMessage.daemon = True - th_stopTranscriptionReceiveMessage.start() - @staticmethod def replaceExclamationsWithRandom(text): # ![...] にマッチする正規表現 From 107320ad28b60fd712b089af4ea62794a8730865 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Fri, 27 Sep 2024 17:37:20 +0900 Subject: [PATCH 4/6] =?UTF-8?q?=F0=9F=91=8D=EF=B8=8F[Update]=20Controller?= =?UTF-8?q?=20:=20Config=20Window=E3=81=AEOPEN/CLOSE=E6=A9=9F=E8=83=BD?= =?UTF-8?q?=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-python/config.py | 10 -------- src-python/webui_controller.py | 45 ++++++---------------------------- src-python/webui_mainloop.py | 3 --- 3 files changed, 8 insertions(+), 50 deletions(-) diff --git a/src-python/config.py b/src-python/config.py index 25748b7f..bc61ccd5 100644 --- a/src-python/config.py +++ b/src-python/config.py @@ -170,15 +170,6 @@ class Config: if isinstance(value, bool): self._ENABLE_CHECK_ENERGY_RECEIVE = value - @property - def IS_OPENED_CONFIG_WINDOW(self): - return self._IS_OPENED_CONFIG_WINDOW - - @IS_OPENED_CONFIG_WINDOW.setter - def IS_OPENED_CONFIG_WINDOW(self, value): - if isinstance(value, bool): - self._IS_OPENED_CONFIG_WINDOW = value - # @property # def SENT_MESSAGES_LOG(self): # return self._SENT_MESSAGES_LOG @@ -1009,7 +1000,6 @@ class Config: self._ENABLE_FOREGROUND = False self._ENABLE_CHECK_ENERGY_SEND = False self._ENABLE_CHECK_ENERGY_RECEIVE = False - self._IS_OPENED_CONFIG_WINDOW = False # self._SENT_MESSAGES_LOG = [] # self._CURRENT_SENT_MESSAGES_LOG_INDEX = 0 diff --git a/src-python/webui_controller.py b/src-python/webui_controller.py index 0d14543d..0a2ff0a5 100644 --- a/src-python/webui_controller.py +++ b/src-python/webui_controller.py @@ -58,14 +58,10 @@ class Controller: def updateSelectedMicDevice(self, host, device) -> None: config.SELECTED_MIC_HOST = host config.SELECTED_MIC_DEVICE = device - if config.IS_OPENED_CONFIG_WINDOW is False: - if config.ENABLE_TRANSCRIPTION_SEND is True: - model.stopMicTranscript() - model.startMicTranscript() - else: - if config.ENABLE_CHECK_ENERGY_SEND is True: - model.stopCheckMicEnergy() - model.startCheckMicEnergy + if config.ENABLE_TRANSCRIPTION_SEND is True: + model.startMicTranscript() + if config.ENABLE_CHECK_ENERGY_SEND is True: + model.startCheckMicEnergy() self.run( 200, self.run_mapping["selected_mic_device"], @@ -74,14 +70,10 @@ class Controller: def updateSelectedSpeakerDevice(self, device) -> None: config.SELECTED_SPEAKER_DEVICE = device - if config.IS_OPENED_CONFIG_WINDOW is False: - if config.ENABLE_TRANSCRIPTION_RECEIVE is True: - model.stopSpeakerTranscript() - model.startSpeakerTranscript() - else: - if config.ENABLE_CHECK_ENERGY_RECEIVE is True: - model.stopCheckSpeakerEnergy() - model.startCheckSpeakerEnergy() + if config.ENABLE_TRANSCRIPTION_RECEIVE is True: + model.startSpeakerTranscript() + if config.ENABLE_CHECK_ENERGY_RECEIVE is True: + model.startCheckSpeakerEnergy() self.run( 200, self.run_mapping["selected_speaker_device"], @@ -381,27 +373,6 @@ class Controller: config.ENABLE_FOREGROUND = False return {"status":200, "result":config.ENABLE_FOREGROUND} - def setEnableConfigWindow(self, *args, **kwargs) -> dict: - config.IS_OPENED_CONFIG_WINDOW = True - if config.ENABLE_TRANSCRIPTION_SEND is True: - self.stopThreadingTranscriptionSendMessage() - if config.ENABLE_TRANSCRIPTION_RECEIVE is True: - self.stopThreadingTranscriptionReceiveMessage() - return {"status":200, "result":True} - - def setDisableConfigWindow(self, *args, **kwargs) -> dict: - config.IS_OPENED_CONFIG_WINDOW = False - model.stopCheckMicEnergy() - model.stopCheckSpeakerEnergy() - - if config.ENABLE_TRANSCRIPTION_SEND is True: - self.startThreadingTranscriptionSendMessage() - if config.ENABLE_TRANSCRIPTION_RECEIVE is True: - sleep(2) - if config.ENABLE_TRANSCRIPTION_RECEIVE is True: - self.startThreadingTranscriptionReceiveMessage() - return {"status":200, "result":True} - @staticmethod def getSelectedTabNo(*args, **kwargs) -> dict: return {"status":200, "result":config.SELECTED_TAB_NO} diff --git a/src-python/webui_mainloop.py b/src-python/webui_mainloop.py index 25ff20cc..7a588373 100644 --- a/src-python/webui_mainloop.py +++ b/src-python/webui_mainloop.py @@ -58,9 +58,6 @@ mapping = { "/set/enable/foreground": {"status": True, "variable":controller.setEnableForeground}, "/set/disable/foreground": {"status": True, "variable":controller.setDisableForeground}, - "/set/enable/config_window": {"status": True, "variable":controller.setEnableConfigWindow}, - "/set/disable/config_window": {"status": True, "variable":controller.setDisableConfigWindow}, - "/get/data/selected_tab_no": {"status": True, "variable":controller.getSelectedTabNo}, "/set/data/selected_tab_no": {"status": True, "variable":controller.setSelectedTabNo}, From 12a2eb420a1cb5fca3eb8a628c9af007b505dcfb Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Fri, 27 Sep 2024 17:39:24 +0900 Subject: [PATCH 5/6] =?UTF-8?q?=F0=9F=91=8D=EF=B8=8F[Update]=20Controller?= =?UTF-8?q?=20:=20volume=20check=E6=99=82=E3=81=ABDevice=E3=81=AE=E8=87=AA?= =?UTF-8?q?=E5=8B=95=E5=88=87=E3=82=8A=E6=9B=BF=E3=81=88=E5=87=A6=E7=90=86?= =?UTF-8?q?=E3=81=8C=E5=8B=95=E4=BD=9C=E3=81=97=E3=81=AA=E3=81=84=E5=95=8F?= =?UTF-8?q?=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../transcription/transcription_utils.py | 20 +++++++++++++++++-- src-python/webui_controller.py | 18 +++++++++++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src-python/models/transcription/transcription_utils.py b/src-python/models/transcription/transcription_utils.py index 70552bab..b39a77f5 100644 --- a/src-python/models/transcription/transcription_utils.py +++ b/src-python/models/transcription/transcription_utils.py @@ -19,6 +19,12 @@ class Client(MMNotificationClient): def on_device_removed(self, removed_device_id): self.loop = False + def on_device_state_changed(self, device_id, state): + self.loop = False + + def on_property_value_changed(self, device_id, key): + self.loop = False + class DeviceManager: _instance = None @@ -46,6 +52,7 @@ class DeviceManager: self.callback_host_list = None self.callback_mic_device_list = None self.callback_speaker_device_list = None + self.callback_prev_update = None self.monitoring_flag = False self.startMonitoring() @@ -133,8 +140,8 @@ class DeviceManager: while cb.loop is True: sleep(1) enumerator.UnregisterEndpointNotificationCallback(cb) - sleep(1) - + self.runPrevUpdateDevices() + sleep(2) self.update() self.noticeDefaultDevice() @@ -185,6 +192,15 @@ class DeviceManager: def clearCallbackSpeakerDeviceList(self): self.callback_speaker_device_list = None + def setCallbackPrevUpdateDevices(self, callback): + self.callback_prev_update = callback + + def clearCallbackPrevUpdateDevices(self): + self.callback_prev_update = None + + def runPrevUpdateDevices(self): + self.callback_prev_update() + def noticeDefaultDevice(self): if self.callback_default_mic_device is not None: if self.prev_default_mic_device["device"]["name"] != self.default_mic_device["device"]["name"]: diff --git a/src-python/webui_controller.py b/src-python/webui_controller.py index 0a2ff0a5..80677a9b 100644 --- a/src-python/webui_controller.py +++ b/src-python/webui_controller.py @@ -55,6 +55,16 @@ class Controller: model.getListSpeakerDevice(), ) + def prevUpdateSelectedDevices(self) -> None: + if config.ENABLE_TRANSCRIPTION_SEND is True: + model.stopMicTranscript() + if config.ENABLE_TRANSCRIPTION_RECEIVE is True: + model.stopSpeakerTranscript() + if config.ENABLE_CHECK_ENERGY_SEND is True: + model.stopCheckMicEnergy() + if config.ENABLE_CHECK_ENERGY_RECEIVE is True: + model.stopCheckSpeakerEnergy() + def updateSelectedMicDevice(self, host, device) -> None: config.SELECTED_MIC_HOST = host config.SELECTED_MIC_DEVICE = device @@ -588,6 +598,7 @@ class Controller: def setEnableAutoMicSelect(self, *args, **kwargs) -> dict: config.AUTO_MIC_SELECT = True + device_manager.setCallbackPrevUpdateDevices(self.prevUpdateSelectedDevices) device_manager.setCallbackDefaultMicDevice(self.updateSelectedMicDevice) device_manager.noticeDefaultDevice() device_manager.forceSetMicDefaultDevice() @@ -595,6 +606,7 @@ class Controller: @staticmethod def setDisableAutoMicSelect(*args, **kwargs) -> dict: + device_manager.clearCallbackPrevUpdateDevices() device_manager.clearCallbackDefaultMicDevice() config.AUTO_MIC_SELECT = False return {"status":200, "result":config.AUTO_MIC_SELECT} @@ -771,6 +783,7 @@ class Controller: def setEnableAutoSpeakerSelect(self, *args, **kwargs) -> dict: config.AUTO_SPEAKER_SELECT = True + device_manager.setCallbackPrevUpdateDevices(self.prevUpdateSelectedDevices) device_manager.setCallbackDefaultSpeakerDevice(self.updateSelectedSpeakerDevice) device_manager.noticeDefaultDevice() device_manager.forceSetSpeakerDefaultDevice() @@ -778,6 +791,7 @@ class Controller: @staticmethod def setDisableAutoSpeakerSelect(*args, **kwargs) -> dict: + device_manager.clearCallbackPrevUpdateDevices() device_manager.clearCallbackDefaultSpeakerDevice() config.AUTO_SPEAKER_SELECT = False return {"status":200, "result":config.AUTO_SPEAKER_SELECT} @@ -1535,10 +1549,10 @@ class Controller: # init Auto device selection printLog("Init Auto Device Selection") if config.AUTO_MIC_SELECT is True: - device_manager.setCallbackDefaultMicDevice(self.updateSelectedMicDevice) + self.setEnableAutoMicSelect() if config.AUTO_SPEAKER_SELECT is True: - device_manager.setCallbackDefaultSpeakerDevice(self.updateSelectedSpeakerDevice) + self.setEnableAutoSpeakerSelect() device_manager.setCallbackHostList(self.updateMicHostList) device_manager.setCallbackMicDeviceList(self.updateMicDeviceList) From 0b29ad83214b78c6e9a3680a52f19d5f64a629a1 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Fri, 27 Sep 2024 21:58:48 +0900 Subject: [PATCH 6/6] =?UTF-8?q?=F0=9F=91=8D=EF=B8=8F[Update]=20Controller?= =?UTF-8?q?=20:=20transcription=E5=AE=9F=E8=A1=8C=E6=99=82=E3=81=ABDevice?= =?UTF-8?q?=E3=81=AE=E8=87=AA=E5=8B=95=E5=88=87=E3=82=8A=E6=9B=BF=E3=81=88?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=81=8C=E5=8B=95=E4=BD=9C=E3=81=97=E3=81=AA?= =?UTF-8?q?=E3=81=84=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../transcription/transcription_utils.py | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src-python/models/transcription/transcription_utils.py b/src-python/models/transcription/transcription_utils.py index b39a77f5..f33a6983 100644 --- a/src-python/models/transcription/transcription_utils.py +++ b/src-python/models/transcription/transcription_utils.py @@ -137,17 +137,20 @@ class DeviceManager: enumerator.RegisterEndpointNotificationCallback(cb) try: while self.monitoring_flag is True: - while cb.loop is True: - sleep(1) - enumerator.UnregisterEndpointNotificationCallback(cb) - self.runPrevUpdateDevices() - sleep(2) - self.update() - self.noticeDefaultDevice() - - cb = Client() - enumerator = AudioUtilities.GetDeviceEnumerator() - enumerator.RegisterEndpointNotificationCallback(cb) + try: + while cb.loop is True: + sleep(1) + enumerator.UnregisterEndpointNotificationCallback(cb) + self.runPrevUpdateDevices() + sleep(2) + self.update() + self.noticeDefaultDevice() + except Exception: + pass + finally: + cb = Client() + enumerator = AudioUtilities.GetDeviceEnumerator() + enumerator.RegisterEndpointNotificationCallback(cb) except Exception: pass comtypes.CoUninitialize()