From e8c65ed81f4c505f5ff194081e21c5a898d1e2b9 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Fri, 13 Sep 2024 13:48:50 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8D=EF=B8=8F[Update]=20Model=20:=20def?= =?UTF-8?q?ault=E3=81=AE=E3=83=87=E3=83=90=E3=82=A4=E3=82=B9=E5=8B=95?= =?UTF-8?q?=E4=BD=9C=E3=81=99=E3=82=8B=E6=A9=9F=E8=83=BD=E3=81=AEendpoint?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-python/config.py | 29 ++++++++++++++--------------- src-python/model.py | 8 ++++---- src-python/webui_controller.py | 22 ++++++++++++++++++++++ src-python/webui_mainloop.py | 6 ++++++ 4 files changed, 46 insertions(+), 19 deletions(-) diff --git a/src-python/config.py b/src-python/config.py index df72c0cb..a2c2608e 100644 --- a/src-python/config.py +++ b/src-python/config.py @@ -5,7 +5,6 @@ from json import load as json_load from json import dump as json_dump import tkinter as tk from tkinter import font -from models.translation.translation_languages import translation_lang from models.transcription.transcription_utils import getInputDevices, getDefaultInputDevice, getOutputDevices, getDefaultOutputDevice from models.transcription.transcription_languages import transcription_lang from utils import generatePercentageStringsList, isUniqueStrings @@ -458,14 +457,14 @@ class Config: saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, self.MAIN_WINDOW_GEOMETRY) @property - @json_serializable('INPUT_MIC_AUTOMATIC_SELECTION') - def INPUT_MIC_AUTOMATIC_SELECTION(self): - return self._INPUT_MIC_AUTOMATIC_SELECTION + @json_serializable('ENABLE_MIC_AUTOMATIC_SELECTION') + def ENABLE_MIC_AUTOMATIC_SELECTION(self): + return self._ENABLE_MIC_AUTOMATIC_SELECTION - @INPUT_MIC_AUTOMATIC_SELECTION.setter - def INPUT_MIC_AUTOMATIC_SELECTION(self, value): + @ENABLE_MIC_AUTOMATIC_SELECTION.setter + def ENABLE_MIC_AUTOMATIC_SELECTION(self, value): if isinstance(value, bool): - self._INPUT_MIC_AUTOMATIC_SELECTION = value + self._ENABLE_MIC_AUTOMATIC_SELECTION = value saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value) @property @@ -579,14 +578,14 @@ class Config: saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value) @property - @json_serializable('INPUT_SPEAKER_AUTOMATIC_SELECTION') - def INPUT_SPEAKER_AUTOMATIC_SELECTION(self): - return self._INPUT_SPEAKER_AUTOMATIC_SELECTION + @json_serializable('ENABLE_SPEAKER_AUTOMATIC_SELECTION') + def ENABLE_SPEAKER_AUTOMATIC_SELECTION(self): + return self._ENABLE_SPEAKER_AUTOMATIC_SELECTION - @INPUT_SPEAKER_AUTOMATIC_SELECTION.setter - def INPUT_SPEAKER_AUTOMATIC_SELECTION(self, value): + @ENABLE_SPEAKER_AUTOMATIC_SELECTION.setter + def ENABLE_SPEAKER_AUTOMATIC_SELECTION(self, value): if isinstance(value, bool): - self._INPUT_SPEAKER_AUTOMATIC_SELECTION = value + self._ENABLE_SPEAKER_AUTOMATIC_SELECTION = value saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value) @property @@ -1139,7 +1138,7 @@ class Config: "width": "870", "height": "654", } - self._INPUT_MIC_AUTOMATIC_SELECTION = True + self._ENABLE_MIC_AUTOMATIC_SELECTION = True self._CHOICE_MIC_HOST = getDefaultInputDevice()["host"]["name"] self._CHOICE_MIC_DEVICE = getDefaultInputDevice()["device"]["name"] self._INPUT_MIC_ENERGY_THRESHOLD = 300 @@ -1150,7 +1149,7 @@ class Config: self._INPUT_MIC_WORD_FILTER = [] self._INPUT_MIC_AVG_LOGPROB=-0.8 self._INPUT_MIC_NO_SPEECH_PROB=0.6 - self._INPUT_SPEAKER_AUTOMATIC_SELECTION = True + self._ENABLE_SPEAKER_AUTOMATIC_SELECTION = True self._CHOICE_SPEAKER_DEVICE = getDefaultOutputDevice()["device"]["name"] self._INPUT_SPEAKER_ENERGY_THRESHOLD = 300 self._INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD = False diff --git a/src-python/model.py b/src-python/model.py index b060157a..b0363f25 100644 --- a/src-python/model.py +++ b/src-python/model.py @@ -423,7 +423,7 @@ class Model: return [device["name"] for device in getOutputDevices()] def startMicTranscript(self, fnc): - if config.INPUT_MIC_AUTOMATIC_SELECTION is True: + if config.ENABLE_MIC_AUTOMATIC_SELECTION is True: default_device = getDefaultInputDevice() mic_host_name = default_device["host"]["name"] mic_device_name = default_device["device"]["name"] @@ -554,7 +554,7 @@ class Model: # self.mic_get_energy = None def startCheckMicEnergy(self, fnc): - if config.INPUT_MIC_AUTOMATIC_SELECTION is True: + if config.ENABLE_MIC_AUTOMATIC_SELECTION is True: default_device = getDefaultInputDevice() mic_host_name = default_device["host"]["name"] mic_device_name = default_device["device"]["name"] @@ -596,7 +596,7 @@ class Model: self.mic_energy_recorder = None def startSpeakerTranscript(self, fnc): - if config.INPUT_SPEAKER_AUTOMATIC_SELECTION is True: + if config.ENABLE_SPEAKER_AUTOMATIC_SELECTION is True: default_device = getDefaultOutputDevice() speaker_device_name = default_device["device"]["name"] else: @@ -685,7 +685,7 @@ class Model: # self.speaker_get_energy = None def startCheckSpeakerEnergy(self, fnc): - if config.INPUT_SPEAKER_AUTOMATIC_SELECTION is True: + if config.ENABLE_SPEAKER_AUTOMATIC_SELECTION is True: default_device = getDefaultOutputDevice() speaker_device_name = default_device["device"]["name"] else: diff --git a/src-python/webui_controller.py b/src-python/webui_controller.py index f16fe514..080eb015 100644 --- a/src-python/webui_controller.py +++ b/src-python/webui_controller.py @@ -794,6 +794,17 @@ def callbackClearDeeplAuthKey(*args, **kwargs) -> dict: # Transcription Tab # Transcription (Mic) + +def callbackEnableMicAutomaticSelection(*args, **kwargs) -> dict: + printLog("Enable Mic Automatic Selection") + config.ENABLE_MIC_AUTOMATIC_SELECTION = True + return {"status":200, "result":config.ENABLE_MIC_AUTOMATIC_SELECTION} + +def callbackDisableMicAutomaticSelection(*args, **kwargs) -> dict: + printLog("Disable Mic Automatic Selection") + config.ENABLE_MIC_AUTOMATIC_SELECTION = False + return {"status":200, "result":config.ENABLE_MIC_AUTOMATIC_SELECTION} + def callbackSetMicHost(data, *args, **kwargs) -> dict: printLog("Set Mic Host", data) config.CHOICE_MIC_HOST = data @@ -931,6 +942,17 @@ def callbackDeleteMicWordFilter(data, *args, **kwargs) -> dict: return {"status":200, "result":config.INPUT_MIC_WORD_FILTER} # Transcription (Speaker) + +def callbackEnableSpeakerAutomaticSelection(*args, **kwargs) -> dict: + printLog("Enable Speaker Automatic Selection") + config.ENABLE_SPEAKER_AUTOMATIC_SELECTION = True + return {"status":200, "result":config.ENABLE_SPEAKER_AUTOMATIC_SELECTION} + +def callbackDisableSpeakerAutomaticSelection(*args, **kwargs) -> dict: + printLog("Disable Speaker Automatic Selection") + config.ENABLE_SPEAKER_AUTOMATIC_SELECTION = False + return {"status":200, "result":config.ENABLE_SPEAKER_AUTOMATIC_SELECTION} + def callbackSetSpeakerDevice(data, *args, **kwargs) -> dict: printLog("Set Speaker Device", data) config.CHOICE_SPEAKER_DEVICE = data diff --git a/src-python/webui_mainloop.py b/src-python/webui_mainloop.py index 3f408a5a..5679cb52 100644 --- a/src-python/webui_mainloop.py +++ b/src-python/webui_mainloop.py @@ -42,6 +42,7 @@ config_mapping = { "/config/ui_language": "UI_LANGUAGE", "/config/enable_restore_main_window_geometry": "ENABLE_RESTORE_MAIN_WINDOW_GEOMETRY", "/config/main_window_geometry": "MAIN_WINDOW_GEOMETRY", + "/config/ENABLE_MIC_AUTOMATIC_SELECTION": "ENABLE_MIC_AUTOMATIC_SELECTION", "/config/choice_mic_host": "CHOICE_MIC_HOST", "/config/choice_mic_device": "CHOICE_MIC_DEVICE", "/config/input_mic_energy_threshold": "INPUT_MIC_ENERGY_THRESHOLD", @@ -52,6 +53,7 @@ config_mapping = { "/config/input_mic_word_filter": "INPUT_MIC_WORD_FILTER", "/config/input_mic_avg_logprob": "INPUT_MIC_AVG_LOGPROB", "/config/input_mic_no_speech_prob": "INPUT_MIC_NO_SPEECH_PROB", + "/config/ENABLE_SPEAKER_AUTOMATIC_SELECTION": "ENABLE_SPEAKER_AUTOMATIC_SELECTION", "/config/choice_speaker_device": "CHOICE_SPEAKER_DEVICE", "/config/input_speaker_energy_threshold": "INPUT_SPEAKER_ENERGY_THRESHOLD", "/config/input_speaker_dynamic_energy_threshold": "INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD", @@ -140,6 +142,8 @@ controller_mapping = { "/controller/callback_download_ctranslate2_weight": controller.callbackDownloadCtranslate2Weight, "/controller/callback_set_deepl_auth_key": controller.callbackSetDeeplAuthKey, "/controller/callback_clear_deepl_auth_key": controller.callbackClearDeeplAuthKey, + "/controller/callback_enable_mic_automatic_selection": controller.callbackEnableMicAutomaticSelection, + "/controller/callback_disable_mic_automatic_selection": controller.callbackDisableMicAutomaticSelection, "/controller/callback_set_mic_host": controller.callbackSetMicHost, "/controller/callback_set_mic_device": controller.callbackSetMicDevice, "/controller/callback_set_mic_energy_threshold": controller.callbackSetMicEnergyThreshold, @@ -152,6 +156,8 @@ controller_mapping = { "/controller/callback_set_mic_max_phrases": controller.callbackSetMicMaxPhrases, "/controller/callback_set_mic_word_filter": controller.callbackSetMicWordFilter, "/controller/callback_delete_mic_word_filter": controller.callbackDeleteMicWordFilter, + "/controller/callback_enable_speaker_automatic_selection": controller.callbackEnableSpeakerAutomaticSelection, + "/controller/callback_disable_speaker_automatic_selection": controller.callbackDisableSpeakerAutomaticSelection, "/controller/callback_set_speaker_device": controller.callbackSetSpeakerDevice, "/controller/callback_set_speaker_energy_threshold": controller.callbackSetSpeakerEnergyThreshold, "/controller/callback_enable_speaker_dynamic_energy_threshold": controller.callbackEnableSpeakerDynamicEnergyThreshold,