diff --git a/VRCT.py b/VRCT.py index 7a2ae8cf..cc028db9 100644 --- a/VRCT.py +++ b/VRCT.py @@ -1,27 +1,29 @@ -import os -import json -import queue +from os import path as os_path +from json import load as json_load +from json import dump as json_dump +from queue import Queue import tkinter as tk import customtkinter -from PIL import Image +from customtkinter import CTk, CTkFrame, CTkCheckBox, CTkFont, CTkButton, CTkImage, CTkTabview, CTkTextbox, CTkEntry +from PIL.Image import open as Image_open from flashtext import KeywordProcessor -import utils -import osc_tools -import window_config -import window_information -import languages -import audio_utils -import audio_recorder -import audio_transcriber -import translation +from utils import save_json, print_textbox, thread_fnc +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 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 +from translation import Translator -class App(customtkinter.CTk): +class App(CTk): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # init instance - self.translator = translation.Translator() + self.translator = Translator() self.keyword_processor = KeywordProcessor() # init config @@ -39,14 +41,14 @@ class App(customtkinter.CTk): self.FONT_FAMILY = "Yu Gothic UI" self.ENABLE_AUTO_CLEAR_CHATBOX = False ## Translation - self.CHOICE_TRANSLATOR = languages.translators[0] - self.INPUT_SOURCE_LANG = list(languages.translation_lang[self.CHOICE_TRANSLATOR].keys())[0] - self.INPUT_TARGET_LANG = list(languages.translation_lang[self.CHOICE_TRANSLATOR].keys())[1] - self.OUTPUT_SOURCE_LANG = list(languages.translation_lang[self.CHOICE_TRANSLATOR].keys())[1] - self.OUTPUT_TARGET_LANG = list(languages.translation_lang[self.CHOICE_TRANSLATOR].keys())[0] + self.CHOICE_TRANSLATOR = translators[0] + self.INPUT_SOURCE_LANG = list(translation_lang[self.CHOICE_TRANSLATOR].keys())[0] + self.INPUT_TARGET_LANG = list(translation_lang[self.CHOICE_TRANSLATOR].keys())[1] + self.OUTPUT_SOURCE_LANG = list(translation_lang[self.CHOICE_TRANSLATOR].keys())[1] + self.OUTPUT_TARGET_LANG = list(translation_lang[self.CHOICE_TRANSLATOR].keys())[0] ## Transcription Send - self.CHOICE_MIC_DEVICE = audio_utils.get_default_input_device()["name"] - self.INPUT_MIC_VOICE_LANGUAGE = list(languages.transcription_lang.keys())[0] + self.CHOICE_MIC_DEVICE = get_default_input_device()["name"] + self.INPUT_MIC_VOICE_LANGUAGE = list(transcription_lang.keys())[0] self.INPUT_MIC_ENERGY_THRESHOLD = 300 self.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD = True self.INPUT_MIC_RECORD_TIMEOUT = 3 @@ -54,8 +56,8 @@ class App(customtkinter.CTk): self.INPUT_MIC_MAX_PHRASES = 10 self.INPUT_MIC_WORD_FILTER = [] ## Transcription Receive - self.CHOICE_SPEAKER_DEVICE = audio_utils.get_default_output_device()["name"] - self.INPUT_SPEAKER_VOICE_LANGUAGE = list(languages.transcription_lang.keys())[1] + self.CHOICE_SPEAKER_DEVICE = get_default_output_device()["name"] + self.INPUT_SPEAKER_VOICE_LANGUAGE = list(transcription_lang.keys())[1] self.INPUT_SPEAKER_ENERGY_THRESHOLD = 300 self.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD = True self.INPUT_SPEAKER_RECORD_TIMEOUT = 3 @@ -73,9 +75,9 @@ class App(customtkinter.CTk): self.MESSAGE_FORMAT = "[message]([translation])" # load config - if os.path.isfile(self.PATH_CONFIG) is not False: + if os_path.isfile(self.PATH_CONFIG) is not False: with open(self.PATH_CONFIG, 'r') as fp: - config = json.load(fp) + config = json_load(fp) # main window if "ENABLE_TRANSLATION" in config.keys(): if type(config["ENABLE_TRANSLATION"]) is bool: @@ -113,24 +115,24 @@ class App(customtkinter.CTk): if config["CHOICE_TRANSLATOR"] in list(self.translator.translator_status.keys()): self.CHOICE_TRANSLATOR = config["CHOICE_TRANSLATOR"] if "INPUT_SOURCE_LANG" in config.keys(): - if config["INPUT_SOURCE_LANG"] in list(languages.translation_lang[self.CHOICE_TRANSLATOR].keys()): + if config["INPUT_SOURCE_LANG"] in list(translation_lang[self.CHOICE_TRANSLATOR].keys()): self.INPUT_SOURCE_LANG = config["INPUT_SOURCE_LANG"] if "INPUT_TARGET_LANG" in config.keys(): - if config["INPUT_SOURCE_LANG"] in list(languages.translation_lang[self.CHOICE_TRANSLATOR].keys()): + if config["INPUT_SOURCE_LANG"] in list(translation_lang[self.CHOICE_TRANSLATOR].keys()): self.INPUT_TARGET_LANG = config["INPUT_TARGET_LANG"] if "OUTPUT_SOURCE_LANG" in config.keys(): - if config["INPUT_SOURCE_LANG"] in list(languages.translation_lang[self.CHOICE_TRANSLATOR].keys()): + if config["INPUT_SOURCE_LANG"] in list(translation_lang[self.CHOICE_TRANSLATOR].keys()): self.OUTPUT_SOURCE_LANG = config["OUTPUT_SOURCE_LANG"] if "OUTPUT_TARGET_LANG" in config.keys(): - if config["INPUT_SOURCE_LANG"] in list(languages.translation_lang[self.CHOICE_TRANSLATOR].keys()): + if config["INPUT_SOURCE_LANG"] in list(translation_lang[self.CHOICE_TRANSLATOR].keys()): self.OUTPUT_TARGET_LANG = config["OUTPUT_TARGET_LANG"] # Transcription if "CHOICE_MIC_DEVICE" in config.keys(): - if config["CHOICE_MIC_DEVICE"] in [device["name"] for device in audio_utils.get_input_device_list()]: + if config["CHOICE_MIC_DEVICE"] in [device["name"] for device in get_input_device_list()]: self.CHOICE_MIC_DEVICE = config["CHOICE_MIC_DEVICE"] if "INPUT_MIC_VOICE_LANGUAGE" in config.keys(): - if config["INPUT_MIC_VOICE_LANGUAGE"] in list(languages.transcription_lang.keys()): + if config["INPUT_MIC_VOICE_LANGUAGE"] in list(transcription_lang.keys()): self.INPUT_MIC_VOICE_LANGUAGE = config["INPUT_MIC_VOICE_LANGUAGE"] if "INPUT_MIC_ENERGY_THRESHOLD" in config.keys(): if type(config["INPUT_MIC_ENERGY_THRESHOLD"]) is int: @@ -152,10 +154,10 @@ class App(customtkinter.CTk): self.INPUT_MIC_WORD_FILTER = config["INPUT_MIC_WORD_FILTER"] if "CHOICE_SPEAKER_DEVICE" in config.keys(): - if config["CHOICE_SPEAKER_DEVICE"] in [device["name"] for device in audio_utils.get_output_device_list()]: + if config["CHOICE_SPEAKER_DEVICE"] in [device["name"] for device in get_output_device_list()]: self.CHOICE_SPEAKER_DEVICE = config["CHOICE_SPEAKER_DEVICE"] if "INPUT_SPEAKER_VOICE_LANGUAGE" in config.keys(): - if config["INPUT_SPEAKER_VOICE_LANGUAGE"] in list(languages.transcription_lang.keys()): + if config["INPUT_SPEAKER_VOICE_LANGUAGE"] in list(transcription_lang.keys()): self.INPUT_SPEAKER_VOICE_LANGUAGE = config["INPUT_SPEAKER_VOICE_LANGUAGE"] if "INPUT_SPEAKER_ENERGY_THRESHOLD" in config.keys(): if type(config["INPUT_SPEAKER_ENERGY_THRESHOLD"]) is int: @@ -226,14 +228,14 @@ class App(customtkinter.CTk): "AUTH_KEYS": self.AUTH_KEYS, "MESSAGE_FORMAT": self.MESSAGE_FORMAT, } - json.dump(config, fp, indent=4) + json_dump(config, fp, indent=4) ## set UI theme customtkinter.set_appearance_mode(self.APPEARANCE_THEME) customtkinter.set_default_color_theme("blue") # init main window - self.iconbitmap(os.path.join(os.path.dirname(__file__), "img", "app.ico")) + self.iconbitmap(os_path.join(os_path.dirname(__file__), "img", "app.ico")) self.title("VRCT") self.geometry(f"{400}x{175}") self.minsize(400, 175) @@ -241,84 +243,84 @@ class App(customtkinter.CTk): self.grid_rowconfigure(0, weight=1) # add sidebar left - self.sidebar_frame = customtkinter.CTkFrame(self, corner_radius=0) + self.sidebar_frame = CTkFrame(self, corner_radius=0) self.sidebar_frame.grid(row=0, column=0, rowspan=4, sticky="nsw") self.sidebar_frame.grid_rowconfigure(5, weight=1) # add checkbox translation - self.checkbox_translation = customtkinter.CTkCheckBox( + self.checkbox_translation = CTkCheckBox( self.sidebar_frame, text="translation", onvalue=True, offvalue=False, command=self.checkbox_translation_callback, - font=customtkinter.CTkFont(family=self.FONT_FAMILY) + font=CTkFont(family=self.FONT_FAMILY) ) self.checkbox_translation.grid(row=0, column=0, columnspan=2 ,padx=10, pady=(5, 5), sticky="we") # add checkbox transcription send - self.checkbox_transcription_send = customtkinter.CTkCheckBox( + self.checkbox_transcription_send = CTkCheckBox( self.sidebar_frame, text="voice2chatbox", onvalue=True, offvalue=False, command=self.checkbox_transcription_send_callback, - font=customtkinter.CTkFont(family=self.FONT_FAMILY) + font=CTkFont(family=self.FONT_FAMILY) ) self.checkbox_transcription_send.grid(row=1, column=0, columnspan=2 ,padx=10, pady=(5, 5), sticky="we") # add checkbox transcription receive - self.checkbox_transcription_receive = customtkinter.CTkCheckBox( + self.checkbox_transcription_receive = CTkCheckBox( self.sidebar_frame, text="speaker2log", onvalue=True, offvalue=False, command=self.checkbox_transcription_receive_callback, - font=customtkinter.CTkFont(family=self.FONT_FAMILY) + font=CTkFont(family=self.FONT_FAMILY) ) self.checkbox_transcription_receive.grid(row=2, column=0, columnspan=2 ,padx=10, pady=(5, 5), sticky="we") # add checkbox foreground - self.checkbox_foreground = customtkinter.CTkCheckBox( + self.checkbox_foreground = CTkCheckBox( self.sidebar_frame, text="foreground", onvalue=True, offvalue=False, command=self.checkbox_foreground_callback, - font=customtkinter.CTkFont(family=self.FONT_FAMILY) + font=CTkFont(family=self.FONT_FAMILY) ) self.checkbox_foreground.grid(row=3, column=0, columnspan=2 ,padx=10, pady=(5, 5), sticky="we") # add button information - self.button_information = customtkinter.CTkButton( + self.button_information = CTkButton( self.sidebar_frame, text="", width=25, command=self.button_information_callback, - image=customtkinter.CTkImage(Image.open(os.path.join(os.path.dirname(__file__), "img", "info-icon-white.png"))) + 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 = customtkinter.CTkButton( + self.button_config = CTkButton( self.sidebar_frame, text="", width=25, command=self.button_config_callback, - image=customtkinter.CTkImage(Image.open(os.path.join(os.path.dirname(__file__), "img", "config-icon-white.png"))) + image=CTkImage(Image_open(os_path.join(os_path.dirname(__file__), "img", "config-icon-white.png"))) ) self.button_config.grid(row=5, column=1, padx=(5, 10), pady=(5, 5), sticky="wse") self.config_window = None # add tabview textbox - self.tabview_logs = customtkinter.CTkTabview(master=self) + 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=customtkinter.CTkFont(family=self.FONT_FAMILY)) + 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) @@ -331,42 +333,42 @@ class App(customtkinter.CTk): self.tabview_logs.configure(fg_color="transparent") # add textbox message log - self.textbox_message_log = customtkinter.CTkTextbox( + self.textbox_message_log = CTkTextbox( self.tabview_logs.tab("log"), - font=customtkinter.CTkFont(family=self.FONT_FAMILY) + 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 = customtkinter.CTkTextbox( + self.textbox_message_send_log = CTkTextbox( self.tabview_logs.tab("send"), - font=customtkinter.CTkFont(family=self.FONT_FAMILY) + 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 = customtkinter.CTkTextbox( + self.textbox_message_receive_log = CTkTextbox( self.tabview_logs.tab("receive"), - font=customtkinter.CTkFont(family=self.FONT_FAMILY) + 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 = customtkinter.CTkTextbox( + self.textbox_message_system_log = CTkTextbox( self.tabview_logs.tab("system"), - font=customtkinter.CTkFont(family=self.FONT_FAMILY) + 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') # add entry message box - self.entry_message_box = customtkinter.CTkEntry( + self.entry_message_box = CTkEntry( self, placeholder_text="message", - font=customtkinter.CTkFont(family=self.FONT_FAMILY) + font=CTkFont(family=self.FONT_FAMILY) ) self.entry_message_box.grid(row=1, column=1, columnspan=2, padx=5, pady=(5, 10), sticky="nsew") @@ -374,8 +376,8 @@ class App(customtkinter.CTk): ## set translator if self.translator.authentication(self.CHOICE_TRANSLATOR, self.AUTH_KEYS[self.CHOICE_TRANSLATOR]) is False: # error update Auth key - utils.print_textbox(self.textbox_message_log, "Auth Key or language setting is incorrect", "ERROR") - utils.print_textbox(self.textbox_message_system_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") ## set checkbox enable translation if self.ENABLE_TRANSLATION: @@ -426,7 +428,7 @@ class App(customtkinter.CTk): def button_config_callback(self): if self.config_window is None or not self.config_window.winfo_exists(): - self.config_window = window_config.ToplevelWindowConfig(self) + self.config_window = ToplevelWindowConfig(self) self.checkbox_translation.configure(state="disabled") self.checkbox_transcription_send.configure(state="disabled") self.checkbox_transcription_receive.configure(state="disabled") @@ -434,41 +436,41 @@ class App(customtkinter.CTk): def button_information_callback(self): if self.information_window is None or not self.information_window.winfo_exists(): - self.information_window = window_information.ToplevelWindowInformation(self) + self.information_window = ToplevelWindowInformation(self) self.information_window.focus() 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"]) - utils.print_textbox(self.textbox_message_log, "Start translation", "INFO") - utils.print_textbox(self.textbox_message_system_log, "Start translation", "INFO") + 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"]) - utils.print_textbox(self.textbox_message_log, "Stop translation", "INFO") - utils.print_textbox(self.textbox_message_system_log, "Stop translation", "INFO") - utils.save_json(self.PATH_CONFIG, "ENABLE_TRANSLATION", self.ENABLE_TRANSLATION) + 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 checkbox_transcription_send_callback(self): self.ENABLE_TRANSCRIPTION_SEND = self.checkbox_transcription_send.get() if self.ENABLE_TRANSCRIPTION_SEND is True: self.button_config.configure(state="disabled", fg_color=["gray92", "gray14"]) - self.mic_audio_queue = queue.Queue() - mic_device = [device for device in audio_utils.get_input_device_list() if device["name"] == self.CHOICE_MIC_DEVICE][0] - self.mic_audio_recorder = audio_recorder.SelectedMicRecorder( + self.mic_audio_queue = Queue() + mic_device = [device for device in get_input_device_list() if device["name"] == self.CHOICE_MIC_DEVICE][0] + self.mic_audio_recorder = SelectedMicRecorder( mic_device, self.INPUT_MIC_ENERGY_THRESHOLD, self.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD, self.INPUT_MIC_RECORD_TIMEOUT, ) self.mic_audio_recorder.record_into_queue(self.mic_audio_queue) - self.mic_transcriber = audio_transcriber.AudioTranscriber( + self.mic_transcriber = AudioTranscriber( speaker=False, source=self.mic_audio_recorder.source, - language=languages.transcription_lang[self.INPUT_MIC_VOICE_LANGUAGE], + language=transcription_lang[self.INPUT_MIC_VOICE_LANGUAGE], phrase_timeout=self.INPUT_MIC_PHRASE_TIMEOUT, max_phrases=self.INPUT_MIC_MAX_PHRASES, ) @@ -478,16 +480,16 @@ class App(customtkinter.CTk): if len(message) > 0: # word filter if len(self.keyword_processor.extract_keywords(message)) != 0: - utils.print_textbox(self.textbox_message_log, f"Detect WordFilter :{message}", "INFO") - utils.print_textbox(self.textbox_message_system_log, f"Detect WordFilter :{message}", "INFO") + print_textbox(self.textbox_message_log, f"Detect WordFilter :{message}", "INFO") + print_textbox(self.textbox_message_system_log, f"Detect WordFilter :{message}", "INFO") return # translate if self.checkbox_translation.get() is False: voice_message = f"{message}" elif self.translator.translator_status[self.CHOICE_TRANSLATOR] is False: - utils.print_textbox(self.textbox_message_log, "Auth Key or language setting is incorrect", "ERROR") - utils.print_textbox(self.textbox_message_system_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: result = self.translator.translate( @@ -500,49 +502,49 @@ class App(customtkinter.CTk): if self.checkbox_transcription_send.get() is True: # send OSC message - osc_tools.send_message(voice_message, self.OSC_IP_ADDRESS, self.OSC_PORT) + send_message(voice_message, self.OSC_IP_ADDRESS, self.OSC_PORT) # update textbox message log - utils.print_textbox(self.textbox_message_log, f"{voice_message}", "SEND") - utils.print_textbox(self.textbox_message_send_log, f"{voice_message}", "SEND") + print_textbox(self.textbox_message_log, f"{voice_message}", "SEND") + print_textbox(self.textbox_message_send_log, f"{voice_message}", "SEND") - self.mic_print_transcript = utils.thread_fnc(mic_transcript_to_chatbox) + self.mic_print_transcript = thread_fnc(mic_transcript_to_chatbox) self.mic_print_transcript.daemon = True self.mic_print_transcript.start() - utils.print_textbox(self.textbox_message_log, "Start voice2chatbox", "INFO") - utils.print_textbox(self.textbox_message_system_log, "Start voice2chatbox", "INFO") + print_textbox(self.textbox_message_log, "Start voice2chatbox", "INFO") + print_textbox(self.textbox_message_system_log, "Start voice2chatbox", "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"]) - if isinstance(self.mic_print_transcript, utils.thread_fnc): + 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 - utils.print_textbox(self.textbox_message_log, "Stop voice2chatbox", "INFO") - utils.print_textbox(self.textbox_message_system_log, "Stop voice2chatbox", "INFO") - utils.save_json(self.PATH_CONFIG, "ENABLE_TRANSCRIPTION_SEND", self.ENABLE_TRANSCRIPTION_SEND) + print_textbox(self.textbox_message_log, "Stop voice2chatbox", "INFO") + print_textbox(self.textbox_message_system_log, "Stop voice2chatbox", "INFO") + save_json(self.PATH_CONFIG, "ENABLE_TRANSCRIPTION_SEND", self.ENABLE_TRANSCRIPTION_SEND) def checkbox_transcription_receive_callback(self): self.ENABLE_TRANSCRIPTION_RECEIVE = self.checkbox_transcription_receive.get() if self.ENABLE_TRANSCRIPTION_RECEIVE is True: self.button_config.configure(state="disabled", fg_color=["gray92", "gray14"]) - self.spk_audio_queue = queue.Queue() - spk_device = [device for device in audio_utils.get_output_device_list() if device["name"] == self.CHOICE_SPEAKER_DEVICE][0] - self.spk_audio_recorder = audio_recorder.SelectedSpeakerRecorder( + 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 = audio_transcriber.AudioTranscriber( + self.spk_transcriber = AudioTranscriber( speaker=True, source=self.spk_audio_recorder.source, - language=languages.transcription_lang[self.INPUT_SPEAKER_VOICE_LANGUAGE], + language=transcription_lang[self.INPUT_SPEAKER_VOICE_LANGUAGE], phrase_timeout=self.INPUT_SPEAKER_PHRASE_TIMEOUT, max_phrases=self.INPUT_SPEAKER_MAX_PHRASES, ) @@ -555,8 +557,8 @@ class App(customtkinter.CTk): if self.checkbox_translation.get() is False: voice_message = f"{message}" elif self.translator.translator_status[self.CHOICE_TRANSLATOR] is False: - utils.print_textbox(self.textbox_message_log, "Auth Key or language setting is incorrect", "ERROR") - utils.print_textbox(self.textbox_message_system_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: result = self.translator.translate( @@ -567,47 +569,47 @@ class App(customtkinter.CTk): ) voice_message = self.MESSAGE_FORMAT.replace("[message]", message).replace("[translation]", result) # send OSC message - # osc_tools.send_message(voice_message, self.OSC_IP_ADDRESS, self.OSC_PORT) + # send_message(voice_message, self.OSC_IP_ADDRESS, self.OSC_PORT) if self.checkbox_transcription_receive.get() is True: # update textbox message receive log - utils.print_textbox(self.textbox_message_log, f"{voice_message}", "RECEIVE") - utils.print_textbox(self.textbox_message_receive_log, f"{voice_message}", "RECEIVE") + print_textbox(self.textbox_message_log, f"{voice_message}", "RECEIVE") + print_textbox(self.textbox_message_receive_log, f"{voice_message}", "RECEIVE") - self.spk_print_transcript = utils.thread_fnc(spk_transcript_to_textbox) + self.spk_print_transcript = thread_fnc(spk_transcript_to_textbox) self.spk_print_transcript.daemon = True self.spk_print_transcript.start() - utils.print_textbox(self.textbox_message_log, "Start speaker2log", "INFO") - utils.print_textbox(self.textbox_message_system_log, "Start speaker2log", "INFO") + print_textbox(self.textbox_message_log, "Start speaker2log", "INFO") + print_textbox(self.textbox_message_system_log, "Start speaker2log", "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"]) - if isinstance(self.spk_print_transcript, utils.thread_fnc): + 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 - utils.print_textbox(self.textbox_message_log, "Stop speaker2log", "INFO") - utils.print_textbox(self.textbox_message_system_log, "Stop speaker2log", "INFO") - utils.save_json(self.PATH_CONFIG, "ENABLE_TRANSCRIPTION_RECEIVE", self.ENABLE_TRANSCRIPTION_RECEIVE) + print_textbox(self.textbox_message_log, "Stop speaker2log", "INFO") + print_textbox(self.textbox_message_system_log, "Stop speaker2log", "INFO") + save_json(self.PATH_CONFIG, "ENABLE_TRANSCRIPTION_RECEIVE", self.ENABLE_TRANSCRIPTION_RECEIVE) def checkbox_foreground_callback(self): self.ENABLE_FOREGROUND = self.checkbox_foreground.get() if self.ENABLE_FOREGROUND: self.attributes("-topmost", True) - utils.print_textbox(self.textbox_message_log, "Start foreground", "INFO") - utils.print_textbox(self.textbox_message_system_log, "Start foreground", "INFO") + print_textbox(self.textbox_message_log, "Start foreground", "INFO") + print_textbox(self.textbox_message_system_log, "Start foreground", "INFO") else: self.attributes("-topmost", False) - utils.print_textbox(self.textbox_message_log, "Stop foreground", "INFO") - utils.print_textbox(self.textbox_message_system_log, "Stop foreground", "INFO") - utils.save_json(self.PATH_CONFIG, "ENABLE_FOREGROUND", self.ENABLE_FOREGROUND) + 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 entry_message_box_press_key_enter(self, event): # send OSC typing - osc_tools.send_typing(False, self.OSC_IP_ADDRESS, self.OSC_PORT) + send_typing(False, self.OSC_IP_ADDRESS, self.OSC_PORT) if self.ENABLE_FOREGROUND: self.attributes("-topmost", True) @@ -618,8 +620,8 @@ class App(customtkinter.CTk): if self.checkbox_translation.get() is False: chat_message = f"{message}" elif self.translator.translator_status[self.CHOICE_TRANSLATOR] is False: - utils.print_textbox(self.textbox_message_log, "Auth Key or language setting is incorrect", "ERROR") - utils.print_textbox(self.textbox_message_system_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") chat_message = f"{message}" else: result = self.translator.translate( @@ -631,11 +633,11 @@ class App(customtkinter.CTk): chat_message = self.MESSAGE_FORMAT.replace("[message]", message).replace("[translation]", result) # send OSC message - osc_tools.send_message(chat_message, self.OSC_IP_ADDRESS, self.OSC_PORT) + send_message(chat_message, self.OSC_IP_ADDRESS, self.OSC_PORT) # update textbox message log - utils.print_textbox(self.textbox_message_log, f"{chat_message}", "SEND") - utils.print_textbox(self.textbox_message_send_log, f"{chat_message}", "SEND") + print_textbox(self.textbox_message_log, f"{chat_message}", "SEND") + print_textbox(self.textbox_message_send_log, f"{chat_message}", "SEND") # delete message in entry message box if self.ENABLE_AUTO_CLEAR_CHATBOX == True: @@ -643,13 +645,13 @@ class App(customtkinter.CTk): def entry_message_box_press_key_any(self, event): # send OSC typing - osc_tools.send_typing(True, self.OSC_IP_ADDRESS, self.OSC_PORT) + send_typing(True, self.OSC_IP_ADDRESS, self.OSC_PORT) if self.ENABLE_FOREGROUND: self.attributes("-topmost", False) def entry_message_box_leave(self, event): # send OSC typing - osc_tools.send_typing(False, self.OSC_IP_ADDRESS, self.OSC_PORT) + send_typing(False, self.OSC_IP_ADDRESS, self.OSC_PORT) if self.ENABLE_FOREGROUND: self.attributes("-topmost", True) diff --git a/audio_recorder.py b/audio_recorder.py index 34f990e5..0b146677 100644 --- a/audio_recorder.py +++ b/audio_recorder.py @@ -1,10 +1,10 @@ -import speech_recognition as sr -import pyaudiowpatch as pyaudio +from speech_recognition import Recognizer, Microphone +from pyaudiowpatch import get_sample_size, paInt16 from datetime import datetime class BaseRecorder: def __init__(self, source, energy_threshold, dynamic_energy_threshold, record_timeout): - self.recorder = sr.Recognizer() + self.recorder = Recognizer() self.recorder.energy_threshold = energy_threshold self.recorder.dynamic_energy_threshold = dynamic_energy_threshold self.record_timeout = record_timeout @@ -20,14 +20,14 @@ class BaseRecorder: self.recorder.adjust_for_ambient_noise(self.source) def record_into_queue(self, audio_queue): - def record_callback(_, audio:sr.AudioData) -> None: + def record_callback(_, audio): audio_queue.put((audio.get_raw_data(), datetime.now())) self.stop = self.recorder.listen_in_background(self.source, record_callback, phrase_time_limit=self.record_timeout) class SelectedMicRecorder(BaseRecorder): def __init__(self, device, energy_threshold, dynamic_energy_threshold, record_timeout): - source=sr.Microphone( + source=Microphone( device_index=device['index'], sample_rate=int(device["defaultSampleRate"]), ) @@ -37,10 +37,10 @@ class SelectedMicRecorder(BaseRecorder): class SelectedSpeakerRecorder(BaseRecorder): def __init__(self, device, energy_threshold, dynamic_energy_threshold, record_timeout): - source = sr.Microphone(speaker=True, + source = Microphone(speaker=True, device_index= device["index"], sample_rate=int(device["defaultSampleRate"]), - chunk_size=pyaudio.get_sample_size(pyaudio.paInt16), + chunk_size=get_sample_size(paInt16), channels=device["maxInputChannels"] ) super().__init__(source=source, energy_threshold=energy_threshold, dynamic_energy_threshold=dynamic_energy_threshold, record_timeout=record_timeout) diff --git a/audio_transcriber.py b/audio_transcriber.py index 695ee55f..aadd6adf 100644 --- a/audio_transcriber.py +++ b/audio_transcriber.py @@ -1,9 +1,9 @@ -import io -import threading +from io import BytesIO +from threading import Event import wave -import speech_recognition as sr +from speech_recognition import Recognizer, AudioData, AudioFile from datetime import timedelta -import pyaudiowpatch as pyaudio +from pyaudiowpatch import get_sample_size, paInt16 PHRASE_TIMEOUT = 3 MAX_PHRASES = 10 @@ -15,8 +15,8 @@ class AudioTranscriber: self.phrase_timeout = phrase_timeout self.max_phrases = max_phrases self.transcript_data = [] - self.transcript_changed_event = threading.Event() - self.audio_recognizer = sr.Recognizer() + self.transcript_changed_event = Event() + self.audio_recognizer = Recognizer() self.audio_sources = { "sample_rate": source.SAMPLE_RATE, "sample_width": source.SAMPLE_WIDTH, @@ -59,19 +59,18 @@ class AudioTranscriber: source_info["last_spoken"] = time_spoken def process_mic_data(self): - audio_data = sr.AudioData(self.audio_sources["last_sample"], self.audio_sources["sample_rate"], self.audio_sources["sample_width"]) + audio_data = AudioData(self.audio_sources["last_sample"], self.audio_sources["sample_rate"], self.audio_sources["sample_width"]) return audio_data def process_speaker_data(self): - temp_file = io.BytesIO() + temp_file = BytesIO() with wave.open(temp_file, 'wb') as wf: wf.setnchannels(self.audio_sources["channels"]) - p = pyaudio.PyAudio() - wf.setsampwidth(p.get_sample_size(pyaudio.paInt16)) + wf.setsampwidth(get_sample_size(paInt16)) wf.setframerate(self.audio_sources["sample_rate"]) wf.writeframes(self.audio_sources["last_sample"]) temp_file.seek(0) - with sr.AudioFile(temp_file) as source: + with AudioFile(temp_file) as source: audio = self.audio_recognizer.record(source) return audio diff --git a/audio_utils.py b/audio_utils.py index fd56ae5c..b6d0d6e0 100644 --- a/audio_utils.py +++ b/audio_utils.py @@ -1,9 +1,9 @@ -import pyaudiowpatch as pyaudio +from pyaudiowpatch import PyAudio, paWASAPI def get_input_device_list(): devices = [] - with pyaudio.PyAudio() as p: - wasapi_info = p.get_host_api_info_by_type(pyaudio.paWASAPI) + with PyAudio() as p: + wasapi_info = p.get_host_api_info_by_type(paWASAPI) for host_index in range(0, p.get_host_api_count()): for device_index in range(0, p. get_host_api_info_by_index(host_index)['deviceCount']): device = p.get_device_info_by_host_api_device_index(host_index, device_index) @@ -13,16 +13,16 @@ def get_input_device_list(): def get_output_device_list(): devices =[] - with pyaudio.PyAudio() as p: - wasapi_info = p.get_host_api_info_by_type(pyaudio.paWASAPI) + with PyAudio() as p: + wasapi_info = p.get_host_api_info_by_type(paWASAPI) for device in p.get_loopback_device_info_generator(): if device["hostApi"] == wasapi_info["index"] and device["isLoopbackDevice"] is True: devices.append(device) return devices def get_default_input_device(): - with pyaudio.PyAudio() as p: - wasapi_info = p.get_host_api_info_by_type(pyaudio.paWASAPI) + with PyAudio() as p: + wasapi_info = p.get_host_api_info_by_type(paWASAPI) defaultInputDevice = wasapi_info["defaultInputDevice"] for host_index in range(0, p.get_host_api_count()): @@ -33,8 +33,8 @@ def get_default_input_device(): return default_device def get_default_output_device(): - with pyaudio.PyAudio() as p: - wasapi_info = p.get_host_api_info_by_type(pyaudio.paWASAPI) + with PyAudio() as p: + wasapi_info = p.get_host_api_info_by_type(paWASAPI) defaultOutputDevice = wasapi_info["defaultOutputDevice"] for host_index in range(0, p.get_host_api_count()): diff --git a/translation.py b/translation.py index 50eda54e..8eacf8a6 100644 --- a/translation.py +++ b/translation.py @@ -1,13 +1,13 @@ -import deepl -import deepl_translate -import translators as ts -import languages +from deepl import Translator as deepl_Translator +from deepl_translate import translate as deepl_web_Translator +from translators import translate_text as other_web_Translator +from languages import translators, translation_lang # Translator class Translator(): def __init__(self): self.translator_status = {} - for translator in languages.translators: + for translator in translators: self.translator_status[translator] = False self.deepl_client = None @@ -18,7 +18,7 @@ class Translator(): self.translator_status["DeepL(web)"] = True result = True elif translator_name == "DeepL(auth)": - self.deepl_client = deepl.Translator(authkey) + self.deepl_client = deepl_Translator(authkey) self.deepl_client.translate_text(" ", target_lang="EN-US") self.translator_status["DeepL(auth)"] = True result = True @@ -35,10 +35,10 @@ class Translator(): def translate(self, translator_name, source_language, target_language, message): result = "" try: - source_language=languages.translation_lang[translator_name][source_language] - target_language=languages.translation_lang[translator_name][target_language] + source_language=translation_lang[translator_name][source_language] + target_language=translation_lang[translator_name][target_language] if translator_name == "DeepL(web)": - result = deepl_translate.translate( + result = deepl_web_Translator( source_language=source_language, target_language=target_language, text=message @@ -50,14 +50,14 @@ class Translator(): target_lang=target_language, ).text elif translator_name == "Google(web)": - result = ts.translate_text( + result = other_web_Translator( query_text=message, translator="google", from_language=source_language, to_language=target_language, ) elif translator_name == "Bing(web)": - result = ts.translate_text( + result = other_web_Translator( query_text=message, translator="bing", from_language=source_language, diff --git a/utils.py b/utils.py index 473487fc..013b16c6 100644 --- a/utils.py +++ b/utils.py @@ -1,16 +1,16 @@ -import json -import datetime -import threading +from json import load, dump +from datetime import datetime +from threading import Thread, Event def save_json(path, key, value): with open(path, "r") as fp: - json_data = json.load(fp) + json_data = load(fp) json_data[key] = value with open(path, "w") as fp: - json.dump(json_data, fp, indent=4) + dump(json_data, fp, indent=4) def print_textbox(textbox, message, tags=None): - now = datetime.datetime.now() + now = datetime.now() now = now.strftime('%H:%M:%S') textbox.tag_config("ERROR", foreground="#FF0000") @@ -25,11 +25,11 @@ def print_textbox(textbox, message, tags=None): textbox.configure(state='disabled') textbox.see("end") -class thread_fnc(threading.Thread): +class thread_fnc(Thread): def __init__(self, fnc, daemon=True, *args, **kwargs): super(thread_fnc, self).__init__(daemon=daemon, *args, **kwargs) self.fnc = fnc - self._stop = threading.Event() + self._stop = Event() def stop(self): self._stop.set() def stopped(self): diff --git a/window_config.py b/window_config.py index 526fb877..1cc8a7f9 100644 --- a/window_config.py +++ b/window_config.py @@ -1,13 +1,15 @@ -import os -import tkinter as tk +from os import path as os_path +from tkinter import DoubleVar +from tkinter import font as tk_font import customtkinter +from customtkinter import CTkToplevel, CTkTabview, CTkFont, CTkLabel, CTkSlider, CTkOptionMenu, StringVar, CTkEntry, CTkCheckBox from flashtext import KeywordProcessor -import utils -import audio_utils -import languages +from utils import save_json, print_textbox +from audio_utils import get_input_device_list, get_output_device_list +from languages import translation_lang, transcription_lang -class ToplevelWindowConfig(customtkinter.CTkToplevel): +class ToplevelWindowConfig(CTkToplevel): def __init__(self, parent, *args, **kwargs): super().__init__(parent, *args, **kwargs) self.parent = parent @@ -16,11 +18,11 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): self.grid_columnconfigure(0, weight=1) self.grid_rowconfigure(0, weight=1) - self.after(200, lambda: self.iconbitmap(os.path.join(os.path.dirname(__file__), "img", "app.ico"))) + self.after(200, lambda: self.iconbitmap(os_path.join(os_path.dirname(__file__), "img", "app.ico"))) self.title("Config") # tabwiew config - self.tabview_config = customtkinter.CTkTabview(self) + 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") @@ -32,7 +34,7 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): 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=customtkinter.CTkFont(family=self.parent.FONT_FAMILY)) + self.tabview_config._segmented_button.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) self.tabview_config._segmented_button.grid(sticky="W") # tab UI @@ -40,258 +42,258 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): row = 0 padx = 5 pady = 1 - self.label_transparency = customtkinter.CTkLabel( + self.label_transparency = CTkLabel( self.tabview_config.tab("UI"), text="Transparency:", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkSlider( + self.slider_transparency = CTkSlider( self.tabview_config.tab("UI"), from_=50, to=100, command=self.slider_transparency_callback, - variable=tk.DoubleVar(value=self.parent.TRANSPARENCY), + 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 = customtkinter.CTkLabel( + self.label_appearance_theme = CTkLabel( self.tabview_config.tab("UI"), text="Appearance Theme:", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkOptionMenu( + self.optionmenu_appearance_theme = CTkOptionMenu( self.tabview_config.tab("UI"), values=["Light", "Dark", "System"], command=self.optionmenu_theme_callback, - variable=customtkinter.StringVar(value=self.parent.APPEARANCE_THEME), - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY), + 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=customtkinter.CTkFont(family=self.parent.FONT_FAMILY)) + self.optionmenu_appearance_theme._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) ## optionmenu UI scaling row += 1 - self.label_ui_scaling = customtkinter.CTkLabel( + self.label_ui_scaling = CTkLabel( self.tabview_config.tab("UI"), text="UI Scaling:", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkOptionMenu( + self.optionmenu_ui_scaling = CTkOptionMenu( self.tabview_config.tab("UI"), values=["80%", "90%", "100%", "110%", "120%"], command=self.optionmenu_ui_scaling_callback, - variable=customtkinter.StringVar(value=self.parent.UI_SCALING), - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY), + 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=customtkinter.CTkFont(family=self.parent.FONT_FAMILY)) + self.optionmenu_ui_scaling._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) ## optionmenu font family row += 1 - self.label_font_family = customtkinter.CTkLabel( + self.label_font_family = CTkLabel( self.tabview_config.tab("UI"), text="Font Family:", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkOptionMenu( + 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=customtkinter.StringVar(value=self.parent.FONT_FAMILY), - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY), + 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=customtkinter.CTkFont(family=self.parent.FONT_FAMILY)) + 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 = customtkinter.CTkLabel( + self.label_translation_translator = CTkLabel( self.tabview_config.tab("Translation"), text="Select Translator:", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY), + 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 = customtkinter.CTkOptionMenu( + 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=customtkinter.StringVar(value=self.parent.CHOICE_TRANSLATOR), - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY), + 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=customtkinter.CTkFont(family=self.parent.FONT_FAMILY)) + 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 = customtkinter.CTkLabel( + self.label_translation_input_language = CTkLabel( self.tabview_config.tab("Translation"), text="Send Language:", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkOptionMenu( + self.optionmenu_translation_input_source_language = CTkOptionMenu( self.tabview_config.tab("Translation"), command=self.optionmenu_translation_input_source_language_callback, - values=list(languages.translation_lang[self.parent.CHOICE_TRANSLATOR].keys()), - variable=customtkinter.StringVar(value=self.parent.INPUT_SOURCE_LANG), - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY), + 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=customtkinter.CTkFont(family=self.parent.FONT_FAMILY)) + 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 = customtkinter.CTkLabel( + self.label_translation_input_arrow = CTkLabel( self.tabview_config.tab("Translation"), text="-->", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkOptionMenu( + self.optionmenu_translation_input_target_language = CTkOptionMenu( self.tabview_config.tab("Translation"), command=self.optionmenu_translation_input_target_language_callback, - values=list(languages.translation_lang[self.parent.CHOICE_TRANSLATOR].keys()), - variable=customtkinter.StringVar(value=self.parent.INPUT_TARGET_LANG), - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY), + 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=customtkinter.CTkFont(family=self.parent.FONT_FAMILY)) + 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 = customtkinter.CTkLabel( + self.label_translation_output_language = CTkLabel( self.tabview_config.tab("Translation"), text="Receive Language:", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkOptionMenu( + self.optionmenu_translation_output_source_language = CTkOptionMenu( self.tabview_config.tab("Translation"), command=self.optionmenu_translation_output_source_language_callback, - values=list(languages.translation_lang[self.parent.CHOICE_TRANSLATOR].keys()), - variable=customtkinter.StringVar(value=self.parent.OUTPUT_SOURCE_LANG), - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY), + 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=customtkinter.CTkFont(family=self.parent.FONT_FAMILY)) + 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 = customtkinter.CTkLabel( + self.label_translation_output_arrow = CTkLabel( self.tabview_config.tab("Translation"), text="-->", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkOptionMenu( + self.optionmenu_translation_output_target_language = CTkOptionMenu( self.tabview_config.tab("Translation"), command=self.optionmenu_translation_output_target_language_callback, - values=list(languages.translation_lang[self.parent.CHOICE_TRANSLATOR].keys()), - variable=customtkinter.StringVar(value=self.parent.OUTPUT_TARGET_LANG), - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY), + 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=customtkinter.CTkFont(family=self.parent.FONT_FAMILY)) + 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_device = customtkinter.CTkLabel( + self.label_input_mic_device = CTkLabel( self.tabview_config.tab("Transcription"), text="Input Mic Device:", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkOptionMenu( + self.optionmenu_input_mic_device = CTkOptionMenu( self.tabview_config.tab("Transcription"), - values=[device["name"] for device in audio_utils.get_input_device_list()], + values=[device["name"] for device in get_input_device_list()], command=self.optionmenu_input_mic_device_callback, - variable=customtkinter.StringVar(value=self.parent.CHOICE_MIC_DEVICE), - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY), + 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=customtkinter.CTkFont(family=self.parent.FONT_FAMILY)) + 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 = customtkinter.CTkLabel( + self.label_input_mic_voice_language = CTkLabel( self.tabview_config.tab("Transcription"), text="Input Mic Voice Language:", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkOptionMenu( + self.optionmenu_input_mic_voice_language = CTkOptionMenu( self.tabview_config.tab("Transcription"), - values=list(languages.transcription_lang.keys()), + values=list(transcription_lang.keys()), command=self.optionmenu_input_mic_voice_language_callback, - variable=customtkinter.StringVar(value=self.parent.INPUT_MIC_VOICE_LANGUAGE), - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY), + 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=customtkinter.CTkFont(family=self.parent.FONT_FAMILY)) + self.optionmenu_input_mic_voice_language._dropdown_menu.configure(font=CTkFont(family=self.parent.FONT_FAMILY)) ## entry input mic energy threshold row +=1 - self.label_input_mic_energy_threshold = customtkinter.CTkLabel( + self.label_input_mic_energy_threshold = CTkLabel( self.tabview_config.tab("Transcription"), text="Input Mic Energy Threshold:", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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.entry_input_mic_energy_threshold = customtkinter.CTkEntry( + self.entry_input_mic_energy_threshold = CTkEntry( self.tabview_config.tab("Transcription"), - textvariable=customtkinter.StringVar(value=self.parent.INPUT_MIC_ENERGY_THRESHOLD), - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + textvariable=StringVar(value=self.parent.INPUT_MIC_ENERGY_THRESHOLD), + font=CTkFont(family=self.parent.FONT_FAMILY) ) self.entry_input_mic_energy_threshold.grid(row=row, column=1, columnspan=1 ,padx=padx, pady=pady, sticky="nsew") self.entry_input_mic_energy_threshold.bind("", self.entry_input_mic_energy_threshold_callback) ## checkbox input mic dynamic energy threshold row +=1 - self.label_input_mic_dynamic_energy_threshold = customtkinter.CTkLabel( + self.label_input_mic_dynamic_energy_threshold = CTkLabel( self.tabview_config.tab("Transcription"), text="Input Mic Dynamic Energy Threshold:", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkCheckBox( + 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=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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: @@ -301,143 +303,143 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): ## entry input mic record timeout row +=1 - self.label_input_mic_record_timeout = customtkinter.CTkLabel( + self.label_input_mic_record_timeout = CTkLabel( self.tabview_config.tab("Transcription"), text="Input Mic Record Timeout:", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkEntry( + self.entry_input_mic_record_timeout = CTkEntry( self.tabview_config.tab("Transcription"), - textvariable=customtkinter.StringVar(value=self.parent.INPUT_MIC_RECORD_TIMEOUT), - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkLabel( + self.label_input_mic_phrase_timeout = CTkLabel( self.tabview_config.tab("Transcription"), text="Input Mic Phrase Timeout:", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkEntry( + self.entry_input_mic_phrase_timeout = CTkEntry( self.tabview_config.tab("Transcription"), - textvariable=customtkinter.StringVar(value=self.parent.INPUT_MIC_PHRASE_TIMEOUT), - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkLabel( + self.label_input_mic_max_phrases = CTkLabel( self.tabview_config.tab("Transcription"), text="Input Mic Max Phrases:", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkEntry( + self.entry_input_mic_max_phrases = CTkEntry( self.tabview_config.tab("Transcription"), - textvariable=customtkinter.StringVar(value=self.parent.INPUT_MIC_MAX_PHRASES), - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkLabel( + self.label_input_mic_word_filter = CTkLabel( self.tabview_config.tab("Transcription"), text="Input Mic Word Filter:", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkEntry( + self.entry_input_mic_word_filter = CTkEntry( self.tabview_config.tab("Transcription"), - textvariable=customtkinter.StringVar(value=",".join(self.parent.INPUT_MIC_WORD_FILTER)), - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkLabel( + self.label_input_speaker_device = CTkLabel( self.tabview_config.tab("Transcription"), text="Input Speaker Device:", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkOptionMenu( + self.optionmenu_input_speaker_device = CTkOptionMenu( self.tabview_config.tab("Transcription"), - values=[device["name"] for device in audio_utils.get_output_device_list()], + values=[device["name"] for device in get_output_device_list()], command=self.optionmenu_input_speaker_device_callback, - variable=customtkinter.StringVar(value=self.parent.CHOICE_SPEAKER_DEVICE), - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY), + 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=customtkinter.CTkFont(family=self.parent.FONT_FAMILY)) + 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 = customtkinter.CTkLabel( + self.label_input_speaker_voice_language = CTkLabel( self.tabview_config.tab("Transcription"), text="Input Speaker Voice Language:", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkOptionMenu( + self.optionmenu_input_speaker_voice_language = CTkOptionMenu( self.tabview_config.tab("Transcription"), - values=list(languages.transcription_lang.keys()), + values=list(transcription_lang.keys()), command=self.optionmenu_input_speaker_voice_language_callback, - variable=customtkinter.StringVar(value=self.parent.INPUT_SPEAKER_VOICE_LANGUAGE), - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY), + 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=customtkinter.CTkFont(family=self.parent.FONT_FAMILY)) + 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 = customtkinter.CTkLabel( + self.label_input_speaker_energy_threshold = CTkLabel( self.tabview_config.tab("Transcription"), text="Input Speaker Energy Threshold:", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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") - self.entry_input_speaker_energy_threshold = customtkinter.CTkEntry( + self.entry_input_speaker_energy_threshold = CTkEntry( self.tabview_config.tab("Transcription"), - textvariable=customtkinter.StringVar(value=self.parent.INPUT_SPEAKER_ENERGY_THRESHOLD), - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + textvariable=StringVar(value=self.parent.INPUT_SPEAKER_ENERGY_THRESHOLD), + font=CTkFont(family=self.parent.FONT_FAMILY) ) self.entry_input_speaker_energy_threshold.grid(row=row, column=1, columnspan=1 ,padx=padx, pady=pady, sticky="nsew") self.entry_input_speaker_energy_threshold.bind("", self.entry_input_speaker_energy_threshold_callback) ## checkbox input speaker dynamic energy threshold row +=1 - self.label_input_speaker_dynamic_energy_threshold = customtkinter.CTkLabel( + self.label_input_speaker_dynamic_energy_threshold = CTkLabel( self.tabview_config.tab("Transcription"), text="Input Speaker Dynamic Energy Threshold:", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkCheckBox( + 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=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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: @@ -447,51 +449,51 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): ## entry input speaker record timeout row +=1 - self.label_input_speaker_record_timeout = customtkinter.CTkLabel( + self.label_input_speaker_record_timeout = CTkLabel( self.tabview_config.tab("Transcription"), text="Input Speaker Record Timeout:", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkEntry( + self.entry_input_speaker_record_timeout = CTkEntry( self.tabview_config.tab("Transcription"), - textvariable=customtkinter.StringVar(value=self.parent.INPUT_SPEAKER_RECORD_TIMEOUT), - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkLabel( + self.label_input_speaker_phrase_timeout = CTkLabel( self.tabview_config.tab("Transcription"), text="Input Speaker Phrase Timeout:", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkEntry( + self.entry_input_speaker_phrase_timeout = CTkEntry( self.tabview_config.tab("Transcription"), - textvariable=customtkinter.StringVar(value=self.parent.INPUT_SPEAKER_PHRASE_TIMEOUT), - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkLabel( + self.label_input_speaker_max_phrases = CTkLabel( self.tabview_config.tab("Transcription"), text="Input Speaker Max Phrases:", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkEntry( + self.entry_input_speaker_max_phrases = CTkEntry( self.tabview_config.tab("Transcription"), - textvariable=customtkinter.StringVar(value=self.parent.INPUT_SPEAKER_MAX_PHRASES), - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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) @@ -501,68 +503,68 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): row = 0 padx = 5 pady = 1 - self.label_ip_address = customtkinter.CTkLabel( + self.label_ip_address = CTkLabel( self.tabview_config.tab("Parameter"), text="OSC IP address:", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkEntry( + self.entry_ip_address = CTkEntry( self.tabview_config.tab("Parameter"), - textvariable=customtkinter.StringVar(value=self.parent.OSC_IP_ADDRESS), - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkLabel( + self.label_port = CTkLabel( self.tabview_config.tab("Parameter"), text="OSC Port:", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkEntry( + self.entry_port = CTkEntry( self.tabview_config.tab("Parameter"), - textvariable=customtkinter.StringVar(value=self.parent.OSC_PORT), - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkLabel( + self.label_authkey = CTkLabel( self.tabview_config.tab("Parameter"), text="DeepL Auth Key:", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkEntry( + self.entry_authkey = CTkEntry( self.tabview_config.tab("Parameter"), - textvariable=customtkinter.StringVar(value=self.parent.AUTH_KEYS["DeepL(auth)"]), - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkLabel( + self.label_message_format = CTkLabel( self.tabview_config.tab("Parameter"), text="Message Format:", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkEntry( + self.entry_message_format = CTkEntry( self.tabview_config.tab("Parameter"), - textvariable=customtkinter.StringVar(value=self.parent.MESSAGE_FORMAT), - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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) @@ -570,20 +572,20 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): # tab Others # checkbox auto clear chat box row += 1 - self.label_checkbox_auto_clear_chatbox = customtkinter.CTkLabel( + self.label_checkbox_auto_clear_chatbox = CTkLabel( self.tabview_config.tab("Others"), text="Auto clear chat box", fg_color="transparent", - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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 = customtkinter.CTkCheckBox( + self.checkbox_auto_clear_chatbox = CTkCheckBox( self.tabview_config.tab("Others"), text="", onvalue=True, offvalue=False, command=self.checkbox_auto_clear_chatbox_callback, - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + 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: @@ -596,116 +598,116 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): def slider_transparency_callback(self, value): self.parent.wm_attributes("-alpha", value/100) self.parent.TRANSPARENCY = value - utils.save_json(self.parent.PATH_CONFIG, "TRANSPARENCY", self.parent.TRANSPARENCY) + save_json(self.parent.PATH_CONFIG, "TRANSPARENCY", self.parent.TRANSPARENCY) def optionmenu_theme_callback(self, choice): customtkinter.set_appearance_mode(choice) self.parent.APPEARANCE_THEME = choice - utils.save_json(self.parent.PATH_CONFIG, "APPEARANCE_THEME", self.parent.APPEARANCE_THEME) + save_json(self.parent.PATH_CONFIG, "APPEARANCE_THEME", self.parent.APPEARANCE_THEME) def optionmenu_ui_scaling_callback(self, choice): new_scaling_float = int(choice.replace("%", "")) / 100 customtkinter.set_widget_scaling(new_scaling_float) self.parent.UI_SCALING = choice - utils.save_json(self.parent.PATH_CONFIG, "UI_SCALING", self.parent.UI_SCALING) + save_json(self.parent.PATH_CONFIG, "UI_SCALING", self.parent.UI_SCALING) def optionmenu_font_family_callback(self, choice): # tab menu - self.tabview_config._segmented_button.configure(font=customtkinter.CTkFont(family=choice)) + self.tabview_config._segmented_button.configure(font=CTkFont(family=choice)) # tab UI - self.label_transparency.configure(font=customtkinter.CTkFont(family=choice)) - self.label_appearance_theme.configure(font=customtkinter.CTkFont(family=choice)) - self.optionmenu_appearance_theme.configure(font=customtkinter.CTkFont(family=choice)) - self.optionmenu_appearance_theme._dropdown_menu.configure(font=customtkinter.CTkFont(family=choice)) - self.label_ui_scaling.configure(font=customtkinter.CTkFont(family=choice)) - self.optionmenu_ui_scaling.configure(font=customtkinter.CTkFont(family=choice)) - self.optionmenu_ui_scaling._dropdown_menu.configure(font=customtkinter.CTkFont(family=choice)) - self.label_font_family.configure(font=customtkinter.CTkFont(family=choice)) - self.optionmenu_font_family.configure(font=customtkinter.CTkFont(family=choice)) - self.optionmenu_font_family._dropdown_menu.configure(font=customtkinter.CTkFont(family=choice)) + self.label_transparency.configure(font=CTkFont(family=choice)) + self.label_appearance_theme.configure(font=CTkFont(family=choice)) + self.optionmenu_appearance_theme.configure(font=CTkFont(family=choice)) + self.optionmenu_appearance_theme._dropdown_menu.configure(font=CTkFont(family=choice)) + self.label_ui_scaling.configure(font=CTkFont(family=choice)) + self.optionmenu_ui_scaling.configure(font=CTkFont(family=choice)) + self.optionmenu_ui_scaling._dropdown_menu.configure(font=CTkFont(family=choice)) + 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)) # tab Translation - self.label_translation_translator.configure(font=customtkinter.CTkFont(family=choice)) - self.optionmenu_translation_translator.configure(font=customtkinter.CTkFont(family=choice)) - self.optionmenu_translation_translator._dropdown_menu.configure(font=customtkinter.CTkFont(family=choice)) - self.label_translation_input_language.configure(font=customtkinter.CTkFont(family=choice)) - self.optionmenu_translation_input_source_language.configure(font=customtkinter.CTkFont(family=choice)) - self.optionmenu_translation_input_source_language._dropdown_menu.configure(font=customtkinter.CTkFont(family=choice)) - self.label_translation_input_arrow.configure(font=customtkinter.CTkFont(family=choice)) - self.optionmenu_translation_input_target_language.configure(font=customtkinter.CTkFont(family=choice)) - self.optionmenu_translation_input_target_language._dropdown_menu.configure(font=customtkinter.CTkFont(family=choice)) - self.label_translation_output_language.configure(font=customtkinter.CTkFont(family=choice)) - self.optionmenu_translation_output_source_language.configure(font=customtkinter.CTkFont(family=choice)) - self.optionmenu_translation_output_source_language._dropdown_menu.configure(font=customtkinter.CTkFont(family=choice)) - self.label_translation_output_arrow.configure(font=customtkinter.CTkFont(family=choice)) - self.optionmenu_translation_output_target_language.configure(font=customtkinter.CTkFont(family=choice)) - self.optionmenu_translation_output_target_language._dropdown_menu.configure(font=customtkinter.CTkFont(family=choice)) + self.label_translation_translator.configure(font=CTkFont(family=choice)) + self.optionmenu_translation_translator.configure(font=CTkFont(family=choice)) + self.optionmenu_translation_translator._dropdown_menu.configure(font=CTkFont(family=choice)) + self.label_translation_input_language.configure(font=CTkFont(family=choice)) + self.optionmenu_translation_input_source_language.configure(font=CTkFont(family=choice)) + self.optionmenu_translation_input_source_language._dropdown_menu.configure(font=CTkFont(family=choice)) + self.label_translation_input_arrow.configure(font=CTkFont(family=choice)) + self.optionmenu_translation_input_target_language.configure(font=CTkFont(family=choice)) + self.optionmenu_translation_input_target_language._dropdown_menu.configure(font=CTkFont(family=choice)) + self.label_translation_output_language.configure(font=CTkFont(family=choice)) + self.optionmenu_translation_output_source_language.configure(font=CTkFont(family=choice)) + self.optionmenu_translation_output_source_language._dropdown_menu.configure(font=CTkFont(family=choice)) + self.label_translation_output_arrow.configure(font=CTkFont(family=choice)) + self.optionmenu_translation_output_target_language.configure(font=CTkFont(family=choice)) + self.optionmenu_translation_output_target_language._dropdown_menu.configure(font=CTkFont(family=choice)) # tab Transcription - self.label_input_mic_device.configure(font=customtkinter.CTkFont(family=choice)) - self.optionmenu_input_mic_device.configure(font=customtkinter.CTkFont(family=choice)) - self.optionmenu_input_mic_device._dropdown_menu.configure(font=customtkinter.CTkFont(family=choice)) - self.label_input_mic_voice_language.configure(font=customtkinter.CTkFont(family=choice)) - self.optionmenu_input_mic_voice_language.configure(font=customtkinter.CTkFont(family=choice)) - self.optionmenu_input_mic_voice_language._dropdown_menu.configure(font=customtkinter.CTkFont(family=choice)) - self.label_input_mic_energy_threshold.configure(font=customtkinter.CTkFont(family=choice)) - self.entry_input_mic_energy_threshold.configure(font=customtkinter.CTkFont(family=choice)) - self.label_input_mic_dynamic_energy_threshold.configure(font=customtkinter.CTkFont(family=choice)) - self.label_input_mic_record_timeout.configure(font=customtkinter.CTkFont(family=choice)) - self.entry_input_mic_record_timeout.configure(font=customtkinter.CTkFont(family=choice)) - self.label_input_mic_phrase_timeout.configure(font=customtkinter.CTkFont(family=choice)) - self.entry_input_mic_phrase_timeout.configure(font=customtkinter.CTkFont(family=choice)) - self.label_input_mic_max_phrases.configure(font=customtkinter.CTkFont(family=choice)) - self.entry_input_mic_max_phrases.configure(font=customtkinter.CTkFont(family=choice)) - self.label_input_mic_word_filter.configure(font=customtkinter.CTkFont(family=choice)) - self.entry_input_mic_word_filter.configure(font=customtkinter.CTkFont(family=choice)) - self.label_input_speaker_device.configure(font=customtkinter.CTkFont(family=choice)) - self.optionmenu_input_speaker_device.configure(font=customtkinter.CTkFont(family=choice)) - self.optionmenu_input_speaker_device._dropdown_menu.configure(font=customtkinter.CTkFont(family=choice)) - self.label_input_speaker_voice_language.configure(font=customtkinter.CTkFont(family=choice)) - self.optionmenu_input_speaker_voice_language.configure(font=customtkinter.CTkFont(family=choice)) - self.optionmenu_input_speaker_voice_language._dropdown_menu.configure(font=customtkinter.CTkFont(family=choice)) - self.label_input_speaker_energy_threshold.configure(font=customtkinter.CTkFont(family=choice)) - self.entry_input_speaker_energy_threshold.configure(font=customtkinter.CTkFont(family=choice)) - self.label_input_speaker_dynamic_energy_threshold.configure(font=customtkinter.CTkFont(family=choice)) - self.label_input_speaker_record_timeout.configure(font=customtkinter.CTkFont(family=choice)) - self.entry_input_speaker_record_timeout.configure(font=customtkinter.CTkFont(family=choice)) - self.label_input_speaker_phrase_timeout.configure(font=customtkinter.CTkFont(family=choice)) - self.entry_input_speaker_phrase_timeout.configure(font=customtkinter.CTkFont(family=choice)) - self.label_input_speaker_max_phrases.configure(font=customtkinter.CTkFont(family=choice)) - self.entry_input_speaker_max_phrases.configure(font=customtkinter.CTkFont(family=choice)) + self.label_input_mic_device.configure(font=CTkFont(family=choice)) + self.optionmenu_input_mic_device.configure(font=CTkFont(family=choice)) + self.optionmenu_input_mic_device._dropdown_menu.configure(font=CTkFont(family=choice)) + self.label_input_mic_voice_language.configure(font=CTkFont(family=choice)) + self.optionmenu_input_mic_voice_language.configure(font=CTkFont(family=choice)) + self.optionmenu_input_mic_voice_language._dropdown_menu.configure(font=CTkFont(family=choice)) + self.label_input_mic_energy_threshold.configure(font=CTkFont(family=choice)) + self.entry_input_mic_energy_threshold.configure(font=CTkFont(family=choice)) + self.label_input_mic_dynamic_energy_threshold.configure(font=CTkFont(family=choice)) + self.label_input_mic_record_timeout.configure(font=CTkFont(family=choice)) + self.entry_input_mic_record_timeout.configure(font=CTkFont(family=choice)) + self.label_input_mic_phrase_timeout.configure(font=CTkFont(family=choice)) + self.entry_input_mic_phrase_timeout.configure(font=CTkFont(family=choice)) + self.label_input_mic_max_phrases.configure(font=CTkFont(family=choice)) + self.entry_input_mic_max_phrases.configure(font=CTkFont(family=choice)) + self.label_input_mic_word_filter.configure(font=CTkFont(family=choice)) + self.entry_input_mic_word_filter.configure(font=CTkFont(family=choice)) + self.label_input_speaker_device.configure(font=CTkFont(family=choice)) + self.optionmenu_input_speaker_device.configure(font=CTkFont(family=choice)) + self.optionmenu_input_speaker_device._dropdown_menu.configure(font=CTkFont(family=choice)) + self.label_input_speaker_voice_language.configure(font=CTkFont(family=choice)) + self.optionmenu_input_speaker_voice_language.configure(font=CTkFont(family=choice)) + self.optionmenu_input_speaker_voice_language._dropdown_menu.configure(font=CTkFont(family=choice)) + self.label_input_speaker_energy_threshold.configure(font=CTkFont(family=choice)) + self.entry_input_speaker_energy_threshold.configure(font=CTkFont(family=choice)) + self.label_input_speaker_dynamic_energy_threshold.configure(font=CTkFont(family=choice)) + self.label_input_speaker_record_timeout.configure(font=CTkFont(family=choice)) + self.entry_input_speaker_record_timeout.configure(font=CTkFont(family=choice)) + self.label_input_speaker_phrase_timeout.configure(font=CTkFont(family=choice)) + self.entry_input_speaker_phrase_timeout.configure(font=CTkFont(family=choice)) + self.label_input_speaker_max_phrases.configure(font=CTkFont(family=choice)) + self.entry_input_speaker_max_phrases.configure(font=CTkFont(family=choice)) # tab Parameter - self.label_ip_address.configure(font=customtkinter.CTkFont(family=choice)) - self.entry_ip_address.configure(font=customtkinter.CTkFont(family=choice)) - self.label_port.configure(font=customtkinter.CTkFont(family=choice)) - self.entry_port.configure(font=customtkinter.CTkFont(family=choice)) - self.label_authkey.configure(font=customtkinter.CTkFont(family=choice)) - self.entry_authkey.configure(font=customtkinter.CTkFont(family=choice)) - self.label_message_format.configure(font=customtkinter.CTkFont(family=choice)) - self.entry_message_format.configure(font=customtkinter.CTkFont(family=choice)) + self.label_ip_address.configure(font=CTkFont(family=choice)) + self.entry_ip_address.configure(font=CTkFont(family=choice)) + self.label_port.configure(font=CTkFont(family=choice)) + self.entry_port.configure(font=CTkFont(family=choice)) + self.label_authkey.configure(font=CTkFont(family=choice)) + self.entry_authkey.configure(font=CTkFont(family=choice)) + self.label_message_format.configure(font=CTkFont(family=choice)) + self.entry_message_format.configure(font=CTkFont(family=choice)) # main window - self.parent.checkbox_translation.configure(font=customtkinter.CTkFont(family=choice)) - self.parent.checkbox_transcription_send.configure(font=customtkinter.CTkFont(family=choice)) - self.parent.checkbox_transcription_receive.configure(font=customtkinter.CTkFont(family=choice)) - self.parent.checkbox_foreground.configure(font=customtkinter.CTkFont(family=choice)) - self.parent.textbox_message_log.configure(font=customtkinter.CTkFont(family=choice)) - self.parent.textbox_message_send_log.configure(font=customtkinter.CTkFont(family=choice)) - self.parent.textbox_message_receive_log.configure(font=customtkinter.CTkFont(family=choice)) - self.parent.textbox_message_system_log.configure(font=customtkinter.CTkFont(family=choice)) - self.parent.entry_message_box.configure(font=customtkinter.CTkFont(family=choice)) - self.parent.tabview_logs._segmented_button.configure(font=customtkinter.CTkFont(family=choice)) + self.parent.checkbox_translation.configure(font=CTkFont(family=choice)) + self.parent.checkbox_transcription_send.configure(font=CTkFont(family=choice)) + self.parent.checkbox_transcription_receive.configure(font=CTkFont(family=choice)) + self.parent.checkbox_foreground.configure(font=CTkFont(family=choice)) + self.parent.textbox_message_log.configure(font=CTkFont(family=choice)) + self.parent.textbox_message_send_log.configure(font=CTkFont(family=choice)) + self.parent.textbox_message_receive_log.configure(font=CTkFont(family=choice)) + self.parent.textbox_message_system_log.configure(font=CTkFont(family=choice)) + self.parent.entry_message_box.configure(font=CTkFont(family=choice)) + self.parent.tabview_logs._segmented_button.configure(font=CTkFont(family=choice)) # window information try: - self.parent.information_window.textbox_information.configure(font=customtkinter.CTkFont(family=choice)) + self.parent.information_window.textbox_information.configure(font=CTkFont(family=choice)) except: pass self.parent.FONT_FAMILY = choice - utils.save_json(self.parent.PATH_CONFIG, "FONT_FAMILY", self.parent.FONT_FAMILY) + save_json(self.parent.PATH_CONFIG, "FONT_FAMILY", self.parent.FONT_FAMILY) def checkbox_auto_clear_chatbox_callback(self): value = self.checkbox_auto_clear_chatbox.get() @@ -714,130 +716,130 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): def optionmenu_translation_translator_callback(self, choice): if self.parent.translator.authentication(choice, self.parent.AUTH_KEYS[choice]) is False: - utils.print_textbox(self.parent.textbox_message_log, "Auth Key or language setting is incorrect", "ERROR") - utils.print_textbox(self.parent.textbox_message_system_log, "Auth Key or language setting is incorrect", "ERROR") + print_textbox(self.parent.textbox_message_log, "Auth Key or language setting is incorrect", "ERROR") + print_textbox(self.parent.textbox_message_system_log, "Auth Key or language setting is incorrect", "ERROR") else: self.optionmenu_translation_input_source_language.configure( - values=list(languages.translation_lang[choice].keys()), - variable=customtkinter.StringVar(value=list(languages.translation_lang[choice].keys())[0])) + values=list(translation_lang[choice].keys()), + variable=StringVar(value=list(translation_lang[choice].keys())[0])) self.optionmenu_translation_input_target_language.configure( - values=list(languages.translation_lang[choice].keys()), - variable=customtkinter.StringVar(value=list(languages.translation_lang[choice].keys())[1])) + values=list(translation_lang[choice].keys()), + variable=StringVar(value=list(translation_lang[choice].keys())[1])) self.optionmenu_translation_output_source_language.configure( - values=list(languages.translation_lang[choice].keys()), - variable=customtkinter.StringVar(value=list(languages.translation_lang[choice].keys())[1])) + values=list(translation_lang[choice].keys()), + variable=StringVar(value=list(translation_lang[choice].keys())[1])) self.optionmenu_translation_output_target_language.configure( - values=list(languages.translation_lang[choice].keys()), - variable=customtkinter.StringVar(value=list(languages.translation_lang[choice].keys())[0])) + values=list(translation_lang[choice].keys()), + variable=StringVar(value=list(translation_lang[choice].keys())[0])) self.parent.CHOICE_TRANSLATOR = choice - self.parent.INPUT_SOURCE_LANG = list(languages.translation_lang[choice].keys())[0] - self.parent.INPUT_TARGET_LANG = list(languages.translation_lang[choice].keys())[1] - self.parent.OUTPUT_SOURCE_LANG = list(languages.translation_lang[choice].keys())[1] - self.parent.OUTPUT_TARGET_LANG = list(languages.translation_lang[choice].keys())[0] - utils.save_json(self.parent.PATH_CONFIG, "CHOICE_TRANSLATOR", self.parent.CHOICE_TRANSLATOR) - utils.save_json(self.parent.PATH_CONFIG, "INPUT_SOURCE_LANG", self.parent.INPUT_SOURCE_LANG) - utils.save_json(self.parent.PATH_CONFIG, "INPUT_TARGET_LANG", self.parent.INPUT_TARGET_LANG) - utils.save_json(self.parent.PATH_CONFIG, "OUTPUT_SOURCE_LANG", self.parent.OUTPUT_SOURCE_LANG) - utils.save_json(self.parent.PATH_CONFIG, "OUTPUT_TARGET_LANG", self.parent.OUTPUT_TARGET_LANG) + self.parent.INPUT_SOURCE_LANG = list(translation_lang[choice].keys())[0] + self.parent.INPUT_TARGET_LANG = list(translation_lang[choice].keys())[1] + self.parent.OUTPUT_SOURCE_LANG = list(translation_lang[choice].keys())[1] + self.parent.OUTPUT_TARGET_LANG = list(translation_lang[choice].keys())[0] + save_json(self.parent.PATH_CONFIG, "CHOICE_TRANSLATOR", self.parent.CHOICE_TRANSLATOR) + save_json(self.parent.PATH_CONFIG, "INPUT_SOURCE_LANG", self.parent.INPUT_SOURCE_LANG) + save_json(self.parent.PATH_CONFIG, "INPUT_TARGET_LANG", self.parent.INPUT_TARGET_LANG) + save_json(self.parent.PATH_CONFIG, "OUTPUT_SOURCE_LANG", self.parent.OUTPUT_SOURCE_LANG) + save_json(self.parent.PATH_CONFIG, "OUTPUT_TARGET_LANG", self.parent.OUTPUT_TARGET_LANG) def optionmenu_translation_input_source_language_callback(self, choice): self.parent.INPUT_SOURCE_LANG = choice - utils.save_json(self.parent.PATH_CONFIG, "INPUT_SOURCE_LANG", self.parent.INPUT_SOURCE_LANG) + save_json(self.parent.PATH_CONFIG, "INPUT_SOURCE_LANG", self.parent.INPUT_SOURCE_LANG) def optionmenu_translation_input_target_language_callback(self, choice): self.parent.INPUT_TARGET_LANG = choice - utils.save_json(self.parent.PATH_CONFIG, "INPUT_TARGET_LANG", self.parent.INPUT_TARGET_LANG) + save_json(self.parent.PATH_CONFIG, "INPUT_TARGET_LANG", self.parent.INPUT_TARGET_LANG) def optionmenu_translation_output_source_language_callback(self, choice): self.parent.OUTPUT_SOURCE_LANG = choice - utils.save_json(self.parent.PATH_CONFIG, "OUTPUT_SOURCE_LANG", self.parent.OUTPUT_SOURCE_LANG) + save_json(self.parent.PATH_CONFIG, "OUTPUT_SOURCE_LANG", self.parent.OUTPUT_SOURCE_LANG) def optionmenu_translation_output_target_language_callback(self, choice): self.parent.OUTPUT_TARGET_LANG = choice - utils.save_json(self.parent.PATH_CONFIG, "OUTPUT_TARGET_LANG", self.parent.OUTPUT_TARGET_LANG) + save_json(self.parent.PATH_CONFIG, "OUTPUT_TARGET_LANG", self.parent.OUTPUT_TARGET_LANG) def optionmenu_input_mic_device_callback(self, choice): self.parent.CHOICE_MIC_DEVICE = choice - utils.save_json(self.parent.PATH_CONFIG, "CHOICE_MIC_DEVICE", self.parent.CHOICE_MIC_DEVICE) + save_json(self.parent.PATH_CONFIG, "CHOICE_MIC_DEVICE", self.parent.CHOICE_MIC_DEVICE) def optionmenu_input_mic_voice_language_callback(self, choice): self.parent.INPUT_MIC_VOICE_LANGUAGE = choice - utils.save_json(self.parent.PATH_CONFIG, "INPUT_MIC_VOICE_LANGUAGE", self.parent.INPUT_MIC_VOICE_LANGUAGE) + save_json(self.parent.PATH_CONFIG, "INPUT_MIC_VOICE_LANGUAGE", self.parent.INPUT_MIC_VOICE_LANGUAGE) def entry_input_mic_energy_threshold_callback(self, event): self.parent.INPUT_MIC_ENERGY_THRESHOLD = int(self.entry_input_mic_energy_threshold.get()) - utils.save_json(self.parent.PATH_CONFIG, "INPUT_MIC_ENERGY_THRESHOLD", self.parent.INPUT_MIC_ENERGY_THRESHOLD) + save_json(self.parent.PATH_CONFIG, "INPUT_MIC_ENERGY_THRESHOLD", self.parent.INPUT_MIC_ENERGY_THRESHOLD) def checkbox_input_mic_dynamic_energy_threshold_callback(self): value = self.checkbox_input_mic_dynamic_energy_threshold.get() self.parent.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD = value - utils.save_json(self.parent.PATH_CONFIG, "INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD", self.parent.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD) + save_json(self.parent.PATH_CONFIG, "INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD", self.parent.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD) def entry_input_mic_record_timeout_callback(self, event): self.parent.INPUT_MIC_RECORD_TIMEOUT = int(self.entry_input_mic_record_timeout.get()) - utils.save_json(self.parent.PATH_CONFIG, "INPUT_MIC_RECORD_TIMEOUT", self.parent.INPUT_MIC_RECORD_TIMEOUT) + save_json(self.parent.PATH_CONFIG, "INPUT_MIC_RECORD_TIMEOUT", self.parent.INPUT_MIC_RECORD_TIMEOUT) def entry_input_mic_phrase_timeout_callback(self, event): self.parent.INPUT_MIC_PHRASE_TIMEOUT = int(self.entry_input_mic_phrase_timeout.get()) - utils.save_json(self.parent.PATH_CONFIG, "INPUT_MIC_PHRASE_TIMEOUT", self.parent.INPUT_MIC_PHRASE_TIMEOUT) + save_json(self.parent.PATH_CONFIG, "INPUT_MIC_PHRASE_TIMEOUT", self.parent.INPUT_MIC_PHRASE_TIMEOUT) def entry_input_mic_max_phrases_callback(self, event): self.parent.INPUT_MIC_MAX_PHRASES = int(self.entry_input_mic_max_phrases.get()) - utils.save_json(self.parent.PATH_CONFIG, "INPUT_MIC_MAX_PHRASES", self.parent.INPUT_MIC_MAX_PHRASES) + save_json(self.parent.PATH_CONFIG, "INPUT_MIC_MAX_PHRASES", self.parent.INPUT_MIC_MAX_PHRASES) def entry_input_mic_word_filters_callback(self, event): self.parent.INPUT_MIC_WORD_FILTER = self.entry_input_mic_word_filter.get().split(",") self.parent.keyword_processor = KeywordProcessor() for f in self.parent.INPUT_MIC_WORD_FILTER: self.parent.keyword_processor.add_keyword(f) - utils.save_json(self.parent.PATH_CONFIG, "INPUT_MIC_WORD_FILTER", self.parent.INPUT_MIC_WORD_FILTER) + save_json(self.parent.PATH_CONFIG, "INPUT_MIC_WORD_FILTER", self.parent.INPUT_MIC_WORD_FILTER) def optionmenu_input_speaker_device_callback(self, choice): self.parent.CHOICE_SPEAKER_DEVICE = choice - utils.save_json(self.parent.PATH_CONFIG, "CHOICE_SPEAKER_DEVICE", self.parent.CHOICE_SPEAKER_DEVICE) + save_json(self.parent.PATH_CONFIG, "CHOICE_SPEAKER_DEVICE", self.parent.CHOICE_SPEAKER_DEVICE) def optionmenu_input_speaker_voice_language_callback(self, choice): self.parent.INPUT_SPEAKER_VOICE_LANGUAGE = choice - utils.save_json(self.parent.PATH_CONFIG, "INPUT_SPEAKER_VOICE_LANGUAGE", self.parent.INPUT_SPEAKER_VOICE_LANGUAGE) + save_json(self.parent.PATH_CONFIG, "INPUT_SPEAKER_VOICE_LANGUAGE", self.parent.INPUT_SPEAKER_VOICE_LANGUAGE) def entry_input_speaker_energy_threshold_callback(self, event): self.parent.INPUT_SPEAKER_ENERGY_THRESHOLD = int(self.entry_input_speaker_energy_threshold.get()) - utils.save_json(self.parent.PATH_CONFIG, "INPUT_SPEAKER_ENERGY_THRESHOLD", self.parent.INPUT_SPEAKER_ENERGY_THRESHOLD) + save_json(self.parent.PATH_CONFIG, "INPUT_SPEAKER_ENERGY_THRESHOLD", self.parent.INPUT_SPEAKER_ENERGY_THRESHOLD) def checkbox_input_speaker_dynamic_energy_threshold_callback(self): value = self.checkbox_input_speaker_dynamic_energy_threshold.get() self.parent.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD = value - utils.save_json(self.parent.PATH_CONFIG, "INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD", self.parent.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD) + save_json(self.parent.PATH_CONFIG, "INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD", self.parent.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD) def entry_input_speaker_record_timeout_callback(self, event): self.parent.INPUT_SPEAKER_RECORD_TIMEOUT = int(self.entry_input_speaker_record_timeout.get()) - utils.save_json(self.parent.PATH_CONFIG, "INPUT_SPEAKER_RECORD_TIMEOUT", self.parent.INPUT_SPEAKER_RECORD_TIMEOUT) + save_json(self.parent.PATH_CONFIG, "INPUT_SPEAKER_RECORD_TIMEOUT", self.parent.INPUT_SPEAKER_RECORD_TIMEOUT) def entry_input_speaker_phrase_timeout_callback(self, event): self.parent.INPUT_SPEAKER_PHRASE_TIMEOUT = int(self.entry_input_speaker_phrase_timeout.get()) - utils.save_json(self.parent.PATH_CONFIG, "INPUT_SPEAKER_PHRASE_TIMEOUT", self.parent.INPUT_SPEAKER_PHRASE_TIMEOUT) + save_json(self.parent.PATH_CONFIG, "INPUT_SPEAKER_PHRASE_TIMEOUT", self.parent.INPUT_SPEAKER_PHRASE_TIMEOUT) def entry_input_speaker_max_phrases_callback(self, event): self.parent.INPUT_SPEAKER_MAX_PHRASES = int(self.entry_input_speaker_max_phrases.get()) - utils.save_json(self.parent.PATH_CONFIG, "INPUT_SPEAKER_MAX_PHRASES", self.parent.INPUT_SPEAKER_MAX_PHRASES) + save_json(self.parent.PATH_CONFIG, "INPUT_SPEAKER_MAX_PHRASES", self.parent.INPUT_SPEAKER_MAX_PHRASES) def entry_ip_address_callback(self, event): self.parent.OSC_IP_ADDRESS = self.entry_ip_address.get() - utils.save_json(self.parent.PATH_CONFIG, "OSC_IP_ADDRESS", self.parent.OSC_IP_ADDRESS) + save_json(self.parent.PATH_CONFIG, "OSC_IP_ADDRESS", self.parent.OSC_IP_ADDRESS) def entry_port_callback(self, event): self.parent.OSC_PORT = self.entry_port.get() - utils.save_json(self.parent.PATH_CONFIG, "OSC_PORT", self.parent.OSC_PORT) + save_json(self.parent.PATH_CONFIG, "OSC_PORT", self.parent.OSC_PORT) def entry_authkey_callback(self, event): value = self.entry_authkey.get() if len(value) > 0: if self.parent.translator.authentication("DeepL(auth)", value) is True: self.parent.AUTH_KEYS["DeepL(auth)"] = value - utils.save_json(self.parent.PATH_CONFIG, "AUTH_KEYS", self.parent.AUTH_KEYS) - utils.print_textbox(self.parent.textbox_message_log, "Auth key update completed", "INFO") - utils.print_textbox(self.parent.textbox_message_system_log, "Auth key update completed", "INFO") + save_json(self.parent.PATH_CONFIG, "AUTH_KEYS", self.parent.AUTH_KEYS) + print_textbox(self.parent.textbox_message_log, "Auth key update completed", "INFO") + print_textbox(self.parent.textbox_message_system_log, "Auth key update completed", "INFO") else: pass @@ -851,4 +853,4 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): value = self.entry_message_format.get() if len(value) > 0: self.parent.MESSAGE_FORMAT = value - utils.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) \ No newline at end of file diff --git a/window_information.py b/window_information.py index f3039589..39f9d713 100644 --- a/window_information.py +++ b/window_information.py @@ -1,7 +1,7 @@ import os -import customtkinter +from customtkinter import CTkToplevel, CTkTextbox, CTkFont -class ToplevelWindowInformation(customtkinter.CTkToplevel): +class ToplevelWindowInformation(CTkToplevel): def __init__(self, parent, *args, **kwargs): super().__init__(parent, *args, **kwargs) self.parent = parent @@ -13,9 +13,9 @@ class ToplevelWindowInformation(customtkinter.CTkToplevel): self.after(200, lambda: self.iconbitmap(os.path.join(os.path.dirname(__file__), "img", "app.ico"))) self.title("Information") # create textbox information - self.textbox_information = customtkinter.CTkTextbox( + self.textbox_information = CTkTextbox( self, - font=customtkinter.CTkFont(family=self.parent.FONT_FAMILY) + font=CTkFont(family=self.parent.FONT_FAMILY) ) self.textbox_information.grid(row=0, column=0, padx=(10, 10), pady=(10, 10), sticky="nsew") textbox_information_message = """VRCT(v1.2)