From 6627b5e7e6b3800cbacf92de09928d9467b78ee3 Mon Sep 17 00:00:00 2001 From: misygauziya Date: Wed, 26 Jul 2023 06:48:56 +0900 Subject: [PATCH 1/6] =?UTF-8?q?[Update]=20config=20window=E3=82=92?= =?UTF-8?q?=E3=82=B0=E3=83=A9=E3=83=83=E3=83=97=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VRCT.py | 9 +++++++++ window_config.py | 11 ++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/VRCT.py b/VRCT.py index 1ed48de2..bcd8fcf1 100644 --- a/VRCT.py +++ b/VRCT.py @@ -423,11 +423,20 @@ class App(CTk): self.checkbox_translation.configure(state="disabled") self.checkbox_transcription_send.configure(state="disabled") self.checkbox_transcription_receive.configure(state="disabled") + self.checkbox_foreground.configure(state="disabled") + self.tabview_logs.configure(state="disabled") + self.textbox_message_log.configure(state="disabled") + self.textbox_message_send_log.configure(state="disabled") + self.textbox_message_receive_log.configure(state="disabled") + self.textbox_message_system_log.configure(state="disabled") + self.entry_message_box.configure(state="disabled") self.button_config.configure(state="disabled", fg_color=["gray92", "gray14"]) + self.button_information.configure(state="disabled", fg_color=["gray92", "gray14"]) self.config_window.deiconify() self.config_window.focus_set() self.config_window.focus() + self.config_window.grab_set() def button_information_callback(self): if self.information_window is None or not self.information_window.winfo_exists(): diff --git a/window_config.py b/window_config.py index 7c8b2173..c5f0da9a 100644 --- a/window_config.py +++ b/window_config.py @@ -506,8 +506,17 @@ class ToplevelWindowConfig(CTkToplevel): self.parent.checkbox_translation.configure(state="normal") self.parent.checkbox_transcription_send.configure(state="normal") self.parent.checkbox_transcription_receive.configure(state="normal") + self.parent.checkbox_foreground.configure(state="normal") + self.parent.tabview_logs.configure(state="normal") + self.parent.textbox_message_log.configure(state="normal") + self.parent.textbox_message_send_log.configure(state="normal") + self.parent.textbox_message_receive_log.configure(state="normal") + self.parent.textbox_message_system_log.configure(state="normal") + self.parent.entry_message_box.configure(state="normal") self.parent.button_config.configure(state="normal", fg_color=["#3B8ED0", "#1F6AA5"]) - self.parent.config_window.withdraw() + self.parent.button_information.configure(state="normal", fg_color=["#3B8ED0", "#1F6AA5"]) + self.withdraw() + self.grab_release() def entry_message_format_callback(self, event): value = self.entry_message_format.get() From 9be6e3de41a112bda6760157d85631e4bf1b388d Mon Sep 17 00:00:00 2001 From: misygauziya Date: Wed, 26 Jul 2023 11:23:44 +0900 Subject: [PATCH 2/6] =?UTF-8?q?[Update]=20main=20window=20=E3=81=AEcheckbo?= =?UTF-8?q?x=E3=82=92ON=E3=81=AE=E7=8A=B6=E6=85=8B=E3=81=A7=E3=82=82config?= =?UTF-8?q?=E3=82=92=E9=96=8B=E3=81=91=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 --- VRCT.py | 91 +++++++++++++++++++++++++++++++++--------------- window_config.py | 3 +- 2 files changed, 65 insertions(+), 29 deletions(-) diff --git a/VRCT.py b/VRCT.py index bcd8fcf1..bb1fd21e 100644 --- a/VRCT.py +++ b/VRCT.py @@ -1,3 +1,4 @@ +from time import sleep from os import path as os_path from json import load as json_load from json import dump as json_dump @@ -33,8 +34,8 @@ class App(CTk): ## main window self.ENABLE_TRANSLATION = False - self.ENABLE_TRANSCRIPTION_SEND = False - self.ENABLE_TRANSCRIPTION_RECEIVE = False + # self.ENABLE_TRANSCRIPTION_SEND = False + # self.ENABLE_TRANSCRIPTION_RECEIVE = False self.ENABLE_FOREGROUND = False ## UI self.TRANSPARENCY = 100 @@ -420,6 +421,8 @@ class App(CTk): send_test_action() def button_config_callback(self): + self.foreground_stop() + self.transcription_stop() self.checkbox_translation.configure(state="disabled") self.checkbox_transcription_send.configure(state="disabled") self.checkbox_transcription_receive.configure(state="disabled") @@ -432,7 +435,6 @@ class App(CTk): self.entry_message_box.configure(state="disabled") self.button_config.configure(state="disabled", fg_color=["gray92", "gray14"]) self.button_information.configure(state="disabled", fg_color=["gray92", "gray14"]) - self.config_window.deiconify() self.config_window.focus_set() self.config_window.focus() @@ -445,18 +447,13 @@ class App(CTk): def checkbox_translation_callback(self): self.ENABLE_TRANSLATION = self.checkbox_translation.get() - if self.ENABLE_TRANSLATION: - self.button_config.configure(state="disabled", fg_color=["gray92", "gray14"]) + if self.ENABLE_TRANSLATION is True: print_textbox(self.textbox_message_log, "Start translation", "INFO") print_textbox(self.textbox_message_system_log, "Start translation", "INFO") else: - if ((self.checkbox_translation.get() is False) and - (self.checkbox_transcription_send.get() is False) and - (self.checkbox_transcription_receive.get() is False)): - self.button_config.configure(state="normal", fg_color=["#3B8ED0", "#1F6AA5"]) print_textbox(self.textbox_message_log, "Stop translation", "INFO") print_textbox(self.textbox_message_system_log, "Stop translation", "INFO") - save_json(self.PATH_CONFIG, "ENABLE_TRANSLATION", self.ENABLE_TRANSLATION) + def transcription_send_start(self): self.mic_audio_queue = Queue() @@ -529,20 +526,24 @@ class App(CTk): print_textbox(self.textbox_message_log, "Stop voice2chatbox", "INFO") print_textbox(self.textbox_message_system_log, "Stop voice2chatbox", "INFO") - if ((self.checkbox_translation.get() is False) and - (self.checkbox_transcription_send.get() is False) and - (self.checkbox_transcription_receive.get() is False)): - self.button_config.configure(state="normal", fg_color=["#3B8ED0", "#1F6AA5"]) self.checkbox_transcription_send.configure(state="normal") self.checkbox_transcription_receive.configure(state="normal") + def transcription_send_stop_for_config(self): + if isinstance(self.mic_print_transcript, thread_fnc): + self.mic_print_transcript.stop() + if self.mic_audio_recorder.stop != None: + self.mic_audio_recorder.stop() + self.mic_audio_recorder.stop = None + + print_textbox(self.textbox_message_log, "Stop voice2chatbox", "INFO") + print_textbox(self.textbox_message_system_log, "Stop voice2chatbox", "INFO") + def checkbox_transcription_send_callback(self): self.checkbox_transcription_send.configure(state="disabled") self.checkbox_transcription_receive.configure(state="disabled") - self.button_config.configure(state="disabled", fg_color=["gray92", "gray14"]) self.update() - self.ENABLE_TRANSCRIPTION_SEND = self.checkbox_transcription_send.get() - if self.ENABLE_TRANSCRIPTION_SEND is True: + if self.checkbox_transcription_send.get() is True: th_transcription_send_start = Thread(target=self.transcription_send_start) th_transcription_send_start.daemon = True th_transcription_send_start.start() @@ -550,7 +551,6 @@ class App(CTk): th_transcription_send_stop = Thread(target=self.transcription_send_stop) th_transcription_send_stop.daemon = True th_transcription_send_stop.start() - save_json(self.PATH_CONFIG, "ENABLE_TRANSCRIPTION_SEND", self.ENABLE_TRANSCRIPTION_SEND) def transcription_receive_start(self): self.spk_audio_queue = Queue() @@ -578,7 +578,7 @@ class App(CTk): if self.checkbox_translation.get() is False: voice_message = f"{message}" elif self.translator.translator_status[self.CHOICE_TRANSLATOR] is False: - print_textbox(self.textbox_message_log, "Auth Key or language setting is incorrect", "ERROR") + print_textbox(self.textbox_message_log, "Auth Key or language setting is incorrect", "ERROR") print_textbox(self.textbox_message_system_log, "Auth Key or language setting is incorrect", "ERROR") voice_message = f"{message}" else: @@ -616,20 +616,24 @@ class App(CTk): print_textbox(self.textbox_message_log, "Stop speaker2log", "INFO") print_textbox(self.textbox_message_system_log, "Stop speaker2log", "INFO") - if ((self.checkbox_translation.get() is False) and - (self.checkbox_transcription_send.get() is False) and - (self.checkbox_transcription_receive.get() is False)): - self.button_config.configure(state="normal", fg_color=["#3B8ED0", "#1F6AA5"]) self.checkbox_transcription_send.configure(state="normal") self.checkbox_transcription_receive.configure(state="normal") + def transcription_receive_stop_for_config(self): + if isinstance(self.spk_print_transcript, thread_fnc): + self.spk_print_transcript.stop() + if self.spk_audio_recorder.stop != None: + self.spk_audio_recorder.stop() + self.spk_audio_recorder.stop = None + + print_textbox(self.textbox_message_log, "Stop speaker2log", "INFO") + print_textbox(self.textbox_message_system_log, "Stop speaker2log", "INFO") + def checkbox_transcription_receive_callback(self): self.checkbox_transcription_send.configure(state="disabled") self.checkbox_transcription_receive.configure(state="disabled") - self.button_config.configure(state="disabled", fg_color=["gray92", "gray14"]) self.update() - self.ENABLE_TRANSCRIPTION_RECEIVE = self.checkbox_transcription_receive.get() - if self.ENABLE_TRANSCRIPTION_RECEIVE is True: + if self.checkbox_transcription_receive.get() is True: th_transcription_receive_start = Thread(target=self.transcription_receive_start) th_transcription_receive_start.daemon = True th_transcription_receive_start.start() @@ -638,7 +642,26 @@ class App(CTk): th_transcription_receive_stop.daemon = True th_transcription_receive_stop.start() - save_json(self.PATH_CONFIG, "ENABLE_TRANSCRIPTION_RECEIVE", self.ENABLE_TRANSCRIPTION_RECEIVE) + def transcription_start(self): + if self.checkbox_transcription_send.get() is True: + th_transcription_send_start = Thread(target=self.transcription_send_start) + th_transcription_send_start.daemon = True + th_transcription_send_start.start() + sleep(2) + if self.checkbox_transcription_receive.get() is True: + th_transcription_receive_start = Thread(target=self.transcription_receive_start) + th_transcription_receive_start.daemon = True + th_transcription_receive_start.start() + + def transcription_stop(self): + if self.checkbox_transcription_send.get() is True: + th_transcription_send_stop = Thread(target=self.transcription_send_stop_for_config) + th_transcription_send_stop.daemon = True + th_transcription_send_stop.start() + if self.checkbox_transcription_receive.get() is True: + th_transcription_receive_stop = Thread(target=self.transcription_receive_stop_for_config) + th_transcription_receive_stop.daemon = True + th_transcription_receive_stop.start() def checkbox_foreground_callback(self): self.ENABLE_FOREGROUND = self.checkbox_foreground.get() @@ -650,7 +673,19 @@ class App(CTk): self.attributes("-topmost", False) print_textbox(self.textbox_message_log, "Stop foreground", "INFO") print_textbox(self.textbox_message_system_log, "Stop foreground", "INFO") - save_json(self.PATH_CONFIG, "ENABLE_FOREGROUND", self.ENABLE_FOREGROUND) + + def foreground_start(self): + self.ENABLE_FOREGROUND = self.checkbox_foreground.get() + if self.ENABLE_FOREGROUND: + self.attributes("-topmost", True) + print_textbox(self.textbox_message_log, "Start foreground", "INFO") + print_textbox(self.textbox_message_system_log, "Start foreground", "INFO") + + def foreground_stop(self): + self.ENABLE_FOREGROUND = False + self.attributes("-topmost", False) + print_textbox(self.textbox_message_log, "Stop foreground", "INFO") + print_textbox(self.textbox_message_system_log, "Stop foreground", "INFO") def entry_message_box_press_key_enter(self, event): # send OSC typing diff --git a/window_config.py b/window_config.py index c5f0da9a..cf92a143 100644 --- a/window_config.py +++ b/window_config.py @@ -502,7 +502,8 @@ class ToplevelWindowConfig(CTkToplevel): self.checkbox_input_speaker_threshold_check.deselect() self.checkbox_input_mic_threshold_check_callback() self.checkbox_input_speaker_threshold_check_callback() - + self.parent.transcription_start() + self.parent.foreground_start() self.parent.checkbox_translation.configure(state="normal") self.parent.checkbox_transcription_send.configure(state="normal") self.parent.checkbox_transcription_receive.configure(state="normal") From 470e1cbabe4b65eaba9d1ac975e1cd37f36930b5 Mon Sep 17 00:00:00 2001 From: misygauziya Date: Wed, 26 Jul 2023 12:54:45 +0900 Subject: [PATCH 3/6] =?UTF-8?q?[Update]=20information=20window=E3=82=92?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E3=81=97=E3=81=9F=E6=99=82=E3=81=AB=E6=9C=80?= =?UTF-8?q?=E5=89=8D=E9=9D=A2=E3=81=AB=E3=81=AA=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VRCT.py | 15 ++++++++------- window_information.py | 7 ++++++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/VRCT.py b/VRCT.py index bb1fd21e..d027e81b 100644 --- a/VRCT.py +++ b/VRCT.py @@ -411,6 +411,7 @@ class App(CTk): self.protocol("WM_DELETE_WINDOW", self.delete_window) self.config_window = ToplevelWindowConfig(self) + self.information_window = ToplevelWindowInformation(self) # start receive osc th_receive_osc_parameters = Thread(target=receive_osc_parameters, args=(self.check_osc_receive,)) @@ -441,8 +442,8 @@ class App(CTk): self.config_window.grab_set() def button_information_callback(self): - if self.information_window is None or not self.information_window.winfo_exists(): - self.information_window = ToplevelWindowInformation(self) + self.information_window.deiconify() + self.information_window.focus_set() self.information_window.focus() def checkbox_translation_callback(self): @@ -454,7 +455,6 @@ class App(CTk): print_textbox(self.textbox_message_log, "Stop translation", "INFO") print_textbox(self.textbox_message_system_log, "Stop translation", "INFO") - def transcription_send_start(self): self.mic_audio_queue = Queue() mic_device = [device for device in get_input_device_list()[self.CHOICE_MIC_HOST] if device["name"] == self.CHOICE_MIC_DEVICE][0] @@ -682,10 +682,11 @@ class App(CTk): print_textbox(self.textbox_message_system_log, "Start foreground", "INFO") def foreground_stop(self): - self.ENABLE_FOREGROUND = False - self.attributes("-topmost", False) - print_textbox(self.textbox_message_log, "Stop foreground", "INFO") - print_textbox(self.textbox_message_system_log, "Stop foreground", "INFO") + if self.ENABLE_FOREGROUND: + self.attributes("-topmost", False) + print_textbox(self.textbox_message_log, "Stop foreground", "INFO") + print_textbox(self.textbox_message_system_log, "Stop foreground", "INFO") + self.ENABLE_FOREGROUND = False def entry_message_box_press_key_enter(self, event): # send OSC typing diff --git a/window_information.py b/window_information.py index aa5d05a6..cc0d3b7f 100644 --- a/window_information.py +++ b/window_information.py @@ -4,6 +4,7 @@ from customtkinter import CTkToplevel, CTkTextbox, CTkFont class ToplevelWindowInformation(CTkToplevel): def __init__(self, parent, *args, **kwargs): super().__init__(parent, *args, **kwargs) + self.withdraw() self.parent = parent self.grid_columnconfigure(0, weight=1) self.grid_rowconfigure(0, weight=1) @@ -146,4 +147,8 @@ https://twitter.com/misya_ai """ self.textbox_information.insert("end", textbox_information_message) - self.textbox_information.configure(state='disabled') \ No newline at end of file + self.textbox_information.configure(state='disabled') + self.protocol("WM_DELETE_WINDOW", self.delete_window) + + def delete_window(self): + self.withdraw() \ No newline at end of file From 546eb7e1fc08cddfc2e9689edb2a7c1626bf0b6d Mon Sep 17 00:00:00 2001 From: misygauziya Date: Thu, 27 Jul 2023 15:09:03 +0900 Subject: [PATCH 4/6] =?UTF-8?q?[bugfix]=20checkbox=E5=8B=95=E4=BD=9C?= =?UTF-8?q?=E4=B8=AD=E3=81=ABconfig=20window=E3=81=8C=E9=96=8B=E3=81=91?= =?UTF-8?q?=E3=82=8B=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 --- VRCT.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/VRCT.py b/VRCT.py index d027e81b..3dae5308 100644 --- a/VRCT.py +++ b/VRCT.py @@ -516,6 +516,7 @@ class App(CTk): print_textbox(self.textbox_message_system_log, "Start voice2chatbox", "INFO") self.checkbox_transcription_send.configure(state="normal") self.checkbox_transcription_receive.configure(state="normal") + self.button_config.configure(state="normal", fg_color=["#3B8ED0", "#1F6AA5"]) def transcription_send_stop(self): if isinstance(self.mic_print_transcript, thread_fnc): @@ -528,6 +529,7 @@ class App(CTk): print_textbox(self.textbox_message_system_log, "Stop voice2chatbox", "INFO") self.checkbox_transcription_send.configure(state="normal") self.checkbox_transcription_receive.configure(state="normal") + self.button_config.configure(state="normal", fg_color=["#3B8ED0", "#1F6AA5"]) def transcription_send_stop_for_config(self): if isinstance(self.mic_print_transcript, thread_fnc): @@ -542,7 +544,7 @@ class App(CTk): def checkbox_transcription_send_callback(self): self.checkbox_transcription_send.configure(state="disabled") self.checkbox_transcription_receive.configure(state="disabled") - self.update() + self.button_config.configure(state="disabled", fg_color=["gray92", "gray14"]) if self.checkbox_transcription_send.get() is True: th_transcription_send_start = Thread(target=self.transcription_send_start) th_transcription_send_start.daemon = True @@ -618,6 +620,7 @@ class App(CTk): print_textbox(self.textbox_message_system_log, "Stop speaker2log", "INFO") self.checkbox_transcription_send.configure(state="normal") self.checkbox_transcription_receive.configure(state="normal") + self.button_config.configure(state="normal", fg_color=["#3B8ED0", "#1F6AA5"]) def transcription_receive_stop_for_config(self): if isinstance(self.spk_print_transcript, thread_fnc): @@ -632,7 +635,7 @@ class App(CTk): def checkbox_transcription_receive_callback(self): self.checkbox_transcription_send.configure(state="disabled") self.checkbox_transcription_receive.configure(state="disabled") - self.update() + self.button_config.configure(state="disabled", fg_color=["gray92", "gray14"]) if self.checkbox_transcription_receive.get() is True: th_transcription_receive_start = Thread(target=self.transcription_receive_start) th_transcription_receive_start.daemon = True From a1fcf0702b2c062d7f989e432fe6c74aa2b2b061 Mon Sep 17 00:00:00 2001 From: misygauziya Date: Thu, 27 Jul 2023 15:09:58 +0900 Subject: [PATCH 5/6] =?UTF-8?q?[bugfix]=20checkbox=E3=82=92=E6=8A=BC?= =?UTF-8?q?=E3=81=97=E3=81=9F=E6=99=82=E3=81=ABconfig=20button=E3=81=AE?= =?UTF-8?q?=E3=82=B5=E3=82=A4=E3=82=BA=E3=81=8C=E5=A4=89=E5=8C=96=E3=81=99?= =?UTF-8?q?=E3=82=8B=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 --- VRCT.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/VRCT.py b/VRCT.py index 3dae5308..b4f2a18a 100644 --- a/VRCT.py +++ b/VRCT.py @@ -325,8 +325,8 @@ class App(CTk): # add button information self.button_information = CTkButton( self.sidebar_frame, - text="", - width=25, + text=None, + width=36, command=self.button_information_callback, image=CTkImage(Image_open(os_path.join(os_path.dirname(__file__), "img", "info-icon-white.png"))) ) @@ -336,8 +336,8 @@ class App(CTk): # add button config self.button_config = CTkButton( self.sidebar_frame, - text="", - width=25, + text=None, + width=36, command=self.button_config_callback, image=CTkImage(Image_open(os_path.join(os_path.dirname(__file__), "img", "config-icon-white.png"))) ) From 3b0ee5325df7a0f6315bf4f0d39eea873c763194 Mon Sep 17 00:00:00 2001 From: misygauziya Date: Thu, 27 Jul 2023 15:11:08 +0900 Subject: [PATCH 6/6] =?UTF-8?q?[Update]=20=E4=B8=8D=E8=A6=81=E3=81=AA?= =?UTF-8?q?=E3=82=B3=E3=83=BC=E3=83=89=E3=82=92=E5=89=8A=E9=99=A4/typo?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VRCT.py | 102 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/VRCT.py b/VRCT.py index b4f2a18a..5c15803f 100644 --- a/VRCT.py +++ b/VRCT.py @@ -331,7 +331,6 @@ class App(CTk): image=CTkImage(Image_open(os_path.join(os_path.dirname(__file__), "img", "info-icon-white.png"))) ) self.button_information.grid(row=5, column=0, padx=(10, 5), pady=(5, 5), sticky="wse") - self.information_window = None # add button config self.button_config = CTkButton( @@ -555,59 +554,60 @@ class App(CTk): th_transcription_send_stop.start() def transcription_receive_start(self): - self.spk_audio_queue = Queue() - spk_device = [device for device in get_output_device_list() if device["name"] == self.CHOICE_SPEAKER_DEVICE][0] - self.spk_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 = AudioTranscriber( - speaker=True, - source=self.spk_audio_recorder.source, - language=transcription_lang[self.INPUT_SPEAKER_VOICE_LANGUAGE], - phrase_timeout=self.INPUT_SPEAKER_PHRASE_TIMEOUT, - max_phrases=self.INPUT_SPEAKER_MAX_PHRASES, - ) + self.spk_audio_queue = Queue() + spk_device = [device for device in get_output_device_list() if device["name"] == self.CHOICE_SPEAKER_DEVICE][0] + self.spk_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 = AudioTranscriber( + speaker=True, + source=self.spk_audio_recorder.source, + language=transcription_lang[self.INPUT_SPEAKER_VOICE_LANGUAGE], + phrase_timeout=self.INPUT_SPEAKER_PHRASE_TIMEOUT, + max_phrases=self.INPUT_SPEAKER_MAX_PHRASES, + ) - def spk_transcript_to_textbox(): - self.spk_transcriber.transcribe_audio_queue(self.spk_audio_queue) - message = self.spk_transcriber.get_transcript() - if len(message) > 0: - # translate - if self.checkbox_translation.get() is False: - voice_message = f"{message}" - elif self.translator.translator_status[self.CHOICE_TRANSLATOR] is False: - print_textbox(self.textbox_message_log, "Auth Key or language setting is incorrect", "ERROR") - print_textbox(self.textbox_message_system_log, "Auth Key or language setting is incorrect", "ERROR") - voice_message = f"{message}" - else: - result = self.translator.translate( - translator_name=self.CHOICE_TRANSLATOR, - source_language=self.OUTPUT_SOURCE_LANG, - target_language=self.OUTPUT_TARGET_LANG, - message=message - ) - voice_message = self.MESSAGE_FORMAT.replace("[message]", message).replace("[translation]", result) - # send OSC message - # send_message(voice_message, self.OSC_IP_ADDRESS, self.OSC_PORT) + def spk_transcript_to_textbox(): + self.spk_transcriber.transcribe_audio_queue(self.spk_audio_queue) + message = self.spk_transcriber.get_transcript() + if len(message) > 0: + # translate + if self.checkbox_translation.get() is False: + voice_message = f"{message}" + elif self.translator.translator_status[self.CHOICE_TRANSLATOR] is False: + print_textbox(self.textbox_message_log, "Auth Key or language setting is incorrect", "ERROR") + print_textbox(self.textbox_message_system_log, "Auth Key or language setting is incorrect", "ERROR") + voice_message = f"{message}" + else: + result = self.translator.translate( + translator_name=self.CHOICE_TRANSLATOR, + source_language=self.OUTPUT_SOURCE_LANG, + target_language=self.OUTPUT_TARGET_LANG, + message=message + ) + voice_message = self.MESSAGE_FORMAT.replace("[message]", message).replace("[translation]", result) + # send OSC message + # send_message(voice_message, self.OSC_IP_ADDRESS, self.OSC_PORT) - if self.checkbox_transcription_receive.get() is True: - # update textbox message receive log - print_textbox(self.textbox_message_log, f"{voice_message}", "RECEIVE") - print_textbox(self.textbox_message_receive_log, f"{voice_message}", "RECEIVE") - if self.ENABLE_NOTICE_XSOVERLAY is True: - notification_xsoverlay_for_vrct(content=f"{voice_message}") + if self.checkbox_transcription_receive.get() is True: + # update textbox message receive log + print_textbox(self.textbox_message_log, f"{voice_message}", "RECEIVE") + print_textbox(self.textbox_message_receive_log, f"{voice_message}", "RECEIVE") + if self.ENABLE_NOTICE_XSOVERLAY is True: + notification_xsoverlay_for_vrct(content=f"{voice_message}") - self.spk_print_transcript = thread_fnc(spk_transcript_to_textbox) - self.spk_print_transcript.daemon = True - self.spk_print_transcript.start() - print_textbox(self.textbox_message_log, "Start speaker2log", "INFO") - print_textbox(self.textbox_message_system_log, "Start speaker2log", "INFO") - self.checkbox_transcription_send.configure(state="normal") - self.checkbox_transcription_receive.configure(state="normal") + self.spk_print_transcript = thread_fnc(spk_transcript_to_textbox) + self.spk_print_transcript.daemon = True + self.spk_print_transcript.start() + print_textbox(self.textbox_message_log, "Start speaker2log", "INFO") + print_textbox(self.textbox_message_system_log, "Start speaker2log", "INFO") + self.checkbox_transcription_send.configure(state="normal") + self.checkbox_transcription_receive.configure(state="normal") + self.button_config.configure(state="normal", fg_color=["#3B8ED0", "#1F6AA5"]) def transcription_receive_stop(self): if isinstance(self.spk_print_transcript, thread_fnc):