[Update] model.pyからprint_textboxをすべて引き剥がした。
UIの依存関係はなくなったはず
This commit is contained in:
187
VRCT.py
187
VRCT.py
@@ -56,8 +56,7 @@ class App(CTk):
|
|||||||
# set translator
|
# set translator
|
||||||
if model.authenticationTranslator() is False:
|
if model.authenticationTranslator() is False:
|
||||||
# error update Auth key
|
# error update Auth key
|
||||||
print_textbox(self.textbox_message_log, "Auth Key or language setting is incorrect", "ERROR")
|
self.printLogAuthenticationError()
|
||||||
print_textbox(self.textbox_message_system_log, "Auth Key or language setting is incorrect", "ERROR")
|
|
||||||
|
|
||||||
# set word filter
|
# set word filter
|
||||||
model.addKeywords()
|
model.addKeywords()
|
||||||
@@ -93,32 +92,27 @@ class App(CTk):
|
|||||||
def checkbox_translation_callback(self):
|
def checkbox_translation_callback(self):
|
||||||
config.ENABLE_TRANSLATION = self.checkbox_translation.get()
|
config.ENABLE_TRANSLATION = self.checkbox_translation.get()
|
||||||
if config.ENABLE_TRANSLATION is True:
|
if config.ENABLE_TRANSLATION is True:
|
||||||
print_textbox(self.textbox_message_log, "Start translation", "INFO")
|
self.printLogStartTranslation()
|
||||||
print_textbox(self.textbox_message_system_log, "Start translation", "INFO")
|
|
||||||
else:
|
else:
|
||||||
print_textbox(self.textbox_message_log, "Stop translation", "INFO")
|
self.printLogStopTranslation()
|
||||||
print_textbox(self.textbox_message_system_log, "Stop translation", "INFO")
|
|
||||||
|
|
||||||
def transcription_send_start(self):
|
def transcription_send_start(self):
|
||||||
model.startMicTranscript(self.textbox_message_log, self.textbox_message_send_log, self.textbox_message_system_log)
|
model.startMicTranscript(self.sendMicMessage)
|
||||||
print_textbox(self.textbox_message_log, "Start voice2chatbox", "INFO")
|
self.printLogStartVoice2chatbox()
|
||||||
print_textbox(self.textbox_message_system_log, "Start voice2chatbox", "INFO")
|
|
||||||
self.checkbox_transcription_send.configure(state="normal")
|
self.checkbox_transcription_send.configure(state="normal")
|
||||||
self.checkbox_transcription_receive.configure(state="normal")
|
self.checkbox_transcription_receive.configure(state="normal")
|
||||||
self.button_config.configure(state="normal", fg_color=["#3B8ED0", "#1F6AA5"])
|
self.button_config.configure(state="normal", fg_color=["#3B8ED0", "#1F6AA5"])
|
||||||
|
|
||||||
def transcription_send_stop(self):
|
def transcription_send_stop(self):
|
||||||
model.stopMicTranscript()
|
model.stopMicTranscript()
|
||||||
print_textbox(self.textbox_message_log, "Stop voice2chatbox", "INFO")
|
self.printLogStopVoice2chatbox()
|
||||||
print_textbox(self.textbox_message_system_log, "Stop voice2chatbox", "INFO")
|
|
||||||
self.checkbox_transcription_send.configure(state="normal")
|
self.checkbox_transcription_send.configure(state="normal")
|
||||||
self.checkbox_transcription_receive.configure(state="normal")
|
self.checkbox_transcription_receive.configure(state="normal")
|
||||||
self.button_config.configure(state="normal", fg_color=["#3B8ED0", "#1F6AA5"])
|
self.button_config.configure(state="normal", fg_color=["#3B8ED0", "#1F6AA5"])
|
||||||
|
|
||||||
def transcription_send_stop_for_config(self):
|
def transcription_send_stop_for_config(self):
|
||||||
model.stopMicTranscript()
|
model.stopMicTranscript()
|
||||||
print_textbox(self.textbox_message_log, "Stop voice2chatbox", "INFO")
|
self.printLogStopVoice2chatbox()
|
||||||
print_textbox(self.textbox_message_system_log, "Stop voice2chatbox", "INFO")
|
|
||||||
|
|
||||||
def checkbox_transcription_send_callback(self):
|
def checkbox_transcription_send_callback(self):
|
||||||
config.ENABLE_TRANSCRIPTION_SEND = self.checkbox_transcription_send.get()
|
config.ENABLE_TRANSCRIPTION_SEND = self.checkbox_transcription_send.get()
|
||||||
@@ -135,25 +129,22 @@ class App(CTk):
|
|||||||
th_transcription_send_stop.start()
|
th_transcription_send_stop.start()
|
||||||
|
|
||||||
def transcription_receive_start(self):
|
def transcription_receive_start(self):
|
||||||
model.startSpeakerTranscript(self.textbox_message_log, self.textbox_message_receive_log, self.textbox_message_system_log)
|
model.startSpeakerTranscript(self.receiveSpeakerMessage)
|
||||||
print_textbox(self.textbox_message_log, "Start speaker2log", "INFO")
|
self.printLogStartSpeaker2log()
|
||||||
print_textbox(self.textbox_message_system_log, "Start speaker2log", "INFO")
|
|
||||||
self.checkbox_transcription_send.configure(state="normal")
|
self.checkbox_transcription_send.configure(state="normal")
|
||||||
self.checkbox_transcription_receive.configure(state="normal")
|
self.checkbox_transcription_receive.configure(state="normal")
|
||||||
self.button_config.configure(state="normal", fg_color=["#3B8ED0", "#1F6AA5"])
|
self.button_config.configure(state="normal", fg_color=["#3B8ED0", "#1F6AA5"])
|
||||||
|
|
||||||
def transcription_receive_stop(self):
|
def transcription_receive_stop(self):
|
||||||
model.stopSpeakerTranscript()
|
model.stopSpeakerTranscript()
|
||||||
print_textbox(self.textbox_message_log, "Stop speaker2log", "INFO")
|
self.printLogStopSpeaker2log()
|
||||||
print_textbox(self.textbox_message_system_log, "Stop speaker2log", "INFO")
|
|
||||||
self.checkbox_transcription_send.configure(state="normal")
|
self.checkbox_transcription_send.configure(state="normal")
|
||||||
self.checkbox_transcription_receive.configure(state="normal")
|
self.checkbox_transcription_receive.configure(state="normal")
|
||||||
self.button_config.configure(state="normal", fg_color=["#3B8ED0", "#1F6AA5"])
|
self.button_config.configure(state="normal", fg_color=["#3B8ED0", "#1F6AA5"])
|
||||||
|
|
||||||
def transcription_receive_stop_for_config(self):
|
def transcription_receive_stop_for_config(self):
|
||||||
model.stopSpeakerTranscript()
|
model.stopSpeakerTranscript()
|
||||||
print_textbox(self.textbox_message_log, "Stop speaker2log", "INFO")
|
self.printLogStopSpeaker2log()
|
||||||
print_textbox(self.textbox_message_system_log, "Stop speaker2log", "INFO")
|
|
||||||
|
|
||||||
def checkbox_transcription_receive_callback(self):
|
def checkbox_transcription_receive_callback(self):
|
||||||
config.ENABLE_TRANSCRIPTION_RECEIVE = self.checkbox_transcription_receive.get()
|
config.ENABLE_TRANSCRIPTION_RECEIVE = self.checkbox_transcription_receive.get()
|
||||||
@@ -194,24 +185,20 @@ class App(CTk):
|
|||||||
config.ENABLE_FOREGROUND = self.checkbox_foreground.get()
|
config.ENABLE_FOREGROUND = self.checkbox_foreground.get()
|
||||||
if config.ENABLE_FOREGROUND:
|
if config.ENABLE_FOREGROUND:
|
||||||
self.attributes("-topmost", True)
|
self.attributes("-topmost", True)
|
||||||
print_textbox(self.textbox_message_log, "Start foreground", "INFO")
|
self.printLogStartForeground()
|
||||||
print_textbox(self.textbox_message_system_log, "Start foreground", "INFO")
|
|
||||||
else:
|
else:
|
||||||
self.attributes("-topmost", False)
|
self.attributes("-topmost", False)
|
||||||
print_textbox(self.textbox_message_log, "Stop foreground", "INFO")
|
self.printLogStopForeground()
|
||||||
print_textbox(self.textbox_message_system_log, "Stop foreground", "INFO")
|
|
||||||
|
|
||||||
def foreground_start(self):
|
def foreground_start(self):
|
||||||
if config.ENABLE_FOREGROUND:
|
if config.ENABLE_FOREGROUND:
|
||||||
self.attributes("-topmost", True)
|
self.attributes("-topmost", True)
|
||||||
print_textbox(self.textbox_message_log, "Start foreground", "INFO")
|
self.printLogStartForeground()
|
||||||
print_textbox(self.textbox_message_system_log, "Start foreground", "INFO")
|
|
||||||
|
|
||||||
def foreground_stop(self):
|
def foreground_stop(self):
|
||||||
if config.ENABLE_FOREGROUND:
|
if config.ENABLE_FOREGROUND:
|
||||||
self.attributes("-topmost", False)
|
self.attributes("-topmost", False)
|
||||||
print_textbox(self.textbox_message_log, "Stop foreground", "INFO")
|
self.printLogStopForeground()
|
||||||
print_textbox(self.textbox_message_system_log, "Stop foreground", "INFO")
|
|
||||||
|
|
||||||
def entry_message_box_press_key_enter(self, event):
|
def entry_message_box_press_key_enter(self, event):
|
||||||
# osc stop send typing
|
# osc stop send typing
|
||||||
@@ -221,31 +208,7 @@ class App(CTk):
|
|||||||
self.attributes("-topmost", True)
|
self.attributes("-topmost", True)
|
||||||
|
|
||||||
message = self.entry_message_box.get()
|
message = self.entry_message_box.get()
|
||||||
if len(message) > 0:
|
self.sendChatMessage(message)
|
||||||
# translate
|
|
||||||
if config.ENABLE_TRANSLATION is False:
|
|
||||||
chat_message = f"{message}"
|
|
||||||
elif model.getTranslatorStatus() is False:
|
|
||||||
print_textbox(self.textbox_message_log, "Auth Key or language setting is incorrect", "ERROR")
|
|
||||||
print_textbox(self.textbox_message_system_log, "Auth Key or language setting is incorrect", "ERROR")
|
|
||||||
chat_message = f"{message}"
|
|
||||||
else:
|
|
||||||
chat_message = model.getInputTranslate(message)
|
|
||||||
|
|
||||||
# send OSC message
|
|
||||||
if config.ENABLE_OSC is True:
|
|
||||||
model.oscSendMessage(chat_message)
|
|
||||||
else:
|
|
||||||
print_textbox(self.textbox_message_log, "OSC is not enabled, please enable OSC and rejoin.", "ERROR")
|
|
||||||
print_textbox(self.textbox_message_system_log, "OSC is not enabled, please enable OSC and rejoin.", "ERROR")
|
|
||||||
|
|
||||||
# update textbox message log
|
|
||||||
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 config.ENABLE_AUTO_CLEAR_CHATBOX is True:
|
|
||||||
self.entry_message_box.delete(0, customtkinter.END)
|
|
||||||
|
|
||||||
def entry_message_box_press_key_any(self, event):
|
def entry_message_box_press_key_any(self, event):
|
||||||
# osc start send typing
|
# osc start send typing
|
||||||
@@ -405,6 +368,124 @@ class App(CTk):
|
|||||||
|
|
||||||
widget_main_window_label_setter(self, language_yaml_data)
|
widget_main_window_label_setter(self, language_yaml_data)
|
||||||
|
|
||||||
|
def printLogAuthenticationError(self):
|
||||||
|
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")
|
||||||
|
|
||||||
|
def printLogStartTranslation(self):
|
||||||
|
print_textbox(self.textbox_message_log, "Start translation", "INFO")
|
||||||
|
print_textbox(self.textbox_message_system_log, "Start translation", "INFO")
|
||||||
|
|
||||||
|
def printLogStopTranslation(self):
|
||||||
|
print_textbox(self.textbox_message_log, "Stop translation", "INFO")
|
||||||
|
print_textbox(self.textbox_message_system_log, "Stop translation", "INFO")
|
||||||
|
|
||||||
|
def printLogStartVoice2chatbox(self):
|
||||||
|
print_textbox(self.textbox_message_log, "Start voice2chatbox", "INFO")
|
||||||
|
print_textbox(self.textbox_message_system_log, "Start voice2chatbox", "INFO")
|
||||||
|
|
||||||
|
def printLogStopVoice2chatbox(self):
|
||||||
|
print_textbox(self.textbox_message_log, "Stop voice2chatbox", "INFO")
|
||||||
|
print_textbox(self.textbox_message_system_log, "Stop voice2chatbox", "INFO")
|
||||||
|
|
||||||
|
def printLogStartSpeaker2log(self):
|
||||||
|
print_textbox(self.textbox_message_log, "Start speaker2log", "INFO")
|
||||||
|
print_textbox(self.textbox_message_system_log, "Start speaker2log", "INFO")
|
||||||
|
|
||||||
|
def printLogStopSpeaker2log(self):
|
||||||
|
print_textbox(self.textbox_message_log, "Stop speaker2log", "INFO")
|
||||||
|
print_textbox(self.textbox_message_system_log, "Stop speaker2log", "INFO")
|
||||||
|
|
||||||
|
def printLogStartForeground(self):
|
||||||
|
print_textbox(self.textbox_message_log, "Start foreground", "INFO")
|
||||||
|
print_textbox(self.textbox_message_system_log, "Start foreground", "INFO")
|
||||||
|
|
||||||
|
def printLogStopForeground(self):
|
||||||
|
print_textbox(self.textbox_message_log, "Stop foreground", "INFO")
|
||||||
|
print_textbox(self.textbox_message_system_log, "Stop foreground", "INFO")
|
||||||
|
|
||||||
|
def printLogDetectWordFilter(self, message):
|
||||||
|
print_textbox(self.textbox_message_log, f"Detect WordFilter :{message}", "INFO")
|
||||||
|
print_textbox(self.textbox_message_system_log, f"Detect WordFilter :{message}", "INFO")
|
||||||
|
|
||||||
|
def printLogOSCError(self):
|
||||||
|
print_textbox(self.textbox_message_log, "OSC is not enabled, please enable OSC and rejoin.", "ERROR")
|
||||||
|
print_textbox(self.textbox_message_system_log, "OSC is not enabled, please enable OSC and rejoin.", "ERROR")
|
||||||
|
|
||||||
|
def printLogSendMessage(self, message):
|
||||||
|
print_textbox(self.textbox_message_log, f"{message}", "SEND")
|
||||||
|
print_textbox(self.textbox_message_send_log, f"{message}", "SEND")
|
||||||
|
|
||||||
|
def printLogReceiveMessage(self, message):
|
||||||
|
print_textbox(self.textbox_message_log, f"{message}", "RECEIVE")
|
||||||
|
print_textbox(self.textbox_message_receive_log, f"{message}", "RECEIVE")
|
||||||
|
|
||||||
|
def sendChatMessage(self, message):
|
||||||
|
if len(message) > 0:
|
||||||
|
# translate
|
||||||
|
if config.ENABLE_TRANSLATION is False:
|
||||||
|
chat_message = f"{message}"
|
||||||
|
elif model.getTranslatorStatus() is False:
|
||||||
|
self.printLogAuthenticationError()
|
||||||
|
chat_message = f"{message}"
|
||||||
|
else:
|
||||||
|
chat_message = model.getInputTranslate(message)
|
||||||
|
|
||||||
|
# send OSC message
|
||||||
|
if config.ENABLE_OSC is True:
|
||||||
|
model.oscSendMessage(chat_message)
|
||||||
|
else:
|
||||||
|
self.printLogOSCError()
|
||||||
|
|
||||||
|
# update textbox message log
|
||||||
|
self.printLogSendMessage(chat_message)
|
||||||
|
|
||||||
|
# delete message in entry message box
|
||||||
|
if config.ENABLE_AUTO_CLEAR_CHATBOX is True:
|
||||||
|
self.entry_message_box.delete(0, customtkinter.END)
|
||||||
|
|
||||||
|
def sendMicMessage(self, message):
|
||||||
|
if len(message) > 0:
|
||||||
|
# word filter
|
||||||
|
if model.checkKeywords(message):
|
||||||
|
self.printLogDetectWordFilter(message)
|
||||||
|
return
|
||||||
|
|
||||||
|
# translate
|
||||||
|
if config.ENABLE_TRANSLATION is False:
|
||||||
|
voice_message = f"{message}"
|
||||||
|
elif model.getTranslatorStatus() is False:
|
||||||
|
self.printLogAuthenticationError()
|
||||||
|
voice_message = f"{message}"
|
||||||
|
else:
|
||||||
|
voice_message = model.getInputTranslate(message)
|
||||||
|
|
||||||
|
if config.ENABLE_TRANSCRIPTION_SEND is True:
|
||||||
|
if config.ENABLE_OSC is True:
|
||||||
|
# osc send message
|
||||||
|
model.oscSendMessage(voice_message)
|
||||||
|
else:
|
||||||
|
self.printLogOSCError()
|
||||||
|
# update textbox message log
|
||||||
|
self.printLogSendMessage(voice_message)
|
||||||
|
|
||||||
|
def receiveSpeakerMessage(self, message):
|
||||||
|
if len(message) > 0:
|
||||||
|
# translate
|
||||||
|
if config.ENABLE_TRANSLATION is False:
|
||||||
|
voice_message = f"{message}"
|
||||||
|
elif model.getTranslatorStatus() is False:
|
||||||
|
self.printLogAuthenticationError()
|
||||||
|
voice_message = f"{message}"
|
||||||
|
else:
|
||||||
|
voice_message = model.getOutputTranslate(message)
|
||||||
|
|
||||||
|
if config.ENABLE_TRANSCRIPTION_RECEIVE is True:
|
||||||
|
# update textbox message receive log
|
||||||
|
self.printLogReceiveMessage(voice_message)
|
||||||
|
if config.ENABLE_NOTICE_XSOVERLAY is True:
|
||||||
|
model.notificationXsoverlay(voice_message)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
app = App()
|
app = App()
|
||||||
|
|||||||
73
config.py
73
config.py
@@ -1,13 +1,20 @@
|
|||||||
|
from json import load, dump
|
||||||
import inspect
|
import inspect
|
||||||
from os import path as os_path
|
from os import path as os_path
|
||||||
from json import load as json_load
|
from json import load as json_load
|
||||||
from json import dump as json_dump
|
from json import dump as json_dump
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from tkinter import font
|
from tkinter import font
|
||||||
from utils import save_json
|
|
||||||
from languages import transcription_lang, translators, translation_lang, selectable_languages
|
from languages import transcription_lang, translators, translation_lang, selectable_languages
|
||||||
from audio_utils import get_input_device_list, get_output_device_list, get_default_input_device, get_default_output_device
|
from audio_utils import get_input_device_list, get_output_device_list, get_default_input_device, get_default_output_device
|
||||||
|
|
||||||
|
def saveJson(path, key, value):
|
||||||
|
with open(path, "r") as fp:
|
||||||
|
json_data = load(fp)
|
||||||
|
json_data[key] = value
|
||||||
|
with open(path, "w") as fp:
|
||||||
|
dump(json_data, fp, indent=4)
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
_instance = None
|
_instance = None
|
||||||
|
|
||||||
@@ -70,7 +77,7 @@ class Config:
|
|||||||
def TRANSPARENCY(self, value):
|
def TRANSPARENCY(self, value):
|
||||||
if type(value) is int and 0 <= value <= 100:
|
if type(value) is int and 0 <= value <= 100:
|
||||||
self._TRANSPARENCY = value
|
self._TRANSPARENCY = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def APPEARANCE_THEME(self):
|
def APPEARANCE_THEME(self):
|
||||||
@@ -80,7 +87,7 @@ class Config:
|
|||||||
def APPEARANCE_THEME(self, value):
|
def APPEARANCE_THEME(self, value):
|
||||||
if value in ["Light", "Dark", "System"]:
|
if value in ["Light", "Dark", "System"]:
|
||||||
self._APPEARANCE_THEME = value
|
self._APPEARANCE_THEME = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def UI_SCALING(self):
|
def UI_SCALING(self):
|
||||||
@@ -90,7 +97,7 @@ class Config:
|
|||||||
def UI_SCALING(self, value):
|
def UI_SCALING(self, value):
|
||||||
if value in ["80%", "90%", "100%", "110%", "120%"]:
|
if value in ["80%", "90%", "100%", "110%", "120%"]:
|
||||||
self._UI_SCALING = value
|
self._UI_SCALING = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def FONT_FAMILY(self):
|
def FONT_FAMILY(self):
|
||||||
@@ -102,7 +109,7 @@ class Config:
|
|||||||
root.withdraw()
|
root.withdraw()
|
||||||
if value in list(font.families()):
|
if value in list(font.families()):
|
||||||
self._FONT_FAMILY = value
|
self._FONT_FAMILY = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
root.destroy()
|
root.destroy()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -113,7 +120,7 @@ class Config:
|
|||||||
def UI_LANGUAGE(self, value):
|
def UI_LANGUAGE(self, value):
|
||||||
if value in list(selectable_languages.keys()):
|
if value in list(selectable_languages.keys()):
|
||||||
self._UI_LANGUAGE = value
|
self._UI_LANGUAGE = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def CHOICE_TRANSLATOR(self):
|
def CHOICE_TRANSLATOR(self):
|
||||||
@@ -123,7 +130,7 @@ class Config:
|
|||||||
def CHOICE_TRANSLATOR(self, value):
|
def CHOICE_TRANSLATOR(self, value):
|
||||||
if value in translators:
|
if value in translators:
|
||||||
self._CHOICE_TRANSLATOR = value
|
self._CHOICE_TRANSLATOR = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def INPUT_SOURCE_LANG(self):
|
def INPUT_SOURCE_LANG(self):
|
||||||
@@ -133,7 +140,7 @@ class Config:
|
|||||||
def INPUT_SOURCE_LANG(self, value):
|
def INPUT_SOURCE_LANG(self, value):
|
||||||
if value in list(translation_lang[self.CHOICE_TRANSLATOR]["source"].keys()):
|
if value in list(translation_lang[self.CHOICE_TRANSLATOR]["source"].keys()):
|
||||||
self._INPUT_SOURCE_LANG = value
|
self._INPUT_SOURCE_LANG = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def INPUT_TARGET_LANG(self):
|
def INPUT_TARGET_LANG(self):
|
||||||
@@ -143,7 +150,7 @@ class Config:
|
|||||||
def INPUT_TARGET_LANG(self, value):
|
def INPUT_TARGET_LANG(self, value):
|
||||||
if value in list(translation_lang[self.CHOICE_TRANSLATOR]["target"].keys()):
|
if value in list(translation_lang[self.CHOICE_TRANSLATOR]["target"].keys()):
|
||||||
self._INPUT_TARGET_LANG = value
|
self._INPUT_TARGET_LANG = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def OUTPUT_SOURCE_LANG(self):
|
def OUTPUT_SOURCE_LANG(self):
|
||||||
@@ -153,7 +160,7 @@ class Config:
|
|||||||
def OUTPUT_SOURCE_LANG(self, value):
|
def OUTPUT_SOURCE_LANG(self, value):
|
||||||
if value in list(translation_lang[self.CHOICE_TRANSLATOR]["source"].keys()):
|
if value in list(translation_lang[self.CHOICE_TRANSLATOR]["source"].keys()):
|
||||||
self._OUTPUT_SOURCE_LANG = value
|
self._OUTPUT_SOURCE_LANG = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def OUTPUT_TARGET_LANG(self):
|
def OUTPUT_TARGET_LANG(self):
|
||||||
@@ -163,7 +170,7 @@ class Config:
|
|||||||
def OUTPUT_TARGET_LANG(self, value):
|
def OUTPUT_TARGET_LANG(self, value):
|
||||||
if value in list(translation_lang[self.CHOICE_TRANSLATOR]["target"].keys()):
|
if value in list(translation_lang[self.CHOICE_TRANSLATOR]["target"].keys()):
|
||||||
self._OUTPUT_TARGET_LANG = value
|
self._OUTPUT_TARGET_LANG = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def CHOICE_MIC_HOST(self):
|
def CHOICE_MIC_HOST(self):
|
||||||
@@ -173,7 +180,7 @@ class Config:
|
|||||||
def CHOICE_MIC_HOST(self, value):
|
def CHOICE_MIC_HOST(self, value):
|
||||||
if value in [host for host in get_input_device_list().keys()]:
|
if value in [host for host in get_input_device_list().keys()]:
|
||||||
self._CHOICE_MIC_HOST = value
|
self._CHOICE_MIC_HOST = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def CHOICE_MIC_DEVICE(self):
|
def CHOICE_MIC_DEVICE(self):
|
||||||
@@ -183,7 +190,7 @@ class Config:
|
|||||||
def CHOICE_MIC_DEVICE(self, value):
|
def CHOICE_MIC_DEVICE(self, value):
|
||||||
if value in [device["name"] for device in get_input_device_list()[self.CHOICE_MIC_HOST]]:
|
if value in [device["name"] for device in get_input_device_list()[self.CHOICE_MIC_HOST]]:
|
||||||
self._CHOICE_MIC_DEVICE = value
|
self._CHOICE_MIC_DEVICE = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def INPUT_MIC_VOICE_LANGUAGE(self):
|
def INPUT_MIC_VOICE_LANGUAGE(self):
|
||||||
@@ -193,7 +200,7 @@ class Config:
|
|||||||
def INPUT_MIC_VOICE_LANGUAGE(self, value):
|
def INPUT_MIC_VOICE_LANGUAGE(self, value):
|
||||||
if value in list(transcription_lang.keys()):
|
if value in list(transcription_lang.keys()):
|
||||||
self._INPUT_MIC_VOICE_LANGUAGE = value
|
self._INPUT_MIC_VOICE_LANGUAGE = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def INPUT_MIC_ENERGY_THRESHOLD(self):
|
def INPUT_MIC_ENERGY_THRESHOLD(self):
|
||||||
@@ -203,7 +210,7 @@ class Config:
|
|||||||
def INPUT_MIC_ENERGY_THRESHOLD(self, value):
|
def INPUT_MIC_ENERGY_THRESHOLD(self, value):
|
||||||
if type(value) is int:
|
if type(value) is int:
|
||||||
self._INPUT_MIC_ENERGY_THRESHOLD = value
|
self._INPUT_MIC_ENERGY_THRESHOLD = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD(self):
|
def INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD(self):
|
||||||
@@ -213,7 +220,7 @@ class Config:
|
|||||||
def INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD(self, value):
|
def INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD(self, value):
|
||||||
if type(value) is bool:
|
if type(value) is bool:
|
||||||
self._INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD = value
|
self._INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def INPUT_MIC_RECORD_TIMEOUT(self):
|
def INPUT_MIC_RECORD_TIMEOUT(self):
|
||||||
@@ -223,7 +230,7 @@ class Config:
|
|||||||
def INPUT_MIC_RECORD_TIMEOUT(self, value):
|
def INPUT_MIC_RECORD_TIMEOUT(self, value):
|
||||||
if type(value) is int:
|
if type(value) is int:
|
||||||
self._INPUT_MIC_RECORD_TIMEOUT = value
|
self._INPUT_MIC_RECORD_TIMEOUT = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def INPUT_MIC_PHRASE_TIMEOUT(self):
|
def INPUT_MIC_PHRASE_TIMEOUT(self):
|
||||||
@@ -233,7 +240,7 @@ class Config:
|
|||||||
def INPUT_MIC_PHRASE_TIMEOUT(self, value):
|
def INPUT_MIC_PHRASE_TIMEOUT(self, value):
|
||||||
if type(value) is int:
|
if type(value) is int:
|
||||||
self._INPUT_MIC_PHRASE_TIMEOUT = value
|
self._INPUT_MIC_PHRASE_TIMEOUT = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def INPUT_MIC_MAX_PHRASES(self):
|
def INPUT_MIC_MAX_PHRASES(self):
|
||||||
@@ -243,7 +250,7 @@ class Config:
|
|||||||
def INPUT_MIC_MAX_PHRASES(self, value):
|
def INPUT_MIC_MAX_PHRASES(self, value):
|
||||||
if type(value) is int:
|
if type(value) is int:
|
||||||
self._INPUT_MIC_MAX_PHRASES = value
|
self._INPUT_MIC_MAX_PHRASES = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def INPUT_MIC_WORD_FILTER(self):
|
def INPUT_MIC_WORD_FILTER(self):
|
||||||
@@ -253,7 +260,7 @@ class Config:
|
|||||||
def INPUT_MIC_WORD_FILTER(self, value):
|
def INPUT_MIC_WORD_FILTER(self, value):
|
||||||
if type(value) is list:
|
if type(value) is list:
|
||||||
self._INPUT_MIC_WORD_FILTER = value
|
self._INPUT_MIC_WORD_FILTER = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def CHOICE_SPEAKER_DEVICE(self):
|
def CHOICE_SPEAKER_DEVICE(self):
|
||||||
@@ -265,7 +272,7 @@ class Config:
|
|||||||
speaker_device = [device for device in get_output_device_list() if device["name"] == value][0]
|
speaker_device = [device for device in get_output_device_list() if device["name"] == value][0]
|
||||||
if get_default_output_device()["index"] == speaker_device["index"]:
|
if get_default_output_device()["index"] == speaker_device["index"]:
|
||||||
self._CHOICE_SPEAKER_DEVICE = value
|
self._CHOICE_SPEAKER_DEVICE = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def INPUT_SPEAKER_VOICE_LANGUAGE(self):
|
def INPUT_SPEAKER_VOICE_LANGUAGE(self):
|
||||||
@@ -275,7 +282,7 @@ class Config:
|
|||||||
def INPUT_SPEAKER_VOICE_LANGUAGE(self, value):
|
def INPUT_SPEAKER_VOICE_LANGUAGE(self, value):
|
||||||
if value in list(transcription_lang.keys()):
|
if value in list(transcription_lang.keys()):
|
||||||
self._INPUT_SPEAKER_VOICE_LANGUAGE = value
|
self._INPUT_SPEAKER_VOICE_LANGUAGE = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def INPUT_SPEAKER_ENERGY_THRESHOLD(self):
|
def INPUT_SPEAKER_ENERGY_THRESHOLD(self):
|
||||||
@@ -285,7 +292,7 @@ class Config:
|
|||||||
def INPUT_SPEAKER_ENERGY_THRESHOLD(self, value):
|
def INPUT_SPEAKER_ENERGY_THRESHOLD(self, value):
|
||||||
if type(value) is int:
|
if type(value) is int:
|
||||||
self._INPUT_SPEAKER_ENERGY_THRESHOLD = value
|
self._INPUT_SPEAKER_ENERGY_THRESHOLD = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD(self):
|
def INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD(self):
|
||||||
@@ -295,7 +302,7 @@ class Config:
|
|||||||
def INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD(self, value):
|
def INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD(self, value):
|
||||||
if type(value) is bool:
|
if type(value) is bool:
|
||||||
self._INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD = value
|
self._INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def INPUT_SPEAKER_RECORD_TIMEOUT(self):
|
def INPUT_SPEAKER_RECORD_TIMEOUT(self):
|
||||||
@@ -305,7 +312,7 @@ class Config:
|
|||||||
def INPUT_SPEAKER_RECORD_TIMEOUT(self, value):
|
def INPUT_SPEAKER_RECORD_TIMEOUT(self, value):
|
||||||
if type(value) is int:
|
if type(value) is int:
|
||||||
self._INPUT_SPEAKER_RECORD_TIMEOUT = value
|
self._INPUT_SPEAKER_RECORD_TIMEOUT = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def INPUT_SPEAKER_PHRASE_TIMEOUT(self):
|
def INPUT_SPEAKER_PHRASE_TIMEOUT(self):
|
||||||
@@ -315,7 +322,7 @@ class Config:
|
|||||||
def INPUT_SPEAKER_PHRASE_TIMEOUT(self, value):
|
def INPUT_SPEAKER_PHRASE_TIMEOUT(self, value):
|
||||||
if type(value) is int:
|
if type(value) is int:
|
||||||
self._INPUT_SPEAKER_PHRASE_TIMEOUT = value
|
self._INPUT_SPEAKER_PHRASE_TIMEOUT = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def INPUT_SPEAKER_MAX_PHRASES(self):
|
def INPUT_SPEAKER_MAX_PHRASES(self):
|
||||||
@@ -325,7 +332,7 @@ class Config:
|
|||||||
def INPUT_SPEAKER_MAX_PHRASES(self, value):
|
def INPUT_SPEAKER_MAX_PHRASES(self, value):
|
||||||
if type(value) is int:
|
if type(value) is int:
|
||||||
self._INPUT_SPEAKER_MAX_PHRASES = value
|
self._INPUT_SPEAKER_MAX_PHRASES = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def OSC_IP_ADDRESS(self):
|
def OSC_IP_ADDRESS(self):
|
||||||
@@ -335,7 +342,7 @@ class Config:
|
|||||||
def OSC_IP_ADDRESS(self, value):
|
def OSC_IP_ADDRESS(self, value):
|
||||||
if type(value) is str:
|
if type(value) is str:
|
||||||
self._OSC_IP_ADDRESS = value
|
self._OSC_IP_ADDRESS = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def OSC_PORT(self):
|
def OSC_PORT(self):
|
||||||
@@ -345,7 +352,7 @@ class Config:
|
|||||||
def OSC_PORT(self, value):
|
def OSC_PORT(self, value):
|
||||||
if type(value) is int:
|
if type(value) is int:
|
||||||
self._OSC_PORT = value
|
self._OSC_PORT = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def AUTH_KEYS(self):
|
def AUTH_KEYS(self):
|
||||||
@@ -357,7 +364,7 @@ class Config:
|
|||||||
for key, value in value.items():
|
for key, value in value.items():
|
||||||
if type(value) is str:
|
if type(value) is str:
|
||||||
self._AUTH_KEYS[key] = value
|
self._AUTH_KEYS[key] = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, self.AUTH_KEYS)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, self.AUTH_KEYS)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def MESSAGE_FORMAT(self):
|
def MESSAGE_FORMAT(self):
|
||||||
@@ -367,7 +374,7 @@ class Config:
|
|||||||
def MESSAGE_FORMAT(self, value):
|
def MESSAGE_FORMAT(self, value):
|
||||||
if type(value) is str:
|
if type(value) is str:
|
||||||
self._MESSAGE_FORMAT = value
|
self._MESSAGE_FORMAT = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ENABLE_AUTO_CLEAR_CHATBOX(self):
|
def ENABLE_AUTO_CLEAR_CHATBOX(self):
|
||||||
@@ -377,7 +384,7 @@ class Config:
|
|||||||
def ENABLE_AUTO_CLEAR_CHATBOX(self, value):
|
def ENABLE_AUTO_CLEAR_CHATBOX(self, value):
|
||||||
if type(value) is bool:
|
if type(value) is bool:
|
||||||
self._ENABLE_AUTO_CLEAR_CHATBOX = value
|
self._ENABLE_AUTO_CLEAR_CHATBOX = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ENABLE_NOTICE_XSOVERLAY(self):
|
def ENABLE_NOTICE_XSOVERLAY(self):
|
||||||
@@ -387,7 +394,7 @@ class Config:
|
|||||||
def ENABLE_NOTICE_XSOVERLAY(self, value):
|
def ENABLE_NOTICE_XSOVERLAY(self, value):
|
||||||
if type(value) is bool:
|
if type(value) is bool:
|
||||||
self._ENABLE_NOTICE_XSOVERLAY = value
|
self._ENABLE_NOTICE_XSOVERLAY = value
|
||||||
save_json(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ENABLE_OSC(self):
|
def ENABLE_OSC(self):
|
||||||
|
|||||||
57
model.py
57
model.py
@@ -11,9 +11,9 @@ from audio_utils import get_input_device_list, get_output_device_list, get_defau
|
|||||||
from audio_recorder import SelectedMicRecorder, SelectedSpeakerRecorder
|
from audio_recorder import SelectedMicRecorder, SelectedSpeakerRecorder
|
||||||
from audio_recorder import SelectedMicEnergyRecorder, SelectedSpeakeEnergyRecorder
|
from audio_recorder import SelectedMicEnergyRecorder, SelectedSpeakeEnergyRecorder
|
||||||
from audio_transcriber import AudioTranscriber
|
from audio_transcriber import AudioTranscriber
|
||||||
from utils import print_textbox, thread_fnc
|
|
||||||
from config import config
|
|
||||||
from notification import notification_xsoverlay_for_vrct
|
from notification import notification_xsoverlay_for_vrct
|
||||||
|
from utils import thread_fnc
|
||||||
|
from config import config
|
||||||
|
|
||||||
class Model:
|
class Model:
|
||||||
_instance = None
|
_instance = None
|
||||||
@@ -141,7 +141,7 @@ class Model:
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def startMicTranscript(self, log, send_log, system_log):
|
def startMicTranscript(self, fnc):
|
||||||
mic_audio_queue = Queue()
|
mic_audio_queue = Queue()
|
||||||
self.mic_audio_recorder = SelectedMicRecorder(
|
self.mic_audio_recorder = SelectedMicRecorder(
|
||||||
[device for device in get_input_device_list()[config.CHOICE_MIC_HOST] if device["name"] == config.CHOICE_MIC_DEVICE][0],
|
[device for device in get_input_device_list()[config.CHOICE_MIC_HOST] if device["name"] == config.CHOICE_MIC_DEVICE][0],
|
||||||
@@ -159,33 +159,7 @@ class Model:
|
|||||||
def mic_transcript_to_chatbox():
|
def mic_transcript_to_chatbox():
|
||||||
mic_transcriber.transcribe_audio_queue(mic_audio_queue, transcription_lang[config.INPUT_MIC_VOICE_LANGUAGE])
|
mic_transcriber.transcribe_audio_queue(mic_audio_queue, transcription_lang[config.INPUT_MIC_VOICE_LANGUAGE])
|
||||||
message = mic_transcriber.get_transcript()
|
message = mic_transcriber.get_transcript()
|
||||||
if len(message) > 0:
|
fnc(message)
|
||||||
# word filter
|
|
||||||
if self.checkKeywords(message):
|
|
||||||
print_textbox(log, f"Detect WordFilter :{message}", "INFO")
|
|
||||||
print_textbox(system_log, f"Detect WordFilter :{message}", "INFO")
|
|
||||||
return
|
|
||||||
|
|
||||||
# translate
|
|
||||||
if config.ENABLE_TRANSLATION is False:
|
|
||||||
voice_message = f"{message}"
|
|
||||||
elif self.getTranslatorStatus() is False:
|
|
||||||
print_textbox(log, "Auth Key or language setting is incorrect", "ERROR")
|
|
||||||
print_textbox(system_log, "Auth Key or language setting is incorrect", "ERROR")
|
|
||||||
voice_message = f"{message}"
|
|
||||||
else:
|
|
||||||
voice_message = self.getInputTranslate(message)
|
|
||||||
|
|
||||||
if config.ENABLE_TRANSCRIPTION_SEND is True:
|
|
||||||
if config.ENABLE_OSC is True:
|
|
||||||
# osc send message
|
|
||||||
model.oscSendMessage(voice_message)
|
|
||||||
else:
|
|
||||||
print_textbox(log, "OSC is not enabled, please enable OSC and rejoin.", "ERROR")
|
|
||||||
print_textbox(system_log, "OSC is not enabled, please enable OSC and rejoin.", "ERROR")
|
|
||||||
# update textbox message log
|
|
||||||
print_textbox(log, f"{voice_message}", "SEND")
|
|
||||||
print_textbox(send_log, f"{voice_message}", "SEND")
|
|
||||||
|
|
||||||
self.mic_print_transcript = 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.daemon = True
|
||||||
@@ -221,7 +195,7 @@ class Model:
|
|||||||
if self.mic_energy_plot_progressbar != None:
|
if self.mic_energy_plot_progressbar != None:
|
||||||
self.mic_energy_plot_progressbar.stop()
|
self.mic_energy_plot_progressbar.stop()
|
||||||
|
|
||||||
def startSpeakerTranscript(self, log, receive_log, system_log):
|
def startSpeakerTranscript(self, fnc):
|
||||||
spk_audio_queue = Queue()
|
spk_audio_queue = Queue()
|
||||||
spk_device = [device for device in get_output_device_list() if device["name"] == config.CHOICE_SPEAKER_DEVICE][0]
|
spk_device = [device for device in get_output_device_list() if device["name"] == config.CHOICE_SPEAKER_DEVICE][0]
|
||||||
self.spk_audio_recorder = SelectedSpeakerRecorder(
|
self.spk_audio_recorder = SelectedSpeakerRecorder(
|
||||||
@@ -240,23 +214,7 @@ class Model:
|
|||||||
def spk_transcript_to_textbox():
|
def spk_transcript_to_textbox():
|
||||||
spk_transcriber.transcribe_audio_queue(spk_audio_queue, transcription_lang[config.INPUT_SPEAKER_VOICE_LANGUAGE])
|
spk_transcriber.transcribe_audio_queue(spk_audio_queue, transcription_lang[config.INPUT_SPEAKER_VOICE_LANGUAGE])
|
||||||
message = spk_transcriber.get_transcript()
|
message = spk_transcriber.get_transcript()
|
||||||
if len(message) > 0:
|
fnc(message)
|
||||||
# translate
|
|
||||||
if config.ENABLE_TRANSLATION is False:
|
|
||||||
voice_message = f"{message}"
|
|
||||||
elif model.getTranslatorStatus() is False:
|
|
||||||
print_textbox(log, "Auth Key or language setting is incorrect", "ERROR")
|
|
||||||
print_textbox(system_log, "Auth Key or language setting is incorrect", "ERROR")
|
|
||||||
voice_message = f"{message}"
|
|
||||||
else:
|
|
||||||
voice_message = model.getOutputTranslate(message)
|
|
||||||
|
|
||||||
if config.ENABLE_TRANSCRIPTION_RECEIVE is True:
|
|
||||||
# update textbox message receive log
|
|
||||||
print_textbox(log, f"{voice_message}", "RECEIVE")
|
|
||||||
print_textbox(receive_log, f"{voice_message}", "RECEIVE")
|
|
||||||
if config.ENABLE_NOTICE_XSOVERLAY is True:
|
|
||||||
notification_xsoverlay_for_vrct(content=f"{voice_message}")
|
|
||||||
|
|
||||||
self.spk_print_transcript = thread_fnc(spk_transcript_to_textbox)
|
self.spk_print_transcript = thread_fnc(spk_transcript_to_textbox)
|
||||||
self.spk_print_transcript.daemon = True
|
self.spk_print_transcript.daemon = True
|
||||||
@@ -300,4 +258,7 @@ class Model:
|
|||||||
if self.speaker_energy_plot_progressbar != None:
|
if self.speaker_energy_plot_progressbar != None:
|
||||||
self.speaker_energy_plot_progressbar.stop()
|
self.speaker_energy_plot_progressbar.stop()
|
||||||
|
|
||||||
|
def notificationXsoverlay(self, message):
|
||||||
|
notification_xsoverlay_for_vrct(content=f"{message}")
|
||||||
|
|
||||||
model = Model()
|
model = Model()
|
||||||
|
|||||||
10
utils.py
10
utils.py
@@ -1,16 +1,8 @@
|
|||||||
from json import load, dump
|
|
||||||
from os import path as os_path
|
from os import path as os_path
|
||||||
import yaml
|
import yaml
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from threading import Thread, Event
|
from threading import Thread, Event
|
||||||
|
|
||||||
def save_json(path, key, value):
|
|
||||||
with open(path, "r") as fp:
|
|
||||||
json_data = load(fp)
|
|
||||||
json_data[key] = value
|
|
||||||
with open(path, "w") as fp:
|
|
||||||
dump(json_data, fp, indent=4)
|
|
||||||
|
|
||||||
def print_textbox(textbox, message, tags=None):
|
def print_textbox(textbox, message, tags=None):
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
now = now.strftime('%H:%M:%S')
|
now = now.strftime('%H:%M:%S')
|
||||||
@@ -58,7 +50,7 @@ def get_localized_text(language):
|
|||||||
return localized_text
|
return localized_text
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_key_by_value(dictionary, value):
|
def get_key_by_value(dictionary, value):
|
||||||
for key, val in dictionary.items():
|
for key, val in dictionary.items():
|
||||||
if val == value:
|
if val == value:
|
||||||
|
|||||||
Reference in New Issue
Block a user