diff --git a/VRCT.py b/VRCT.py index bec6fb5b..9e85d309 100644 --- a/VRCT.py +++ b/VRCT.py @@ -41,14 +41,18 @@ class App(customtkinter.CTk): self.INPUT_TARGET_LANG = list(languages.translation_lang[self.CHOICE_TRANSLATOR].keys())[1] self.OUTPUT_SOURCE_LANG = list(languages.translation_lang[self.CHOICE_TRANSLATOR].keys())[1] self.OUTPUT_TARGET_LANG = list(languages.translation_lang[self.CHOICE_TRANSLATOR].keys())[0] - ## Transcription + ## Transcription Send self.CHOICE_MIC_DEVICE = audio_utils.get_default_input_device()["name"] self.INPUT_MIC_VOICE_LANGUAGE = list(languages.transcription_lang.keys())[0] - self.INPUT_MIC_IS_DYNAMIC = False - self.INPUT_MIC_THRESHOLD = 300 + self.INPUT_MIC_ENERGY_THRESHOLD = 1000 + self.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD = False + self.INPUT_MIC_RECORD_TIMEOUT = 3 + ## Transcription Receive self.CHOICE_SPEAKER_DEVICE = audio_utils.get_default_output_device()["name"] self.INPUT_SPEAKER_VOICE_LANGUAGE = list(languages.transcription_lang.keys())[1] - self.INPUT_SPEAKER_INTERVAL = 4 + self.INPUT_SPEAKER_ENERGY_THRESHOLD = 1000 + self.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD = False + self.INPUT_SPEAKER_RECORD_TIMEOUT = 3 ## Parameter self.OSC_IP_ADDRESS = "127.0.0.1" @@ -118,21 +122,30 @@ class App(customtkinter.CTk): if "INPUT_MIC_VOICE_LANGUAGE" in config.keys(): if config["INPUT_MIC_VOICE_LANGUAGE"] in list(languages.transcription_lang.keys()): self.INPUT_MIC_VOICE_LANGUAGE = config["INPUT_MIC_VOICE_LANGUAGE"] - if "INPUT_MIC_IS_DYNAMIC" in config.keys(): - if type(config["INPUT_MIC_IS_DYNAMIC"]) is bool: - self.INPUT_MIC_IS_DYNAMIC = config["INPUT_MIC_IS_DYNAMIC"] - if "INPUT_MIC_THRESHOLD" in config.keys(): - if type(config["INPUT_MIC_THRESHOLD"]) is int: - self.INPUT_MIC_THRESHOLD = config["INPUT_MIC_THRESHOLD"] + if "INPUT_MIC_ENERGY_THRESHOLD" in config.keys(): + if type(config["INPUT_MIC_ENERGY_THRESHOLD"]) is int: + self.INPUT_MIC_ENERGY_THRESHOLD = config["INPUT_MIC_ENERGY_THRESHOLD"] + if "INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD" in config.keys(): + if type(config["INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD"]) is bool: + self.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD = config["INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD"] + if "INPUT_MIC_RECORD_TIMEOUT" in config.keys(): + if type(config["INPUT_MIC_RECORD_TIMEOUT"]) is int: + self.INPUT_MIC_RECORD_TIMEOUT = config["INPUT_MIC_RECORD_TIMEOUT"] if "CHOICE_SPEAKER_DEVICE" in config.keys(): if config["CHOICE_SPEAKER_DEVICE"] in [device["name"] for device in audio_utils.get_output_device_list()]: self.CHOICE_SPEAKER_DEVICE = config["CHOICE_SPEAKER_DEVICE"] if "INPUT_SPEAKER_VOICE_LANGUAGE" in config.keys(): if config["INPUT_SPEAKER_VOICE_LANGUAGE"] in list(languages.transcription_lang.keys()): self.INPUT_SPEAKER_VOICE_LANGUAGE = config["INPUT_SPEAKER_VOICE_LANGUAGE"] - if "INPUT_SPEAKER_INTERVAL" in config.keys(): - if type(config["INPUT_SPEAKER_INTERVAL"]) is int: - self.INPUT_SPEAKER_INTERVAL = config["INPUT_SPEAKER_INTERVAL"] + if "INPUT_SPEAKER_ENERGY_THRESHOLD" in config.keys(): + if type(config["INPUT_SPEAKER_ENERGY_THRESHOLD"]) is int: + self.INPUT_SPEAKER_ENERGY_THRESHOLD = config["INPUT_SPEAKER_ENERGY_THRESHOLD"] + if "INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD" in config.keys(): + if type(config["INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD"]) is bool: + self.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD = config["INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD"] + if "INPUT_SPEAKER_RECORD_TIMEOUT" in config.keys(): + if type(config["INPUT_SPEAKER_RECORD_TIMEOUT"]) is int: + self.INPUT_SPEAKER_RECORD_TIMEOUT = config["INPUT_SPEAKER_RECORD_TIMEOUT"] # Parameter if "OSC_IP_ADDRESS" in config.keys(): @@ -168,11 +181,14 @@ class App(customtkinter.CTk): "OUTPUT_TARGET_LANG": self.OUTPUT_TARGET_LANG, "CHOICE_MIC_DEVICE": self.CHOICE_MIC_DEVICE, "INPUT_MIC_VOICE_LANGUAGE": self.INPUT_MIC_VOICE_LANGUAGE, - "INPUT_MIC_IS_DYNAMIC": self.INPUT_MIC_IS_DYNAMIC, - "INPUT_MIC_THRESHOLD": self.INPUT_MIC_THRESHOLD, + "INPUT_MIC_ENERGY_THRESHOLD": self.INPUT_MIC_ENERGY_THRESHOLD, + "INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD": self.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD, + "INPUT_MIC_RECORD_TIMEOUT": self.INPUT_MIC_RECORD_TIMEOUT, "CHOICE_SPEAKER_DEVICE": self.CHOICE_SPEAKER_DEVICE, "INPUT_SPEAKER_VOICE_LANGUAGE": self.INPUT_SPEAKER_VOICE_LANGUAGE, - "INPUT_SPEAKER_INTERVAL": self.INPUT_SPEAKER_INTERVAL, + "INPUT_SPEAKER_ENERGY_THRESHOLD": self.INPUT_SPEAKER_ENERGY_THRESHOLD, + "INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD": self.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD, + "INPUT_SPEAKER_RECORD_TIMEOUT": self.INPUT_SPEAKER_RECORD_TIMEOUT, "OSC_IP_ADDRESS": self.OSC_IP_ADDRESS, "OSC_PORT": self.OSC_PORT, "AUTH_KEYS": self.AUTH_KEYS, @@ -397,7 +413,12 @@ class App(customtkinter.CTk): if self.ENABLE_TRANSCRIPTION_SEND is True: self.mic_audio_queue = queue.Queue() mic_device = [device for device in audio_utils.get_input_device_list() if device["name"] == self.CHOICE_MIC_DEVICE][0] - self.mic_audio_recorder = audio_recorder.SelectedMicRecorder(mic_device) + self.mic_audio_recorder = audio_recorder.SelectedMicRecorder( + mic_device, + self.INPUT_MIC_ENERGY_THRESHOLD, + self.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD, + self.INPUT_MIC_RECORD_TIMEOUT, + ) self.mic_audio_recorder.record_into_queue(self.mic_audio_queue) self.mic_transcriber = audio_transcriber.AudioTranscriber( speaker=False, @@ -430,7 +451,12 @@ class App(customtkinter.CTk): if self.ENABLE_TRANSCRIPTION_RECEIVE is True: self.spk_audio_queue = queue.Queue() spk_device = [device for device in audio_utils.get_output_device_list() if device["name"] == self.CHOICE_SPEAKER_DEVICE][0] - self.spk_audio_recorder = audio_recorder.SelectedSpeakerRecorder(spk_device) + self.spk_audio_recorder = audio_recorder.SelectedSpeakerRecorder( + spk_device, + self.INPUT_SPEAKER_ENERGY_THRESHOLD, + self.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD, + self.INPUT_SPEAKER_RECORD_TIMEOUT, + ) self.spk_audio_recorder.record_into_queue(self.spk_audio_queue) self.spk_transcriber = audio_transcriber.AudioTranscriber( speaker=True, diff --git a/audio_recorder.py b/audio_recorder.py index c402147d..85a3d434 100644 --- a/audio_recorder.py +++ b/audio_recorder.py @@ -2,15 +2,12 @@ import custom_speech_recognition as sr import pyaudiowpatch as pyaudio from datetime import datetime -RECORD_TIMEOUT = 3 -ENERGY_THRESHOLD = 1000 -DYNAMIC_ENERGY_THRESHOLD = False - class BaseRecorder: - def __init__(self, source): + def __init__(self, source, energy_threshold, dynamic_energy_threshold, record_timeout): self.recorder = sr.Recognizer() - self.recorder.energy_threshold = ENERGY_THRESHOLD - self.recorder.dynamic_energy_threshold = DYNAMIC_ENERGY_THRESHOLD + self.recorder.energy_threshold = energy_threshold + self.recorder.dynamic_energy_threshold = dynamic_energy_threshold + self.record_timeout = record_timeout self.stop = None if source is None: @@ -26,19 +23,19 @@ class BaseRecorder: def record_callback(_, audio:sr.AudioData) -> None: audio_queue.put((audio.get_raw_data(), datetime.now())) - self.stop = self.recorder.listen_in_background(self.source, record_callback, phrase_time_limit=RECORD_TIMEOUT) + self.stop = self.recorder.listen_in_background(self.source, record_callback, phrase_time_limit=self.record_timeout) class SelectedMicRecorder(BaseRecorder): - def __init__(self, device): + def __init__(self, device, energy_threshold, dynamic_energy_threshold, record_timeout): source=sr.Microphone( device_index=device['index'], sample_rate=int(device["defaultSampleRate"]), ) - super().__init__(source=source) + super().__init__(source=source, energy_threshold=energy_threshold, dynamic_energy_threshold=dynamic_energy_threshold, record_timeout=record_timeout) self.adjust_for_noise() class SelectedSpeakerRecorder(BaseRecorder): - def __init__(self, device): + def __init__(self, device, energy_threshold, dynamic_energy_threshold, record_timeout): source = sr.Microphone(speaker=True, device_index= device["index"], @@ -46,5 +43,5 @@ class SelectedSpeakerRecorder(BaseRecorder): chunk_size=pyaudio.get_sample_size(pyaudio.paInt16), channels=device["maxInputChannels"] ) - super().__init__(source=source) + super().__init__(source=source, energy_threshold=energy_threshold, dynamic_energy_threshold=dynamic_energy_threshold, record_timeout=record_timeout) self.adjust_for_noise() \ No newline at end of file diff --git a/window_config.py b/window_config.py index 87ddaa37..9b7cf946 100644 --- a/window_config.py +++ b/window_config.py @@ -240,43 +240,59 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): self.optionmenu_input_mic_voice_language.grid(row=1, column=1, columnspan=1 ,padx=5, pady=5, sticky="nsew") self.optionmenu_input_mic_voice_language._dropdown_menu.configure(font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY)) - ## checkbox input mic in dynamic - self.label_input_mic_is_dynamic = customtkinter.CTkLabel( + ## entry input mic energy threshold + self.label_input_mic_energy_threshold = customtkinter.CTkLabel( self.tabview_config.tab("Transcription"), - text="Input Mic IsDynamic:", + text="Input Mic Energy Threshold:", fg_color="transparent", font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) ) - self.label_input_mic_is_dynamic.grid(row=2, column=0, columnspan=1, padx=5, pady=5, sticky="nsw") - self.checkbox_input_mic_is_dynamic = customtkinter.CTkCheckBox( + self.label_input_mic_energy_threshold.grid(row=2, column=0, columnspan=1, padx=5, pady=5, sticky="nsw") + self.entry_input_mic_energy_threshold = customtkinter.CTkEntry( + self.tabview_config.tab("Transcription"), + textvariable=customtkinter.StringVar(value=self.parent.INPUT_MIC_ENERGY_THRESHOLD), + font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + ) + self.entry_input_mic_energy_threshold.grid(row=2, column=1, columnspan=1 ,padx=5, pady=10, sticky="nsew") + self.entry_input_mic_energy_threshold.bind("", self.entry_input_mic_energy_threshold_callback) + + ## checkbox input mic dynamic energy threshold + self.label_input_mic_dynamic_energy_threshold = customtkinter.CTkLabel( + self.tabview_config.tab("Transcription"), + text="Input Mic Dynamic Energy Threshold:", + fg_color="transparent", + font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_input_mic_dynamic_energy_threshold.grid(row=3, column=0, columnspan=1, padx=5, pady=5, sticky="nsw") + self.checkbox_input_mic_dynamic_energy_threshold = customtkinter.CTkCheckBox( self.tabview_config.tab("Transcription"), text="", onvalue=True, offvalue=False, - command=self.checkbox_input_mic_is_dynamic_callback, + command=self.checkbox_input_mic_dynamic_energy_threshold_callback, font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) ) - self.checkbox_input_mic_is_dynamic.grid(row=2, column=1, columnspan=1 ,padx=5, pady=5, sticky="nsew") - if self.parent.INPUT_MIC_IS_DYNAMIC is True: - self.checkbox_input_mic_is_dynamic.select() + self.checkbox_input_mic_dynamic_energy_threshold.grid(row=3, column=1, columnspan=1 ,padx=5, pady=5, sticky="nsew") + if self.parent.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD is True: + self.checkbox_input_mic_dynamic_energy_threshold.select() else: - self.checkbox_input_mic_is_dynamic.deselect() + self.checkbox_input_mic_dynamic_energy_threshold.deselect() - ## entry input mic threshold - self.label_input_mic_threshold = customtkinter.CTkLabel( + ## entry input mic record timeout + self.label_input_mic_record_timeout = customtkinter.CTkLabel( self.tabview_config.tab("Transcription"), - text="Input Mic Threshold:", + text="Input Mic Record Timeout:", fg_color="transparent", font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) ) - self.label_input_mic_threshold.grid(row=3, column=0, columnspan=1, padx=5, pady=5, sticky="nsw") - self.entry_input_mic_threshold = customtkinter.CTkEntry( + self.label_input_mic_record_timeout.grid(row=4, column=0, columnspan=1, padx=5, pady=5, sticky="nsw") + self.entry_input_mic_record_timeout = customtkinter.CTkEntry( self.tabview_config.tab("Transcription"), - textvariable=customtkinter.StringVar(value=self.parent.INPUT_MIC_THRESHOLD), + textvariable=customtkinter.StringVar(value=self.parent.INPUT_MIC_RECORD_TIMEOUT), font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) ) - self.entry_input_mic_threshold.grid(row=3, column=1, columnspan=1 ,padx=5, pady=10, sticky="nsew") - self.entry_input_mic_threshold.bind("", self.entry_input_mic_threshold_callback) + self.entry_input_mic_record_timeout.grid(row=4, column=1, columnspan=1 ,padx=5, pady=10, sticky="nsew") + self.entry_input_mic_record_timeout.bind("", self.entry_input_mic_record_timeout_callback) ## optionmenu input speaker device self.label_input_speaker_device = customtkinter.CTkLabel( @@ -285,7 +301,7 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): fg_color="transparent", font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) ) - self.label_input_speaker_device.grid(row=4, column=0, columnspan=1, padx=5, pady=5, sticky="nsw") + self.label_input_speaker_device.grid(row=5, column=0, columnspan=1, padx=5, pady=5, sticky="nsw") self.optionmenu_input_speaker_device = customtkinter.CTkOptionMenu( self.tabview_config.tab("Transcription"), values=[device["name"] for device in audio_utils.get_output_device_list()], @@ -293,7 +309,7 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): variable=customtkinter.StringVar(value=self.parent.CHOICE_SPEAKER_DEVICE), font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY), ) - self.optionmenu_input_speaker_device.grid(row=4, column=1, columnspan=1 ,padx=5, pady=5, sticky="nsew") + self.optionmenu_input_speaker_device.grid(row=5, column=1, columnspan=1 ,padx=5, pady=5, sticky="nsew") self.optionmenu_input_speaker_device._dropdown_menu.configure(font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY)) ## optionmenu input speaker voice language @@ -303,7 +319,7 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): fg_color="transparent", font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) ) - self.label_input_speaker_voice_language.grid(row=5, column=0, columnspan=1, padx=5, pady=5, sticky="nsw") + self.label_input_speaker_voice_language.grid(row=6, column=0, columnspan=1, padx=5, pady=5, sticky="nsw") self.optionmenu_input_speaker_voice_language = customtkinter.CTkOptionMenu( self.tabview_config.tab("Transcription"), values=list(languages.transcription_lang.keys()), @@ -311,24 +327,62 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): variable=customtkinter.StringVar(value=self.parent.INPUT_SPEAKER_VOICE_LANGUAGE), font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY), ) - self.optionmenu_input_speaker_voice_language.grid(row=5, column=1, columnspan=1 ,padx=5, pady=5, sticky="nsew") + self.optionmenu_input_speaker_voice_language.grid(row=6, column=1, columnspan=1 ,padx=5, pady=5, sticky="nsew") self.optionmenu_input_speaker_voice_language._dropdown_menu.configure(font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY)) - ## entry input speaker interval - self.label_input_speaker_interval = customtkinter.CTkLabel( + ## entry input speaker energy threshold + self.label_input_speaker_energy_threshold = customtkinter.CTkLabel( self.tabview_config.tab("Transcription"), - text="Input Speaker Interval:", + text="Input Speaker Energy Threshold:", fg_color="transparent", font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) ) - self.label_input_speaker_interval.grid(row=6, column=0, columnspan=1, padx=5, pady=5, sticky="nsw") - self.entry_input_speaker_interval = customtkinter.CTkEntry( + self.label_input_speaker_energy_threshold.grid(row=7, column=0, columnspan=1, padx=5, pady=5, sticky="nsw") + self.entry_input_speaker_energy_threshold = customtkinter.CTkEntry( self.tabview_config.tab("Transcription"), - textvariable=customtkinter.StringVar(value=self.parent.INPUT_SPEAKER_INTERVAL), + textvariable=customtkinter.StringVar(value=self.parent.INPUT_SPEAKER_ENERGY_THRESHOLD), font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) ) - self.entry_input_speaker_interval.grid(row=6, column=1, columnspan=1 ,padx=5, pady=5, sticky="nsew") - self.entry_input_speaker_interval.bind("", self.entry_input_speaker_interval_callback) + self.entry_input_speaker_energy_threshold.grid(row=7, column=1, columnspan=1 ,padx=5, pady=10, sticky="nsew") + self.entry_input_speaker_energy_threshold.bind("", self.entry_input_speaker_energy_threshold_callback) + + ## checkbox input speaker dynamic energy threshold + self.label_input_speaker_dynamic_energy_threshold = customtkinter.CTkLabel( + self.tabview_config.tab("Transcription"), + text="Input Speaker Dynamic Energy Threshold:", + fg_color="transparent", + font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_input_speaker_dynamic_energy_threshold.grid(row=8, column=0, columnspan=1, padx=5, pady=5, sticky="nsw") + self.checkbox_input_speaker_dynamic_energy_threshold = customtkinter.CTkCheckBox( + self.tabview_config.tab("Transcription"), + text="", + onvalue=True, + offvalue=False, + command=self.checkbox_input_speaker_dynamic_energy_threshold_callback, + font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + ) + self.checkbox_input_speaker_dynamic_energy_threshold.grid(row=8, column=1, columnspan=1 ,padx=5, pady=5, sticky="nsew") + if self.parent.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD is True: + self.checkbox_input_speaker_dynamic_energy_threshold.select() + else: + self.checkbox_input_speaker_dynamic_energy_threshold.deselect() + + ## entry input speaker record timeout + self.label_input_speaker_record_timeout = customtkinter.CTkLabel( + self.tabview_config.tab("Transcription"), + text="Input Speaker Record Timeout:", + fg_color="transparent", + font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_input_speaker_record_timeout.grid(row=9, column=0, columnspan=1, padx=5, pady=5, sticky="nsw") + self.entry_input_speaker_record_timeout = customtkinter.CTkEntry( + self.tabview_config.tab("Transcription"), + textvariable=customtkinter.StringVar(value=self.parent.INPUT_SPEAKER_RECORD_TIMEOUT), + font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + ) + self.entry_input_speaker_record_timeout.grid(row=9, column=1, columnspan=1 ,padx=5, pady=10, sticky="nsew") + self.entry_input_speaker_record_timeout.bind("", self.entry_input_speaker_record_timeout_callback) # tab Parameter ## entry ip address @@ -451,17 +505,22 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): self.label_input_mic_voice_language.configure(font=customtkinter.CTkFont(family=choice)) self.optionmenu_input_mic_voice_language.configure(font=customtkinter.CTkFont(family=choice)) self.optionmenu_input_mic_voice_language._dropdown_menu.configure(font=customtkinter.CTkFont(family=choice)) - self.label_input_mic_is_dynamic.configure(font=customtkinter.CTkFont(family=choice)) - self.label_input_mic_threshold.configure(font=customtkinter.CTkFont(family=choice)) - self.entry_input_mic_threshold.configure(font=customtkinter.CTkFont(family=choice)) + self.label_input_mic_energy_threshold.configure(font=customtkinter.CTkFont(family=choice)) + self.entry_input_mic_energy_threshold.configure(font=customtkinter.CTkFont(family=choice)) + self.label_input_mic_dynamic_energy_threshold.configure(font=customtkinter.CTkFont(family=choice)) + self.label_input_mic_record_timeout.configure(font=customtkinter.CTkFont(family=choice)) + self.entry_input_mic_record_timeout.configure(font=customtkinter.CTkFont(family=choice)) self.label_input_speaker_device.configure(font=customtkinter.CTkFont(family=choice)) self.optionmenu_input_speaker_device.configure(font=customtkinter.CTkFont(family=choice)) self.optionmenu_input_speaker_device._dropdown_menu.configure(font=customtkinter.CTkFont(family=choice)) self.label_input_speaker_voice_language.configure(font=customtkinter.CTkFont(family=choice)) self.optionmenu_input_speaker_voice_language.configure(font=customtkinter.CTkFont(family=choice)) self.optionmenu_input_speaker_voice_language._dropdown_menu.configure(font=customtkinter.CTkFont(family=choice)) - self.label_input_speaker_interval.configure(font=customtkinter.CTkFont(family=choice)) - self.entry_input_speaker_interval.configure(font=customtkinter.CTkFont(family=choice)) + self.label_input_speaker_energy_threshold.configure(font=customtkinter.CTkFont(family=choice)) + self.entry_input_speaker_energy_threshold.configure(font=customtkinter.CTkFont(family=choice)) + self.label_input_speaker_dynamic_energy_threshold.configure(font=customtkinter.CTkFont(family=choice)) + self.label_input_speaker_record_timeout.configure(font=customtkinter.CTkFont(family=choice)) + self.entry_input_speaker_record_timeout.configure(font=customtkinter.CTkFont(family=choice)) # tab Parameter self.label_ip_address.configure(font=customtkinter.CTkFont(family=choice)) @@ -547,14 +606,18 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): self.parent.INPUT_MIC_VOICE_LANGUAGE = choice utils.save_json(self.parent.PATH_CONFIG, "INPUT_MIC_VOICE_LANGUAGE", self.parent.INPUT_MIC_VOICE_LANGUAGE) - def checkbox_input_mic_is_dynamic_callback(self): - value = self.checkbox_input_mic_is_dynamic.get() - self.parent.INPUT_MIC_IS_DYNAMIC = value - utils.save_json(self.parent.PATH_CONFIG, "INPUT_MIC_IS_DYNAMIC", self.parent.INPUT_MIC_IS_DYNAMIC) + def entry_input_mic_energy_threshold_callback(self, event): + self.parent.INPUT_MIC_ENERGY_THRESHOLD = int(self.entry_input_mic_energy_threshold.get()) + utils.save_json(self.parent.PATH_CONFIG, "INPUT_MIC_ENERGY_THRESHOLD", self.parent.INPUT_MIC_ENERGY_THRESHOLD) - def entry_input_mic_threshold_callback(self, event): - self.parent.INPUT_MIC_THRESHOLD = int(self.entry_input_mic_threshold.get()) - utils.save_json(self.parent.PATH_CONFIG, "INPUT_MIC_THRESHOLD", self.parent.INPUT_MIC_THRESHOLD) + def checkbox_input_mic_dynamic_energy_threshold_callback(self): + value = self.checkbox_input_mic_dynamic_energy_threshold.get() + self.parent.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD = value + utils.save_json(self.parent.PATH_CONFIG, "INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD", self.parent.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD) + + def entry_input_mic_record_timeout_callback(self, event): + self.parent.INPUT_MIC_RECORD_TIMEOUT = int(self.entry_input_mic_record_timeout.get()) + utils.save_json(self.parent.PATH_CONFIG, "INPUT_MIC_RECORD_TIMEOUT", self.parent.INPUT_MIC_RECORD_TIMEOUT) def optionmenu_input_speaker_device_callback(self, choice): self.parent.CHOICE_SPEAKER_DEVICE = choice @@ -564,9 +627,18 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): self.parent.INPUT_SPEAKER_VOICE_LANGUAGE = choice utils.save_json(self.parent.PATH_CONFIG, "INPUT_SPEAKER_VOICE_LANGUAGE", self.parent.INPUT_SPEAKER_VOICE_LANGUAGE) - def entry_input_speaker_interval_callback(self, event): - self.parent.INPUT_SPEAKER_INTERVAL = int(self.entry_input_speaker_interval.get()) - utils.save_json(self.parent.PATH_CONFIG, "INPUT_SPEAKER_INTERVAL", self.parent.INPUT_SPEAKER_INTERVAL) + def entry_input_speaker_energy_threshold_callback(self, event): + self.parent.INPUT_SPEAKER_ENERGY_THRESHOLD = int(self.entry_input_speaker_energy_threshold.get()) + utils.save_json(self.parent.PATH_CONFIG, "INPUT_SPEAKER_ENERGY_THRESHOLD", self.parent.INPUT_SPEAKER_ENERGY_THRESHOLD) + + def checkbox_input_speaker_dynamic_energy_threshold_callback(self): + value = self.checkbox_input_speaker_dynamic_energy_threshold.get() + self.parent.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD = value + utils.save_json(self.parent.PATH_CONFIG, "INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD", self.parent.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD) + + def entry_input_speaker_record_timeout_callback(self, event): + self.parent.INPUT_SPEAKER_RECORD_TIMEOUT = int(self.entry_input_speaker_record_timeout.get()) + utils.save_json(self.parent.PATH_CONFIG, "INPUT_SPEAKER_RECORD_TIMEOUT", self.parent.INPUT_SPEAKER_RECORD_TIMEOUT) def entry_ip_address_callback(self, event): self.parent.OSC_IP_ADDRESS = self.entry_ip_address.get()