From 829e1de2b37e303c12ae991106e14b6f3d72f310 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Wed, 12 Jul 2023 10:32:37 +0900 Subject: [PATCH] =?UTF-8?q?UI=E3=81=AE=E5=A4=9A=E8=A8=80=E8=AA=9E=E5=8C=96?= =?UTF-8?q?=EF=BC=88=E6=97=A5=E6=9C=AC=E8=AA=9E=E3=81=A8=E8=8B=B1=E8=AA=9E?= =?UTF-8?q?=EF=BC=89=E3=81=AB=E5=AF=BE=E5=BF=9C=E3=80=81Config=E3=81=A7?= =?UTF-8?q?=E8=A8=80=E8=AA=9E=E3=82=92=E5=A4=89=E6=9B=B4=E3=81=A7=E3=81=8D?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=80=82=E3=81=9D=E3=82=8C?= =?UTF-8?q?=E3=81=AB=E4=BC=B4=E3=81=84UI=E3=82=92=E5=86=8D=E7=94=9F?= =?UTF-8?q?=E6=88=90=E3=81=97=E3=81=A6=E3=81=84=E3=82=8B=E3=81=9F=E3=82=81?= =?UTF-8?q?=E3=80=81=E3=81=9D=E3=81=AE=E9=83=A8=E5=88=86=E3=82=92=E9=96=A2?= =?UTF-8?q?=E6=95=B0=E5=8C=96=E3=81=97=E3=81=A6=E5=88=87=E3=82=8A=E5=87=BA?= =?UTF-8?q?=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VRCT.py | 136 +++-- languages.py | 6 + locales.yml | 125 +++++ utils.py | 91 +++- window_config.py | 1356 ++++++++++++++++++++++++---------------------- 5 files changed, 1015 insertions(+), 699 deletions(-) create mode 100644 locales.yml diff --git a/VRCT.py b/VRCT.py index 1c294404..3270081f 100644 --- a/VRCT.py +++ b/VRCT.py @@ -8,11 +8,11 @@ from customtkinter import CTk, CTkFrame, CTkCheckBox, CTkFont, CTkButton, CTkIma from PIL.Image import open as Image_open from flashtext import KeywordProcessor -from utils import save_json, print_textbox, thread_fnc +from utils import save_json, print_textbox, thread_fnc, get_localized_text, widget_main_window_label_setter from osc_tools import send_typing, send_message from window_config import ToplevelWindowConfig from window_information import ToplevelWindowInformation -from languages import transcription_lang, translators, translation_lang +from languages import transcription_lang, translators, translation_lang, selectable_languages from audio_utils import get_input_device_list, get_output_device_list, get_default_input_device, get_default_output_device from audio_recorder import SelectedMicRecorder, SelectedSpeakerRecorder from audio_transcriber import AudioTranscriber @@ -39,6 +39,7 @@ class App(CTk): self.APPEARANCE_THEME = "System" self.UI_SCALING = "100%" self.FONT_FAMILY = "Yu Gothic UI" + self.UI_LANGUAGE = "en" ## Translation self.CHOICE_TRANSLATOR = translators[0] self.INPUT_SOURCE_LANG = list(translation_lang[self.CHOICE_TRANSLATOR].keys())[0] @@ -108,6 +109,9 @@ class App(CTk): if "FONT_FAMILY" in config.keys(): if config["FONT_FAMILY"] in list(tk.font.families()): self.FONT_FAMILY = config["FONT_FAMILY"] + if "UI_LANGUAGE" in config.keys(): + if config["UI_LANGUAGE"] in list(selectable_languages.keys()): + self.UI_LANGUAGE = config["UI_LANGUAGE"] # translation if "CHOICE_TRANSLATOR" in config.keys(): @@ -208,6 +212,7 @@ class App(CTk): "TRANSPARENCY": self.TRANSPARENCY, "APPEARANCE_THEME": self.APPEARANCE_THEME, "UI_SCALING": self.UI_SCALING, + "UI_LANGUAGE": self.UI_LANGUAGE, "FONT_FAMILY": self.FONT_FAMILY, "CHOICE_TRANSLATOR": self.CHOICE_TRANSLATOR, "INPUT_SOURCE_LANG": self.INPUT_SOURCE_LANG, @@ -255,10 +260,12 @@ class App(CTk): self.sidebar_frame.grid(row=0, column=0, rowspan=4, sticky="nsw") self.sidebar_frame.grid_rowconfigure(5, weight=1) + init_lang_text = "Loading..." + # add checkbox translation self.checkbox_translation = CTkCheckBox( self.sidebar_frame, - text="translation", + text=init_lang_text, onvalue=True, offvalue=False, command=self.checkbox_translation_callback, @@ -269,7 +276,7 @@ class App(CTk): # add checkbox transcription send self.checkbox_transcription_send = CTkCheckBox( self.sidebar_frame, - text="voice2chatbox", + text=init_lang_text, onvalue=True, offvalue=False, command=self.checkbox_transcription_send_callback, @@ -280,7 +287,7 @@ class App(CTk): # add checkbox transcription receive self.checkbox_transcription_receive = CTkCheckBox( self.sidebar_frame, - text="speaker2log", + text=init_lang_text, onvalue=True, offvalue=False, command=self.checkbox_transcription_receive_callback, @@ -291,7 +298,7 @@ class App(CTk): # add checkbox foreground self.checkbox_foreground = CTkCheckBox( self.sidebar_frame, - text="foreground", + text=init_lang_text, onvalue=True, offvalue=False, command=self.checkbox_foreground_callback, @@ -321,56 +328,10 @@ class App(CTk): self.button_config.grid(row=5, column=1, padx=(5, 10), pady=(5, 5), sticky="wse") self.config_window = None + # load ui language data + language_yaml_data = get_localized_text(f"{self.UI_LANGUAGE}") # add tabview textbox - self.tabview_logs = CTkTabview(master=self) - self.tabview_logs.add("log") - self.tabview_logs.add("send") - self.tabview_logs.add("receive") - self.tabview_logs.add("system") - self.tabview_logs.grid(row=0, column=1, padx=0, pady=0, sticky="nsew") - self.tabview_logs._segmented_button.configure(font=CTkFont(family=self.FONT_FAMILY)) - self.tabview_logs._segmented_button.grid(sticky="W") - self.tabview_logs.tab("log").grid_rowconfigure(0, weight=1) - self.tabview_logs.tab("log").grid_columnconfigure(0, weight=1) - self.tabview_logs.tab("send").grid_rowconfigure(0, weight=1) - self.tabview_logs.tab("send").grid_columnconfigure(0, weight=1) - self.tabview_logs.tab("receive").grid_rowconfigure(0, weight=1) - self.tabview_logs.tab("receive").grid_columnconfigure(0, weight=1) - self.tabview_logs.tab("system").grid_rowconfigure(0, weight=1) - self.tabview_logs.tab("system").grid_columnconfigure(0, weight=1) - self.tabview_logs.configure(fg_color="transparent") - - # add textbox message log - self.textbox_message_log = CTkTextbox( - self.tabview_logs.tab("log"), - font=CTkFont(family=self.FONT_FAMILY) - ) - self.textbox_message_log.grid(row=0, column=0, padx=0, pady=0, sticky="nsew") - self.textbox_message_log.configure(state='disabled') - - # add textbox message send log - self.textbox_message_send_log = CTkTextbox( - self.tabview_logs.tab("send"), - font=CTkFont(family=self.FONT_FAMILY) - ) - self.textbox_message_send_log.grid(row=0, column=0, padx=0, pady=0, sticky="nsew") - self.textbox_message_send_log.configure(state='disabled') - - # add textbox message receive log - self.textbox_message_receive_log = CTkTextbox( - self.tabview_logs.tab("receive"), - font=CTkFont(family=self.FONT_FAMILY) - ) - self.textbox_message_receive_log.grid(row=0, column=0, padx=0, pady=0, sticky="nsew") - self.textbox_message_receive_log.configure(state='disabled') - - # add textbox message system log - self.textbox_message_system_log = CTkTextbox( - self.tabview_logs.tab("system"), - font=CTkFont(family=self.FONT_FAMILY) - ) - self.textbox_message_system_log.grid(row=0, column=0, padx=0, pady=0, sticky="nsew") - self.textbox_message_system_log.configure(state='disabled') + self.add_tabview_logs(language_yaml_data) # add entry message box self.entry_message_box = CTkEntry( @@ -667,6 +628,71 @@ class App(CTk): self.quit() self.destroy() + def delete_tabview_logs(self, pre_language_yaml_data): + self.tabview_logs.delete(pre_language_yaml_data["main_tab_title_log"]) + self.tabview_logs.delete(pre_language_yaml_data["main_tab_title_send"]) + self.tabview_logs.delete(pre_language_yaml_data["main_tab_title_receive"]) + self.tabview_logs.delete(pre_language_yaml_data["main_tab_title_system"]) + + def add_tabview_logs(self, language_yaml_data): + main_tab_title_log = language_yaml_data["main_tab_title_log"] + main_tab_title_send = language_yaml_data["main_tab_title_send"] + main_tab_title_receive = language_yaml_data["main_tab_title_receive"] + main_tab_title_system = language_yaml_data["main_tab_title_system"] + + # add tabview textbox + self.tabview_logs = CTkTabview(master=self) + self.tabview_logs.add(main_tab_title_log) + self.tabview_logs.add(main_tab_title_send) + self.tabview_logs.add(main_tab_title_receive) + self.tabview_logs.add(main_tab_title_system) + self.tabview_logs.grid(row=0, column=1, padx=0, pady=0, sticky="nsew") + self.tabview_logs._segmented_button.configure(font=CTkFont(family=self.FONT_FAMILY)) + self.tabview_logs._segmented_button.grid(sticky="W") + self.tabview_logs.tab(main_tab_title_log).grid_rowconfigure(0, weight=1) + self.tabview_logs.tab(main_tab_title_log).grid_columnconfigure(0, weight=1) + self.tabview_logs.tab(main_tab_title_send).grid_rowconfigure(0, weight=1) + self.tabview_logs.tab(main_tab_title_send).grid_columnconfigure(0, weight=1) + self.tabview_logs.tab(main_tab_title_receive).grid_rowconfigure(0, weight=1) + self.tabview_logs.tab(main_tab_title_receive).grid_columnconfigure(0, weight=1) + self.tabview_logs.tab(main_tab_title_system).grid_rowconfigure(0, weight=1) + self.tabview_logs.tab(main_tab_title_system).grid_columnconfigure(0, weight=1) + self.tabview_logs.configure(fg_color="transparent") + + # add textbox message log + self.textbox_message_log = CTkTextbox( + self.tabview_logs.tab(main_tab_title_log), + font=CTkFont(family=self.FONT_FAMILY) + ) + self.textbox_message_log.grid(row=0, column=0, padx=0, pady=0, sticky="nsew") + self.textbox_message_log.configure(state='disabled') + + # add textbox message send log + self.textbox_message_send_log = CTkTextbox( + self.tabview_logs.tab(main_tab_title_send), + font=CTkFont(family=self.FONT_FAMILY) + ) + self.textbox_message_send_log.grid(row=0, column=0, padx=0, pady=0, sticky="nsew") + self.textbox_message_send_log.configure(state='disabled') + + # add textbox message receive log + self.textbox_message_receive_log = CTkTextbox( + self.tabview_logs.tab(main_tab_title_receive), + font=CTkFont(family=self.FONT_FAMILY) + ) + self.textbox_message_receive_log.grid(row=0, column=0, padx=0, pady=0, sticky="nsew") + self.textbox_message_receive_log.configure(state='disabled') + + # add textbox message system log + self.textbox_message_system_log = CTkTextbox( + self.tabview_logs.tab(main_tab_title_system), + font=CTkFont(family=self.FONT_FAMILY) + ) + self.textbox_message_system_log.grid(row=0, column=0, padx=0, pady=0, sticky="nsew") + self.textbox_message_system_log.configure(state='disabled') + + widget_main_window_label_setter(self, language_yaml_data) + if __name__ == "__main__": try: app = App() diff --git a/languages.py b/languages.py index 40b546f5..186fd747 100644 --- a/languages.py +++ b/languages.py @@ -278,4 +278,10 @@ translation_lang["Bing(web)"] = { "telugu":"te", "punjabi":"pa", "irish":"ga" +} + +selectable_languages = { + "en": "English", + "ja": "日本語", + # 新しい言語とキーを追加する場合はここに追記してください } \ No newline at end of file diff --git a/locales.yml b/locales.yml new file mode 100644 index 00000000..38dbe6e4 --- /dev/null +++ b/locales.yml @@ -0,0 +1,125 @@ +en: + # main window + checkbox_translation: "Translation" + checkbox_transcription_send: "Voice2chatbox" + checkbox_transcription_receive: "Speaker2log" + checkbox_foreground: "Foreground" + + # main tabview + main_tab_title_log: "Log" + main_tab_title_send: "Send" + main_tab_title_receive: "Receive" + main_tab_title_system: "System" + + + # configure window + # config tabview + config_tab_title_ui: "UI" + config_tab_title_translation: "Translation" + config_tab_title_transcription: "Transcription" + config_tab_title_parameter: "Parameter" + config_tab_title_others: "Others" + # tab UI + label_transparency: "Transparency" + label_appearance_theme: "Appearance Theme" + label_ui_scaling: "UI Scaling" + label_font_family: "Font Family" + label_ui_language: "UI Language" + + # tab Translation + label_translation_translator: "Select Translator" + label_translation_input_language: "Send Language" + label_translation_output_language: "Receive Language" + + # tab Transcription + label_input_mic_host: "Input Mic Host" + label_input_mic_device: "Input Mic Device" + label_input_mic_voice_language: "Input Mic Voice Language" + label_input_mic_energy_threshold: "Input Mic Energy Threshold" + checkbox_input_mic_threshold_check: "Check threshold point" + label_input_mic_dynamic_energy_threshold: "Input Mic Dynamic Energy Threshold" + label_input_mic_record_timeout: "Input Mic Record Timeout" + label_input_mic_phrase_timeout: "Input Mic Phrase Timeout" + label_input_mic_max_phrases: "Input Mic Max Phrases" + label_input_mic_word_filter: "Input Mic Word Filter" + + label_input_speaker_device: "Input Speaker Device" + label_input_speaker_voice_language: "Input Speaker Voice Language" + label_input_speaker_energy_threshold: "Input Speaker Energy Threshold" + checkbox_input_speaker_threshold_check: "Check threshold point" + label_input_speaker_dynamic_energy_threshold: "Input Speaker Dynamic Energy Threshold" + label_input_speaker_record_timeout: "Input Speaker Record Timeout" + label_input_speaker_phrase_timeout: "Input Speaker Phrase Timeout" + label_input_speaker_max_phrases: "Input Speaker Max Phrases" + + # tab Parameter + label_ip_address: "OSC IP address" + label_port: "OSC Port" + label_authkey: "DeepL Auth Key" + label_message_format: "Message Format" + + # tab Others + label_checkbox_auto_clear_chatbox: "Auto clear chat box" + + +ja: + # main window + checkbox_translation: "翻訳" + checkbox_transcription_send: "マイク->チャットボックス" + checkbox_transcription_receive: "スピーカー->ログ" + checkbox_foreground: "最前面表示" + + # main tabview + main_tab_title_log: "ログ" + main_tab_title_send: "送信" + main_tab_title_receive: "受信" + main_tab_title_system: "システム" + + + # configure window + # config tabview + config_tab_title_ui: "UI" + config_tab_title_translation: "翻訳方法" + config_tab_title_transcription: "音声認識" + config_tab_title_parameter: "パラメーター" + config_tab_title_others: "その他" + + # tab UI + label_transparency: "透過度" + label_appearance_theme: "外観テーマを選択" + label_ui_scaling: "UIの拡大縮小" + label_font_family: "使用フォントの変更" + label_ui_language: "UI 言語" + + # tab Translation + label_translation_translator: "翻訳エンジンの選択" + label_translation_input_language: "送信言語-->翻訳言語" + label_translation_output_language: "受信言語-->翻訳言語" + + # tab Transcription + label_input_mic_host: "マイク入力ホスト" + label_input_mic_device: "マイク入力デバイス" + label_input_mic_voice_language: "マイクで話す言語" + label_input_mic_energy_threshold: "音声取得のしきい値" + label_input_mic_dynamic_energy_threshold: "音声取得のしきい値の自動調整" + label_input_mic_record_timeout: "マイク音声の区切りの無音時間" + # label_input_mic_phrase_timeout: "" + label_input_mic_max_phrases: "保留する単語の上限(マイク)" + + label_input_speaker_device: "スピーカー(聞き取りたいデバイス)" + label_input_speaker_voice_language: "聞き取る音声の言語" + label_input_speaker_energy_threshold: "音声取得のしきい値" + label_input_speaker_dynamic_energy_threshold: "音声取得のしきい値の自動調整" + label_input_speaker_record_timeout: "スピーカー音声の区切りの無音時間" + # label_input_speaker_phrase_timeout: "" + label_input_speaker_max_phrases: "保留する単語の上限(スピーカー)" + + # tab Parameter + # label_ip_address: "" + # label_port: "" + # label_authkey: "" + label_message_format: "送信するメッセージのフォーマット" + + # tab Others + label_checkbox_auto_clear_chatbox: "送信後はチャットボックスを空にする" + diff --git a/utils.py b/utils.py index 013b16c6..0e63f179 100644 --- a/utils.py +++ b/utils.py @@ -1,4 +1,6 @@ from json import load, dump +from os import path as os_path +import yaml from datetime import datetime from threading import Thread, Event @@ -38,4 +40,91 @@ class thread_fnc(Thread): while True: if self.stopped(): return - self.fnc(*self._args, **self._kwargs) \ No newline at end of file + self.fnc(*self._args, **self._kwargs) + +def get_localized_text(language): + file_path = os_path.join(os_path.dirname(__file__), "locales.yml") + + with open(file_path, encoding="utf-8") as file: + languages_yaml_data = yaml.safe_load(file) + default_language = "en" + if language in languages_yaml_data: + localized_text = languages_yaml_data[language] + if default_language in languages_yaml_data: + default_text = languages_yaml_data[default_language] + merged_text = {**default_text, **localized_text} + return merged_text + else: + return localized_text + else: + return None + +def get_key_by_value(dictionary, value): + for key, val in dictionary.items(): + if val == value: + return key + return None + +def widget_config_window_label_setter(self, language_yaml_data): + widget_names = [ + # tab UI + "label_transparency", + "label_appearance_theme", + "label_ui_scaling", + "label_font_family", + "label_ui_language", + + # tab Translation + "label_translation_translator", + "label_translation_input_language", + "label_translation_output_language", + + # tab Transcription + "label_input_mic_host", + "label_input_mic_device", + "label_input_mic_voice_language", + "label_input_mic_energy_threshold", + "checkbox_input_mic_threshold_check", + "label_input_mic_dynamic_energy_threshold", + "label_input_mic_record_timeout", + "label_input_mic_phrase_timeout", + "label_input_mic_max_phrases", + "label_input_mic_word_filter", + + "label_input_speaker_device", + "label_input_speaker_voice_language", + "label_input_speaker_energy_threshold", + "checkbox_input_speaker_threshold_check", + "label_input_speaker_dynamic_energy_threshold", + "label_input_speaker_record_timeout", + "label_input_speaker_phrase_timeout", + "label_input_speaker_max_phrases", + + + # tab Parameter + "label_ip_address", + "label_port", + "label_authkey", + "label_message_format", + + # tab Others + "label_checkbox_auto_clear_chatbox" + ] + for name in widget_names: + widget = getattr(self, name) + text_value = language_yaml_data.get(name) + if widget is not None and text_value is not None: + widget.configure(text=text_value + ":") + +def widget_main_window_label_setter(self, language_yaml_data): + widget_names = [ + "checkbox_translation", + "checkbox_transcription_send", + "checkbox_transcription_receive", + "checkbox_foreground", + ] + for name in widget_names: + widget = getattr(self, name) + text_value = language_yaml_data.get(name) + if widget is not None and text_value is not None: + widget.configure(text=text_value) \ No newline at end of file diff --git a/window_config.py b/window_config.py index 637af7f5..747f21f8 100644 --- a/window_config.py +++ b/window_config.py @@ -7,10 +7,10 @@ import customtkinter from customtkinter import CTkToplevel, CTkTabview, CTkFont, CTkLabel, CTkSlider, CTkOptionMenu, StringVar, CTkEntry, CTkCheckBox, CTkProgressBar from flashtext import KeywordProcessor -from utils import save_json, print_textbox, thread_fnc +from utils import save_json, print_textbox, thread_fnc, get_localized_text, get_key_by_value, widget_config_window_label_setter from audio_utils import get_input_device_list, get_output_device_list, get_default_output_device from audio_recorder import SelectedMicEnergyRecorder, SelectedSpeakeEnergyRecorder -from languages import translation_lang, transcription_lang +from languages import translation_lang, transcription_lang, selectable_languages class ToplevelWindowConfig(CTkToplevel): @@ -34,646 +34,12 @@ class ToplevelWindowConfig(CTkToplevel): self.speaker_energy_get_progressbar = None self.speaker_energy_plot_progressbar = None - # tabwiew config - self.tabview_config = CTkTabview(self) - self.tabview_config.grid(row=0, column=0, padx=5, pady=5, sticky="nsew") - self.tabview_config.add("UI") - self.tabview_config.add("Translation") - self.tabview_config.add("Transcription") - self.tabview_config.add("Parameter") - self.tabview_config.add("Others") - self.tabview_config.tab("UI").grid_columnconfigure(1, weight=1) - self.tabview_config.tab("Translation").grid_columnconfigure([1,2,3], weight=1) - self.tabview_config.tab("Transcription").grid_columnconfigure(1, weight=1) - self.tabview_config.tab("Parameter").grid_columnconfigure(1, weight=1) - self.tabview_config.tab("Others").grid_columnconfigure(1, weight=1) - self.tabview_config._segmented_button.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) - self.tabview_config._segmented_button.grid(sticky="W") - - # tab UI - ## slider transparency - row = 0 - padx = 5 - pady = 1 - self.label_transparency = CTkLabel( - self.tabview_config.tab("UI"), - text="Transparency:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_transparency.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.slider_transparency = CTkSlider( - self.tabview_config.tab("UI"), - from_=50, - to=100, - command=self.slider_transparency_callback, - variable=DoubleVar(value=self.parent.TRANSPARENCY), - ) - self.slider_transparency.grid(row=row, column=1, columnspan=1, padx=padx, pady=10, sticky="nsew") - - ## optionmenu theme - row += 1 - self.label_appearance_theme = CTkLabel( - self.tabview_config.tab("UI"), - text="Appearance Theme:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_appearance_theme.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.optionmenu_appearance_theme = CTkOptionMenu( - self.tabview_config.tab("UI"), - values=["Light", "Dark", "System"], - command=self.optionmenu_theme_callback, - variable=StringVar(value=self.parent.APPEARANCE_THEME), - font=CTkFont(family=self.parent.FONT_FAMILY), - ) - self.optionmenu_appearance_theme.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.optionmenu_appearance_theme._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) - - ## optionmenu UI scaling - row += 1 - self.label_ui_scaling = CTkLabel( - self.tabview_config.tab("UI"), - text="UI Scaling:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_ui_scaling.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.optionmenu_ui_scaling = CTkOptionMenu( - self.tabview_config.tab("UI"), - values=["80%", "90%", "100%", "110%", "120%"], - command=self.optionmenu_ui_scaling_callback, - variable=StringVar(value=self.parent.UI_SCALING), - font=CTkFont(family=self.parent.FONT_FAMILY), - ) - self.optionmenu_ui_scaling.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.optionmenu_ui_scaling._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) - - ## optionmenu font family - row += 1 - self.label_font_family = CTkLabel( - self.tabview_config.tab("UI"), - text="Font Family:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_font_family.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - font_families = list(tk_font.families()) - self.optionmenu_font_family = CTkOptionMenu( - self.tabview_config.tab("UI"), - values=font_families, - command=self.optionmenu_font_family_callback, - variable=StringVar(value=self.parent.FONT_FAMILY), - font=CTkFont(family=self.parent.FONT_FAMILY), - ) - self.optionmenu_font_family.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.optionmenu_font_family._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) - - # tab Translation - ## optionmenu translation translator - row = 0 - padx = 5 - pady = 1 - self.label_translation_translator = CTkLabel( - self.tabview_config.tab("Translation"), - text="Select Translator:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY), - ) - self.label_translation_translator.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.optionmenu_translation_translator = CTkOptionMenu( - self.tabview_config.tab("Translation"), - values=list(self.parent.translator.translator_status.keys()), - command=self.optionmenu_translation_translator_callback, - variable=StringVar(value=self.parent.CHOICE_TRANSLATOR), - font=CTkFont(family=self.parent.FONT_FAMILY), - ) - self.optionmenu_translation_translator.grid(row=row, column=1, columnspan=3, padx=padx, pady=pady, sticky="nsew") - self.optionmenu_translation_translator._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) - - ## optionmenu translation input language - row +=1 - self.label_translation_input_language = CTkLabel( - self.tabview_config.tab("Translation"), - text="Send Language:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_translation_input_language.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - - ## select translation input source language - self.optionmenu_translation_input_source_language = CTkOptionMenu( - self.tabview_config.tab("Translation"), - command=self.optionmenu_translation_input_source_language_callback, - values=list(translation_lang[self.parent.CHOICE_TRANSLATOR].keys()), - variable=StringVar(value=self.parent.INPUT_SOURCE_LANG), - font=CTkFont(family=self.parent.FONT_FAMILY), - ) - self.optionmenu_translation_input_source_language.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.optionmenu_translation_input_source_language._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) - - ## label translation input arrow - self.label_translation_input_arrow = CTkLabel( - self.tabview_config.tab("Translation"), - text="-->", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_translation_input_arrow.grid(row=row, column=2, columnspan=1, padx=padx, pady=pady, sticky="nsew") - - ## select translation input target language - self.optionmenu_translation_input_target_language = CTkOptionMenu( - self.tabview_config.tab("Translation"), - command=self.optionmenu_translation_input_target_language_callback, - values=list(translation_lang[self.parent.CHOICE_TRANSLATOR].keys()), - variable=StringVar(value=self.parent.INPUT_TARGET_LANG), - font=CTkFont(family=self.parent.FONT_FAMILY), - ) - self.optionmenu_translation_input_target_language.grid(row=row, column=3, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.optionmenu_translation_input_target_language._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) - - ## optionmenu translation output language - row +=1 - self.label_translation_output_language = CTkLabel( - self.tabview_config.tab("Translation"), - text="Receive Language:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_translation_output_language.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - - ## select translation output source language - self.optionmenu_translation_output_source_language = CTkOptionMenu( - self.tabview_config.tab("Translation"), - command=self.optionmenu_translation_output_source_language_callback, - values=list(translation_lang[self.parent.CHOICE_TRANSLATOR].keys()), - variable=StringVar(value=self.parent.OUTPUT_SOURCE_LANG), - font=CTkFont(family=self.parent.FONT_FAMILY), - ) - self.optionmenu_translation_output_source_language.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.optionmenu_translation_output_source_language._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) - - ## label translation output arrow - self.label_translation_output_arrow = CTkLabel( - self.tabview_config.tab("Translation"), - text="-->", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_translation_output_arrow.grid(row=row, column=2, columnspan=1, padx=padx, pady=pady, sticky="nsew") - - ## select translation output target language - self.optionmenu_translation_output_target_language = CTkOptionMenu( - self.tabview_config.tab("Translation"), - command=self.optionmenu_translation_output_target_language_callback, - values=list(translation_lang[self.parent.CHOICE_TRANSLATOR].keys()), - variable=StringVar(value=self.parent.OUTPUT_TARGET_LANG), - font=CTkFont(family=self.parent.FONT_FAMILY), - ) - self.optionmenu_translation_output_target_language.grid(row=row, column=3, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.optionmenu_translation_output_target_language._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) - - # tab Transcription - ## optionmenu input mic device - row = 0 - padx = 5 - pady = 1 - self.label_input_mic_host = CTkLabel( - self.tabview_config.tab("Transcription"), - text="Input Mic Host:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_input_mic_host.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.optionmenu_input_mic_host = CTkOptionMenu( - self.tabview_config.tab("Transcription"), - values=[host for host in get_input_device_list().keys()], - command=self.optionmenu_input_mic_host_callback, - variable=StringVar(value=self.parent.CHOICE_MIC_HOST), - font=CTkFont(family=self.parent.FONT_FAMILY), - ) - self.optionmenu_input_mic_host.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.optionmenu_input_mic_host._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) - - row += 1 - self.label_input_mic_device = CTkLabel( - self.tabview_config.tab("Transcription"), - text="Input Mic Device:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_input_mic_device.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.optionmenu_input_mic_device = CTkOptionMenu( - self.tabview_config.tab("Transcription"), - values=[device["name"] for device in get_input_device_list()[self.parent.CHOICE_MIC_HOST]], - command=self.optionmenu_input_mic_device_callback, - variable=StringVar(value=self.parent.CHOICE_MIC_DEVICE), - font=CTkFont(family=self.parent.FONT_FAMILY), - ) - self.optionmenu_input_mic_device.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.optionmenu_input_mic_device._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) - - ## optionmenu input mic voice language - row +=1 - self.label_input_mic_voice_language = CTkLabel( - self.tabview_config.tab("Transcription"), - text="Input Mic Voice Language:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_input_mic_voice_language.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.optionmenu_input_mic_voice_language = CTkOptionMenu( - self.tabview_config.tab("Transcription"), - values=list(transcription_lang.keys()), - command=self.optionmenu_input_mic_voice_language_callback, - variable=StringVar(value=self.parent.INPUT_MIC_VOICE_LANGUAGE), - font=CTkFont(family=self.parent.FONT_FAMILY), - ) - self.optionmenu_input_mic_voice_language.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.optionmenu_input_mic_voice_language._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) - - ## slider input mic energy threshold - row +=1 - self.label_input_mic_energy_threshold = CTkLabel( - self.tabview_config.tab("Transcription"), - text="Input Mic Energy Threshold:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_input_mic_energy_threshold.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - - self.slider_input_mic_energy_threshold = CTkSlider( - self.tabview_config.tab("Transcription"), - from_=0, - to=self.MAX_MIC_ENERGY_THRESHOLD, - border_width=7, - button_length=0, - button_corner_radius=3, - number_of_steps=self.MAX_MIC_ENERGY_THRESHOLD, - command=self.slider_input_mic_energy_threshold_callback, - variable=IntVar(value=self.parent.INPUT_MIC_ENERGY_THRESHOLD), - ) - self.slider_input_mic_energy_threshold.grid(row=row, column=1, columnspan=1, padx=0, pady=5, sticky="nsew") - - ## progressBar input mic energy threshold - row +=1 - self.checkbox_input_mic_threshold_check = CTkCheckBox( - self.tabview_config.tab("Transcription"), - text="check threshold point", - onvalue=True, - offvalue=False, - command=self.checkbox_input_mic_threshold_check_callback, - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.checkbox_input_mic_threshold_check.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - - self.progressBar_input_mic_energy_threshold = CTkProgressBar( - self.tabview_config.tab("Transcription"), - corner_radius=0 - ) - self.progressBar_input_mic_energy_threshold.grid(row=row, column=1, columnspan=1, padx=padx, pady=5, sticky="nsew") - self.progressBar_input_mic_energy_threshold.set(0) - - ## checkbox input mic dynamic energy threshold - row +=1 - self.label_input_mic_dynamic_energy_threshold = CTkLabel( - self.tabview_config.tab("Transcription"), - text="Input Mic Dynamic Energy Threshold:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_input_mic_dynamic_energy_threshold.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.checkbox_input_mic_dynamic_energy_threshold = CTkCheckBox( - self.tabview_config.tab("Transcription"), - text="", - onvalue=True, - offvalue=False, - command=self.checkbox_input_mic_dynamic_energy_threshold_callback, - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.checkbox_input_mic_dynamic_energy_threshold.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, 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_dynamic_energy_threshold.deselect() - - ## entry input mic record timeout - row +=1 - self.label_input_mic_record_timeout = CTkLabel( - self.tabview_config.tab("Transcription"), - text="Input Mic Record Timeout:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_input_mic_record_timeout.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.entry_input_mic_record_timeout = CTkEntry( - self.tabview_config.tab("Transcription"), - textvariable=StringVar(value=self.parent.INPUT_MIC_RECORD_TIMEOUT), - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.entry_input_mic_record_timeout.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.entry_input_mic_record_timeout.bind("", self.entry_input_mic_record_timeout_callback) - - ## entry input mic phrase timeout - row +=1 - self.label_input_mic_phrase_timeout = CTkLabel( - self.tabview_config.tab("Transcription"), - text="Input Mic Phrase Timeout:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_input_mic_phrase_timeout.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.entry_input_mic_phrase_timeout = CTkEntry( - self.tabview_config.tab("Transcription"), - textvariable=StringVar(value=self.parent.INPUT_MIC_PHRASE_TIMEOUT), - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.entry_input_mic_phrase_timeout.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.entry_input_mic_phrase_timeout.bind("", self.entry_input_mic_phrase_timeout_callback) - - ## entry input mic max phrases - row +=1 - self.label_input_mic_max_phrases = CTkLabel( - self.tabview_config.tab("Transcription"), - text="Input Mic Max Phrases:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_input_mic_max_phrases.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.entry_input_mic_max_phrases = CTkEntry( - self.tabview_config.tab("Transcription"), - textvariable=StringVar(value=self.parent.INPUT_MIC_MAX_PHRASES), - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.entry_input_mic_max_phrases.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.entry_input_mic_max_phrases.bind("", self.entry_input_mic_max_phrases_callback) - - ## entry input mic word filter - row +=1 - self.label_input_mic_word_filter = CTkLabel( - self.tabview_config.tab("Transcription"), - text="Input Mic Word Filter:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_input_mic_word_filter.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.entry_input_mic_word_filter = CTkEntry( - self.tabview_config.tab("Transcription"), - textvariable=StringVar(value=",".join(self.parent.INPUT_MIC_WORD_FILTER)), - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.entry_input_mic_word_filter.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.entry_input_mic_word_filter.bind("", self.entry_input_mic_word_filters_callback) - - ## optionmenu input speaker device - row +=1 - self.label_input_speaker_device = CTkLabel( - self.tabview_config.tab("Transcription"), - text="Input Speaker Device:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_input_speaker_device.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.optionmenu_input_speaker_device = CTkOptionMenu( - self.tabview_config.tab("Transcription"), - values=[device["name"] for device in get_output_device_list()], - command=self.optionmenu_input_speaker_device_callback, - variable=StringVar(value=self.parent.CHOICE_SPEAKER_DEVICE), - font=CTkFont(family=self.parent.FONT_FAMILY), - ) - self.optionmenu_input_speaker_device.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.optionmenu_input_speaker_device._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) - - ## optionmenu input speaker voice language - row +=1 - self.label_input_speaker_voice_language = CTkLabel( - self.tabview_config.tab("Transcription"), - text="Input Speaker Voice Language:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_input_speaker_voice_language.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.optionmenu_input_speaker_voice_language = CTkOptionMenu( - self.tabview_config.tab("Transcription"), - values=list(transcription_lang.keys()), - command=self.optionmenu_input_speaker_voice_language_callback, - variable=StringVar(value=self.parent.INPUT_SPEAKER_VOICE_LANGUAGE), - font=CTkFont(family=self.parent.FONT_FAMILY), - ) - self.optionmenu_input_speaker_voice_language.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.optionmenu_input_speaker_voice_language._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) - - ## entry input speaker energy threshold - row +=1 - self.label_input_speaker_energy_threshold = CTkLabel( - self.tabview_config.tab("Transcription"), - text="Input Speaker Energy Threshold:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_input_speaker_energy_threshold.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - - ## progressBar input speaker energy threshold - self.slider_input_speaker_energy_threshold = CTkSlider( - self.tabview_config.tab("Transcription"), - from_=0, - to=self.MAX_SPEAKER_ENERGY_THRESHOLD, - border_width=7, - button_length=0, - button_corner_radius=3, - number_of_steps=self.MAX_SPEAKER_ENERGY_THRESHOLD, - command=self.slider_input_speaker_energy_threshold_callback, - variable=IntVar(value=self.parent.INPUT_SPEAKER_ENERGY_THRESHOLD), - ) - self.slider_input_speaker_energy_threshold.grid(row=row, column=1, columnspan=1, padx=0, pady=5, sticky="nsew") - - ## progressBar input speaker energy threshold - row +=1 - self.checkbox_input_speaker_threshold_check = CTkCheckBox( - self.tabview_config.tab("Transcription"), - text="check threshold point", - onvalue=True, - offvalue=False, - command=self.checkbox_input_speaker_threshold_check_callback, - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.checkbox_input_speaker_threshold_check.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - - self.progressBar_input_speaker_energy_threshold = CTkProgressBar( - self.tabview_config.tab("Transcription"), - corner_radius=0 - ) - self.progressBar_input_speaker_energy_threshold.grid(row=row, column=1, columnspan=1, padx=padx, pady=5, sticky="nsew") - self.progressBar_input_speaker_energy_threshold.set(0) - - ## checkbox input speaker dynamic energy threshold - row +=1 - self.label_input_speaker_dynamic_energy_threshold = CTkLabel( - self.tabview_config.tab("Transcription"), - text="Input Speaker Dynamic Energy Threshold:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_input_speaker_dynamic_energy_threshold.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.checkbox_input_speaker_dynamic_energy_threshold = CTkCheckBox( - self.tabview_config.tab("Transcription"), - text="", - onvalue=True, - offvalue=False, - command=self.checkbox_input_speaker_dynamic_energy_threshold_callback, - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.checkbox_input_speaker_dynamic_energy_threshold.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, 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 - row +=1 - self.label_input_speaker_record_timeout = CTkLabel( - self.tabview_config.tab("Transcription"), - text="Input Speaker Record Timeout:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_input_speaker_record_timeout.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.entry_input_speaker_record_timeout = CTkEntry( - self.tabview_config.tab("Transcription"), - textvariable=StringVar(value=self.parent.INPUT_SPEAKER_RECORD_TIMEOUT), - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.entry_input_speaker_record_timeout.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.entry_input_speaker_record_timeout.bind("", self.entry_input_speaker_record_timeout_callback) - - ## entry input speaker phrase timeout - row +=1 - self.label_input_speaker_phrase_timeout = CTkLabel( - self.tabview_config.tab("Transcription"), - text="Input Speaker Phrase Timeout:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_input_speaker_phrase_timeout.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.entry_input_speaker_phrase_timeout = CTkEntry( - self.tabview_config.tab("Transcription"), - textvariable=StringVar(value=self.parent.INPUT_SPEAKER_PHRASE_TIMEOUT), - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.entry_input_speaker_phrase_timeout.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.entry_input_speaker_phrase_timeout.bind("", self.entry_input_speaker_phrase_timeout_callback) - - ## entry input speaker max phrases - row +=1 - self.label_input_speaker_max_phrases = CTkLabel( - self.tabview_config.tab("Transcription"), - text="Input Speaker Max Phrases:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_input_speaker_max_phrases.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.entry_input_speaker_max_phrases = CTkEntry( - self.tabview_config.tab("Transcription"), - textvariable=StringVar(value=self.parent.INPUT_SPEAKER_MAX_PHRASES), - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.entry_input_speaker_max_phrases.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.entry_input_speaker_max_phrases.bind("", self.entry_input_speaker_max_phrases_callback) - - # tab Parameter - ## entry ip address - row = 0 - padx = 5 - pady = 1 - self.label_ip_address = CTkLabel( - self.tabview_config.tab("Parameter"), - text="OSC IP address:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_ip_address.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.entry_ip_address = CTkEntry( - self.tabview_config.tab("Parameter"), - textvariable=StringVar(value=self.parent.OSC_IP_ADDRESS), - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.entry_ip_address.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.entry_ip_address.bind("", self.entry_ip_address_callback) - - ## entry port - row +=1 - self.label_port = CTkLabel( - self.tabview_config.tab("Parameter"), - text="OSC Port:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_port.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.entry_port = CTkEntry( - self.tabview_config.tab("Parameter"), - textvariable=StringVar(value=self.parent.OSC_PORT), - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.entry_port.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.entry_port.bind("", self.entry_port_callback) - - ## entry authkey - row +=1 - self.label_authkey = CTkLabel( - self.tabview_config.tab("Parameter"), - text="DeepL Auth Key:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_authkey.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.entry_authkey = CTkEntry( - self.tabview_config.tab("Parameter"), - textvariable=StringVar(value=self.parent.AUTH_KEYS["DeepL(auth)"]), - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.entry_authkey.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.entry_authkey.bind("", self.entry_authkey_callback) - - ## entry message format - row +=1 - self.label_message_format = CTkLabel( - self.tabview_config.tab("Parameter"), - text="Message Format:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_message_format.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.entry_message_format = CTkEntry( - self.tabview_config.tab("Parameter"), - textvariable=StringVar(value=self.parent.MESSAGE_FORMAT), - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.entry_message_format.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - self.entry_message_format.bind("", self.entry_message_format_callback) - - # tab Others - ## checkbox auto clear chat box - row += 1 - self.label_checkbox_auto_clear_chatbox = CTkLabel( - self.tabview_config.tab("Others"), - text="Auto clear chat box:", - fg_color="transparent", - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.label_checkbox_auto_clear_chatbox.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") - self.checkbox_auto_clear_chatbox = CTkCheckBox( - self.tabview_config.tab("Others"), - text="", - onvalue=True, - offvalue=False, - command=self.checkbox_auto_clear_chatbox_callback, - font=CTkFont(family=self.parent.FONT_FAMILY) - ) - self.checkbox_auto_clear_chatbox.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") - if self.parent.ENABLE_AUTO_CLEAR_CHATBOX is True: - self.checkbox_auto_clear_chatbox.select() - else: - self.checkbox_auto_clear_chatbox.deselect() + # load ui language data + language_yaml_data = get_localized_text(f"{self.parent.UI_LANGUAGE}") + # add tabview config + self.add_tabview_config(language_yaml_data, selectable_languages) + # set all config window labels + widget_config_window_label_setter(self, language_yaml_data) self.protocol("WM_DELETE_WINDOW", self.delete_window) @@ -708,6 +74,9 @@ class ToplevelWindowConfig(CTkToplevel): self.label_font_family.configure(font=CTkFont(family=choice)) self.optionmenu_font_family.configure(font=CTkFont(family=choice)) self.optionmenu_font_family._dropdown_menu.configure(font=CTkFont(family=choice)) + self.label_ui_language.configure(font=CTkFont(family=choice)) + self.optionmenu_ui_language.configure(font=CTkFont(family=choice)) + self.optionmenu_ui_language._dropdown_menu.configure(font=CTkFont(family=choice)) # tab Translation self.label_translation_translator.configure(font=CTkFont(family=choice)) @@ -797,6 +166,27 @@ class ToplevelWindowConfig(CTkToplevel): self.parent.FONT_FAMILY = choice save_json(self.parent.PATH_CONFIG, "FONT_FAMILY", self.parent.FONT_FAMILY) + def optionmenu_ui_language_callback(self, choice): + pre_language_yaml_data = get_localized_text(f"{self.parent.UI_LANGUAGE}") + self.parent.UI_LANGUAGE = get_key_by_value(selectable_languages, choice) + language_yaml_data = get_localized_text(f"{self.parent.UI_LANGUAGE}") + save_json(self.parent.PATH_CONFIG, "UI_LANGUAGE", self.parent.UI_LANGUAGE) + + + # delete + self.parent.delete_tabview_logs(pre_language_yaml_data) + self.delete_tabview_config(pre_language_yaml_data) + # add tabview textbox + self.parent.add_tabview_logs(language_yaml_data) + self.add_tabview_config(language_yaml_data, selectable_languages) + + # 翻訳予定 + # window information + # try: + # self.parent.information_window.textbox_information.configure(font=customtkinter.CTkFont(family=choice)) + # except: + # pass + def optionmenu_translation_translator_callback(self, choice): if self.parent.translator.authentication(choice, self.parent.AUTH_KEYS[choice]) is False: print_textbox(self.parent.textbox_message_log, "Auth Key or language setting is incorrect", "ERROR") @@ -1017,4 +407,684 @@ class ToplevelWindowConfig(CTkToplevel): value = self.entry_message_format.get() if len(value) > 0: self.parent.MESSAGE_FORMAT = value - save_json(self.parent.PATH_CONFIG, "MESSAGE_FORMAT", self.parent.MESSAGE_FORMAT) \ No newline at end of file + save_json(self.parent.PATH_CONFIG, "MESSAGE_FORMAT", self.parent.MESSAGE_FORMAT) + + def delete_tabview_config(self, pre_language_yaml_data): + self.tabview_config.delete(pre_language_yaml_data["config_tab_title_ui"]) + self.tabview_config.delete(pre_language_yaml_data["config_tab_title_translation"]) + self.tabview_config.delete(pre_language_yaml_data["config_tab_title_transcription"]) + self.tabview_config.delete(pre_language_yaml_data["config_tab_title_parameter"]) + self.tabview_config.delete(pre_language_yaml_data["config_tab_title_others"]) + + def add_tabview_config(self, language_yaml_data, selectable_languages): + config_tab_title_ui = language_yaml_data["config_tab_title_ui"] + config_tab_title_translation = language_yaml_data["config_tab_title_translation"] + config_tab_title_transcription = language_yaml_data["config_tab_title_transcription"] + config_tab_title_parameter = language_yaml_data["config_tab_title_parameter"] + config_tab_title_others = language_yaml_data["config_tab_title_others"] + + init_lang_text = "Loading..." + + # tabwiew config + self.tabview_config = CTkTabview(self) + self.tabview_config.grid(row=0, column=0, padx=5, pady=5, sticky="nsew") + self.tabview_config.add(config_tab_title_ui) + self.tabview_config.add(config_tab_title_translation) + self.tabview_config.add(config_tab_title_transcription) + self.tabview_config.add(config_tab_title_parameter) + self.tabview_config.add(config_tab_title_others) + self.tabview_config.tab(config_tab_title_ui).grid_columnconfigure(1, weight=1) + self.tabview_config.tab(config_tab_title_translation).grid_columnconfigure([1,2,3], weight=1) + self.tabview_config.tab(config_tab_title_transcription).grid_columnconfigure(1, weight=1) + self.tabview_config.tab(config_tab_title_parameter).grid_columnconfigure(1, weight=1) + self.tabview_config.tab(config_tab_title_others).grid_columnconfigure(1, weight=1) + self.tabview_config._segmented_button.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) + self.tabview_config._segmented_button.grid(sticky="W") + + # tab UI + ## slider transparency + row = 0 + padx = 5 + pady = 1 + self.label_transparency = CTkLabel( + self.tabview_config.tab(config_tab_title_ui), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_transparency.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + self.slider_transparency = CTkSlider( + self.tabview_config.tab(config_tab_title_ui), + from_=50, + to=100, + command=self.slider_transparency_callback, + variable=DoubleVar(value=self.parent.TRANSPARENCY), + ) + self.slider_transparency.grid(row=row, column=1, columnspan=1, padx=padx, pady=10, sticky="nsew") + + ## optionmenu theme + row += 1 + self.label_appearance_theme = CTkLabel( + self.tabview_config.tab(config_tab_title_ui), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_appearance_theme.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + self.optionmenu_appearance_theme = CTkOptionMenu( + self.tabview_config.tab(config_tab_title_ui), + values=["Light", "Dark", "System"], + command=self.optionmenu_theme_callback, + variable=StringVar(value=self.parent.APPEARANCE_THEME), + font=CTkFont(family=self.parent.FONT_FAMILY), + ) + self.optionmenu_appearance_theme.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") + self.optionmenu_appearance_theme._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) + + ## optionmenu UI scaling + row += 1 + self.label_ui_scaling = CTkLabel( + self.tabview_config.tab(config_tab_title_ui), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_ui_scaling.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + self.optionmenu_ui_scaling = CTkOptionMenu( + self.tabview_config.tab(config_tab_title_ui), + values=["80%", "90%", "100%", "110%", "120%"], + command=self.optionmenu_ui_scaling_callback, + variable=StringVar(value=self.parent.UI_SCALING), + font=CTkFont(family=self.parent.FONT_FAMILY), + ) + self.optionmenu_ui_scaling.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") + self.optionmenu_ui_scaling._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) + + ## optionmenu font family + row += 1 + self.label_font_family = CTkLabel( + self.tabview_config.tab(config_tab_title_ui), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_font_family.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + font_families = list(tk_font.families()) + self.optionmenu_font_family = CTkOptionMenu( + self.tabview_config.tab(config_tab_title_ui), + values=font_families, + command=self.optionmenu_font_family_callback, + variable=StringVar(value=self.parent.FONT_FAMILY), + font=CTkFont(family=self.parent.FONT_FAMILY), + ) + self.optionmenu_font_family.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") + self.optionmenu_font_family._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) + + ## optionmenu ui language + row += 1 + self.label_ui_language = CTkLabel( + self.tabview_config.tab(config_tab_title_ui), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_ui_language.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + selectable_languages_values = list(selectable_languages.values()) + self.optionmenu_ui_language = CTkOptionMenu( + self.tabview_config.tab(config_tab_title_ui), + values=selectable_languages_values, + command=self.optionmenu_ui_language_callback, + variable=StringVar(value=selectable_languages[self.parent.UI_LANGUAGE]), + font=CTkFont(family=self.parent.FONT_FAMILY), + ) + self.optionmenu_ui_language.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") + self.optionmenu_ui_language._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) + + # tab Translation + ## optionmenu translation translator + row = 0 + padx = 5 + pady = 1 + self.label_translation_translator = CTkLabel( + self.tabview_config.tab(config_tab_title_translation), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY), + ) + self.label_translation_translator.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + self.optionmenu_translation_translator = CTkOptionMenu( + self.tabview_config.tab(config_tab_title_translation), + values=list(self.parent.translator.translator_status.keys()), + command=self.optionmenu_translation_translator_callback, + variable=StringVar(value=self.parent.CHOICE_TRANSLATOR), + font=CTkFont(family=self.parent.FONT_FAMILY), + ) + self.optionmenu_translation_translator.grid(row=row, column=1, columnspan=3, padx=padx, pady=pady, sticky="nsew") + self.optionmenu_translation_translator._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) + + ## optionmenu translation input language + row +=1 + self.label_translation_input_language = CTkLabel( + self.tabview_config.tab(config_tab_title_translation), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_translation_input_language.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + + ## select translation input source language + self.optionmenu_translation_input_source_language = CTkOptionMenu( + self.tabview_config.tab(config_tab_title_translation), + command=self.optionmenu_translation_input_source_language_callback, + values=list(translation_lang[self.parent.CHOICE_TRANSLATOR].keys()), + variable=StringVar(value=self.parent.INPUT_SOURCE_LANG), + font=CTkFont(family=self.parent.FONT_FAMILY), + ) + self.optionmenu_translation_input_source_language.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") + self.optionmenu_translation_input_source_language._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) + + ## label translation input arrow + self.label_translation_input_arrow = CTkLabel( + self.tabview_config.tab(config_tab_title_translation), + text="-->", + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_translation_input_arrow.grid(row=row, column=2, columnspan=1, padx=padx, pady=pady, sticky="nsew") + + ## select translation input target language + self.optionmenu_translation_input_target_language = CTkOptionMenu( + self.tabview_config.tab(config_tab_title_translation), + command=self.optionmenu_translation_input_target_language_callback, + values=list(translation_lang[self.parent.CHOICE_TRANSLATOR].keys()), + variable=StringVar(value=self.parent.INPUT_TARGET_LANG), + font=CTkFont(family=self.parent.FONT_FAMILY), + ) + self.optionmenu_translation_input_target_language.grid(row=row, column=3, columnspan=1, padx=padx, pady=pady, sticky="nsew") + self.optionmenu_translation_input_target_language._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) + + ## optionmenu translation output language + row +=1 + self.label_translation_output_language = CTkLabel( + self.tabview_config.tab(config_tab_title_translation), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_translation_output_language.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + + ## select translation output source language + self.optionmenu_translation_output_source_language = CTkOptionMenu( + self.tabview_config.tab(config_tab_title_translation), + command=self.optionmenu_translation_output_source_language_callback, + values=list(translation_lang[self.parent.CHOICE_TRANSLATOR].keys()), + variable=StringVar(value=self.parent.OUTPUT_SOURCE_LANG), + font=CTkFont(family=self.parent.FONT_FAMILY), + ) + self.optionmenu_translation_output_source_language.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") + self.optionmenu_translation_output_source_language._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) + + ## label translation output arrow + self.label_translation_output_arrow = CTkLabel( + self.tabview_config.tab(config_tab_title_translation), + text="-->", + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_translation_output_arrow.grid(row=row, column=2, columnspan=1, padx=padx, pady=pady, sticky="nsew") + + ## select translation output target language + self.optionmenu_translation_output_target_language = CTkOptionMenu( + self.tabview_config.tab(config_tab_title_translation), + command=self.optionmenu_translation_output_target_language_callback, + values=list(translation_lang[self.parent.CHOICE_TRANSLATOR].keys()), + variable=StringVar(value=self.parent.OUTPUT_TARGET_LANG), + font=CTkFont(family=self.parent.FONT_FAMILY), + ) + self.optionmenu_translation_output_target_language.grid(row=row, column=3, columnspan=1, padx=padx, pady=pady, sticky="nsew") + self.optionmenu_translation_output_target_language._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) + + # tab Transcription + ## optionmenu input mic device's host + row = 0 + padx = 5 + pady = 1 + self.label_input_mic_host = CTkLabel( + self.tabview_config.tab(config_tab_title_transcription), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_input_mic_host.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + self.optionmenu_input_mic_host = CTkOptionMenu( + self.tabview_config.tab(config_tab_title_transcription), + values=[host for host in get_input_device_list().keys()], + command=self.optionmenu_input_mic_host_callback, + variable=StringVar(value=self.parent.CHOICE_MIC_HOST), + font=CTkFont(family=self.parent.FONT_FAMILY), + ) + self.optionmenu_input_mic_host.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") + self.optionmenu_input_mic_host._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) + + ## optionmenu input mic device + row += 1 + self.label_input_mic_device = CTkLabel( + self.tabview_config.tab(config_tab_title_transcription), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_input_mic_device.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + self.optionmenu_input_mic_device = CTkOptionMenu( + self.tabview_config.tab(config_tab_title_transcription), + values=[device["name"] for device in get_input_device_list()[self.parent.CHOICE_MIC_HOST]], + command=self.optionmenu_input_mic_device_callback, + variable=StringVar(value=self.parent.CHOICE_MIC_DEVICE), + font=CTkFont(family=self.parent.FONT_FAMILY), + ) + self.optionmenu_input_mic_device.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") + self.optionmenu_input_mic_device._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) + + ## optionmenu input mic voice language + row +=1 + self.label_input_mic_voice_language = CTkLabel( + self.tabview_config.tab(config_tab_title_transcription), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_input_mic_voice_language.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + self.optionmenu_input_mic_voice_language = CTkOptionMenu( + self.tabview_config.tab(config_tab_title_transcription), + values=list(transcription_lang.keys()), + command=self.optionmenu_input_mic_voice_language_callback, + variable=StringVar(value=self.parent.INPUT_MIC_VOICE_LANGUAGE), + font=CTkFont(family=self.parent.FONT_FAMILY), + ) + self.optionmenu_input_mic_voice_language.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") + self.optionmenu_input_mic_voice_language._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) + + ## slider input mic energy threshold + row +=1 + self.label_input_mic_energy_threshold = CTkLabel( + self.tabview_config.tab(config_tab_title_transcription), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_input_mic_energy_threshold.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + + self.slider_input_mic_energy_threshold = CTkSlider( + self.tabview_config.tab(config_tab_title_transcription), + from_=0, + to=self.MAX_MIC_ENERGY_THRESHOLD, + border_width=7, + button_length=0, + button_corner_radius=3, + number_of_steps=self.MAX_MIC_ENERGY_THRESHOLD, + command=self.slider_input_mic_energy_threshold_callback, + variable=IntVar(value=self.parent.INPUT_MIC_ENERGY_THRESHOLD), + ) + self.slider_input_mic_energy_threshold.grid(row=row, column=1, columnspan=1, padx=0, pady=5, sticky="nsew") + + ## progressBar input mic energy threshold + row +=1 + self.checkbox_input_mic_threshold_check = CTkCheckBox( + self.tabview_config.tab(config_tab_title_transcription), + text=init_lang_text, + onvalue=True, + offvalue=False, + command=self.checkbox_input_mic_threshold_check_callback, + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.checkbox_input_mic_threshold_check.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + + self.progressBar_input_mic_energy_threshold = CTkProgressBar( + self.tabview_config.tab(config_tab_title_transcription), + corner_radius=0 + ) + self.progressBar_input_mic_energy_threshold.grid(row=row, column=1, columnspan=1, padx=padx, pady=5, sticky="nsew") + self.progressBar_input_mic_energy_threshold.set(0) + + ## checkbox input mic dynamic energy threshold + row +=1 + self.label_input_mic_dynamic_energy_threshold = CTkLabel( + self.tabview_config.tab(config_tab_title_transcription), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_input_mic_dynamic_energy_threshold.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + self.checkbox_input_mic_dynamic_energy_threshold = CTkCheckBox( + self.tabview_config.tab(config_tab_title_transcription), + text="", + onvalue=True, + offvalue=False, + command=self.checkbox_input_mic_dynamic_energy_threshold_callback, + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.checkbox_input_mic_dynamic_energy_threshold.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, 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_dynamic_energy_threshold.deselect() + + ## entry input mic record timeout + row +=1 + self.label_input_mic_record_timeout = CTkLabel( + self.tabview_config.tab(config_tab_title_transcription), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_input_mic_record_timeout.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + self.entry_input_mic_record_timeout = CTkEntry( + self.tabview_config.tab(config_tab_title_transcription), + textvariable=StringVar(value=self.parent.INPUT_MIC_RECORD_TIMEOUT), + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.entry_input_mic_record_timeout.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") + self.entry_input_mic_record_timeout.bind("", self.entry_input_mic_record_timeout_callback) + + ## entry input mic phrase timeout + row +=1 + self.label_input_mic_phrase_timeout = CTkLabel( + self.tabview_config.tab(config_tab_title_transcription), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_input_mic_phrase_timeout.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + self.entry_input_mic_phrase_timeout = CTkEntry( + self.tabview_config.tab(config_tab_title_transcription), + textvariable=StringVar(value=self.parent.INPUT_MIC_PHRASE_TIMEOUT), + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.entry_input_mic_phrase_timeout.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") + self.entry_input_mic_phrase_timeout.bind("", self.entry_input_mic_phrase_timeout_callback) + + ## entry input mic max phrases + row +=1 + self.label_input_mic_max_phrases = CTkLabel( + self.tabview_config.tab(config_tab_title_transcription), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_input_mic_max_phrases.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + self.entry_input_mic_max_phrases = CTkEntry( + self.tabview_config.tab(config_tab_title_transcription), + textvariable=StringVar(value=self.parent.INPUT_MIC_MAX_PHRASES), + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.entry_input_mic_max_phrases.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") + self.entry_input_mic_max_phrases.bind("", self.entry_input_mic_max_phrases_callback) + + ## entry input mic word filter + row +=1 + self.label_input_mic_word_filter = CTkLabel( + self.tabview_config.tab(config_tab_title_transcription), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_input_mic_word_filter.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + self.entry_input_mic_word_filter = CTkEntry( + self.tabview_config.tab(config_tab_title_transcription), + textvariable=StringVar(value=",".join(self.parent.INPUT_MIC_WORD_FILTER)), + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.entry_input_mic_word_filter.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") + self.entry_input_mic_word_filter.bind("", self.entry_input_mic_word_filters_callback) + + ## optionmenu input speaker device + row +=1 + self.label_input_speaker_device = CTkLabel( + self.tabview_config.tab(config_tab_title_transcription), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_input_speaker_device.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + self.optionmenu_input_speaker_device = CTkOptionMenu( + self.tabview_config.tab(config_tab_title_transcription), + values=[device["name"] for device in get_output_device_list()], + command=self.optionmenu_input_speaker_device_callback, + variable=StringVar(value=self.parent.CHOICE_SPEAKER_DEVICE), + font=CTkFont(family=self.parent.FONT_FAMILY), + ) + self.optionmenu_input_speaker_device.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") + self.optionmenu_input_speaker_device._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) + + ## optionmenu input speaker voice language + row +=1 + self.label_input_speaker_voice_language = CTkLabel( + self.tabview_config.tab(config_tab_title_transcription), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_input_speaker_voice_language.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + self.optionmenu_input_speaker_voice_language = CTkOptionMenu( + self.tabview_config.tab(config_tab_title_transcription), + values=list(transcription_lang.keys()), + command=self.optionmenu_input_speaker_voice_language_callback, + variable=StringVar(value=self.parent.INPUT_SPEAKER_VOICE_LANGUAGE), + font=CTkFont(family=self.parent.FONT_FAMILY), + ) + self.optionmenu_input_speaker_voice_language.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") + self.optionmenu_input_speaker_voice_language._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) + + ## entry input speaker energy threshold + row +=1 + self.label_input_speaker_energy_threshold = CTkLabel( + self.tabview_config.tab(config_tab_title_transcription), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_input_speaker_energy_threshold.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + + ## progressBar input speaker energy threshold + self.slider_input_speaker_energy_threshold = CTkSlider( + self.tabview_config.tab(config_tab_title_transcription), + from_=0, + to=self.MAX_SPEAKER_ENERGY_THRESHOLD, + border_width=7, + button_length=0, + button_corner_radius=3, + number_of_steps=self.MAX_SPEAKER_ENERGY_THRESHOLD, + command=self.slider_input_speaker_energy_threshold_callback, + variable=IntVar(value=self.parent.INPUT_SPEAKER_ENERGY_THRESHOLD), + ) + self.slider_input_speaker_energy_threshold.grid(row=row, column=1, columnspan=1, padx=0, pady=5, sticky="nsew") + + ## progressBar input speaker energy threshold + row +=1 + self.checkbox_input_speaker_threshold_check = CTkCheckBox( + self.tabview_config.tab(config_tab_title_transcription), + text=init_lang_text, + onvalue=True, + offvalue=False, + command=self.checkbox_input_speaker_threshold_check_callback, + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.checkbox_input_speaker_threshold_check.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + + self.progressBar_input_speaker_energy_threshold = CTkProgressBar( + self.tabview_config.tab(config_tab_title_transcription), + corner_radius=0 + ) + self.progressBar_input_speaker_energy_threshold.grid(row=row, column=1, columnspan=1, padx=padx, pady=5, sticky="nsew") + self.progressBar_input_speaker_energy_threshold.set(0) + + ## checkbox input speaker dynamic energy threshold + row +=1 + self.label_input_speaker_dynamic_energy_threshold = CTkLabel( + self.tabview_config.tab(config_tab_title_transcription), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_input_speaker_dynamic_energy_threshold.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + self.checkbox_input_speaker_dynamic_energy_threshold = CTkCheckBox( + self.tabview_config.tab(config_tab_title_transcription), + text="", + onvalue=True, + offvalue=False, + command=self.checkbox_input_speaker_dynamic_energy_threshold_callback, + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.checkbox_input_speaker_dynamic_energy_threshold.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, 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 + row +=1 + self.label_input_speaker_record_timeout = CTkLabel( + self.tabview_config.tab(config_tab_title_transcription), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_input_speaker_record_timeout.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + self.entry_input_speaker_record_timeout = CTkEntry( + self.tabview_config.tab(config_tab_title_transcription), + textvariable=StringVar(value=self.parent.INPUT_SPEAKER_RECORD_TIMEOUT), + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.entry_input_speaker_record_timeout.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") + self.entry_input_speaker_record_timeout.bind("", self.entry_input_speaker_record_timeout_callback) + + ## entry input speaker phrase timeout + row +=1 + self.label_input_speaker_phrase_timeout = CTkLabel( + self.tabview_config.tab(config_tab_title_transcription), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_input_speaker_phrase_timeout.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + self.entry_input_speaker_phrase_timeout = CTkEntry( + self.tabview_config.tab(config_tab_title_transcription), + textvariable=StringVar(value=self.parent.INPUT_SPEAKER_PHRASE_TIMEOUT), + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.entry_input_speaker_phrase_timeout.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") + self.entry_input_speaker_phrase_timeout.bind("", self.entry_input_speaker_phrase_timeout_callback) + + ## entry input speaker max phrases + row +=1 + self.label_input_speaker_max_phrases = CTkLabel( + self.tabview_config.tab(config_tab_title_transcription), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_input_speaker_max_phrases.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + self.entry_input_speaker_max_phrases = CTkEntry( + self.tabview_config.tab(config_tab_title_transcription), + textvariable=StringVar(value=self.parent.INPUT_SPEAKER_MAX_PHRASES), + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.entry_input_speaker_max_phrases.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") + self.entry_input_speaker_max_phrases.bind("", self.entry_input_speaker_max_phrases_callback) + + # tab Parameter + ## entry ip address + row = 0 + padx = 5 + pady = 1 + self.label_ip_address = CTkLabel( + self.tabview_config.tab(config_tab_title_parameter), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_ip_address.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + self.entry_ip_address = CTkEntry( + self.tabview_config.tab(config_tab_title_parameter), + textvariable=StringVar(value=self.parent.OSC_IP_ADDRESS), + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.entry_ip_address.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") + self.entry_ip_address.bind("", self.entry_ip_address_callback) + + ## entry port + row +=1 + self.label_port = CTkLabel( + self.tabview_config.tab(config_tab_title_parameter), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_port.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + self.entry_port = CTkEntry( + self.tabview_config.tab(config_tab_title_parameter), + textvariable=StringVar(value=self.parent.OSC_PORT), + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.entry_port.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") + self.entry_port.bind("", self.entry_port_callback) + + ## entry authkey + row +=1 + self.label_authkey = CTkLabel( + self.tabview_config.tab(config_tab_title_parameter), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_authkey.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + self.entry_authkey = CTkEntry( + self.tabview_config.tab(config_tab_title_parameter), + textvariable=StringVar(value=self.parent.AUTH_KEYS["DeepL(auth)"]), + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.entry_authkey.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") + self.entry_authkey.bind("", self.entry_authkey_callback) + + ## entry message format + row +=1 + self.label_message_format = CTkLabel( + self.tabview_config.tab(config_tab_title_parameter), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_message_format.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + self.entry_message_format = CTkEntry( + self.tabview_config.tab(config_tab_title_parameter), + textvariable=StringVar(value=self.parent.MESSAGE_FORMAT), + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.entry_message_format.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") + self.entry_message_format.bind("", self.entry_message_format_callback) + + # tab Others + ## checkbox auto clear chat box + row += 1 + self.label_checkbox_auto_clear_chatbox = CTkLabel( + self.tabview_config.tab(config_tab_title_others), + text=init_lang_text, + fg_color="transparent", + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.label_checkbox_auto_clear_chatbox.grid(row=row, column=0, columnspan=1, padx=padx, pady=pady, sticky="nsw") + self.checkbox_auto_clear_chatbox = CTkCheckBox( + self.tabview_config.tab(config_tab_title_others), + text="", + onvalue=True, + offvalue=False, + command=self.checkbox_auto_clear_chatbox_callback, + font=CTkFont(family=self.parent.FONT_FAMILY) + ) + self.checkbox_auto_clear_chatbox.grid(row=row, column=1, columnspan=1, padx=padx, pady=pady, sticky="nsew") + if self.parent.ENABLE_AUTO_CLEAR_CHATBOX is True: + self.checkbox_auto_clear_chatbox.select() + else: + self.checkbox_auto_clear_chatbox.deselect() + + widget_config_window_label_setter(self, language_yaml_data) \ No newline at end of file