Merge branch 'models' into for_webui

This commit is contained in:
misyaguziya
2024-09-01 19:18:06 +09:00
8 changed files with 152 additions and 146 deletions

View File

@@ -1,4 +1,3 @@
import os
import ctypes import ctypes
import time import time
from psutil import process_iter from psutil import process_iter
@@ -10,6 +9,7 @@ try:
from . import overlay_utils as utils from . import overlay_utils as utils
except ImportError: except ImportError:
import overlay_utils as utils import overlay_utils as utils
from utils import printLog
def mat34Id(array): def mat34Id(array):
arr = openvr.HmdMatrix34_t() arr = openvr.HmdMatrix34_t()
@@ -109,8 +109,7 @@ class Overlay:
) )
except Exception as e: except Exception as e:
import json printLog("error:Could not initialise OpenVR", e)
print(json.dumps({"status":348, "log": f"error:Could not initialise OpenVR {e}"}), flush=True)
def updateImage(self, img): def updateImage(self, img):
if self.initialized is True: if self.initialized is True:
@@ -204,8 +203,7 @@ class Overlay:
return False return False
return True return True
except Exception as e: except Exception as e:
import json printLog("error:Could not check SteamVR running", e)
print(json.dumps({"status":348, "log": f"error:Could not check SteamVR running {e}"}), flush=True)
return False return False
def evaluateOpacityFade(self, lastUpdate, currentTime): def evaluateOpacityFade(self, lastUpdate, currentTime):

View File

@@ -11,6 +11,8 @@ from .transcription_whisper import getWhisperModel, checkWhisperWeight
import torch import torch
import numpy as np import numpy as np
from pydub import AudioSegment from pydub import AudioSegment
import warnings
warnings.simplefilter('ignore', RuntimeWarning)
PHRASE_TIMEOUT = 3 PHRASE_TIMEOUT = 3
MAX_PHRASES = 10 MAX_PHRASES = 10

View File

@@ -4,6 +4,8 @@ from typing import Callable
import huggingface_hub import huggingface_hub
from faster_whisper import WhisperModel from faster_whisper import WhisperModel
import logging import logging
from utils import printLog
logger = logging.getLogger('faster_whisper') logger = logging.getLogger('faster_whisper')
logger.setLevel(logging.CRITICAL) logger.setLevel(logging.CRITICAL)
@@ -33,15 +35,14 @@ def downloadFile(url, path, func=None):
file_size = int(res.headers.get('content-length', 0)) file_size = int(res.headers.get('content-length', 0))
total_chunk = 0 total_chunk = 0
with open(os_path.join(path), 'wb') as file: with open(os_path.join(path), 'wb') as file:
for chunk in res.iter_content(chunk_size=1024*5): for chunk in res.iter_content(chunk_size=1024*2000):
file.write(chunk) file.write(chunk)
if isinstance(func, Callable): if isinstance(func, Callable):
total_chunk += len(chunk) total_chunk += len(chunk)
func(total_chunk/file_size) func(total_chunk/file_size)
except Exception as e: except Exception as e:
import json printLog("warning:downloadFile()", e)
print(json.dumps({"status":348, "log": f"error:downloadFile() {e}"}), flush=True)
def checkWhisperWeight(root, weight_type): def checkWhisperWeight(root, weight_type):
path = os_path.join(root, "weights", "whisper", weight_type) path = os_path.join(root, "weights", "whisper", weight_type)

View File

@@ -1,4 +1,4 @@
import os from os import path as os_path
from deepl import Translator as deepl_Translator from deepl import Translator as deepl_Translator
from translators import translate_text as other_web_Translator from translators import translate_text as other_web_Translator
from .translation_languages import translation_lang from .translation_languages import translation_lang
@@ -6,6 +6,7 @@ from .translation_utils import ctranslate2_weights
import ctranslate2 import ctranslate2
import transformers import transformers
from utils import printLog
import warnings import warnings
warnings.filterwarnings("ignore") warnings.filterwarnings("ignore")
@@ -32,8 +33,8 @@ class Translator():
self.is_loaded_ctranslate2_model = False self.is_loaded_ctranslate2_model = False
directory_name = ctranslate2_weights[model_type]["directory_name"] directory_name = ctranslate2_weights[model_type]["directory_name"]
tokenizer = ctranslate2_weights[model_type]["tokenizer"] tokenizer = ctranslate2_weights[model_type]["tokenizer"]
weight_path = os.path.join(path, "weights", "ctranslate2", directory_name) weight_path = os_path.join(path, "weights", "ctranslate2", directory_name)
tokenizer_path = os.path.join(path, "weights", "ctranslate2", directory_name, "tokenizer") tokenizer_path = os_path.join(path, "weights", "ctranslate2", directory_name, "tokenizer")
self.ctranslate2_translator = ctranslate2.Translator( self.ctranslate2_translator = ctranslate2.Translator(
weight_path, weight_path,
device="cpu", device="cpu",
@@ -45,9 +46,8 @@ class Translator():
try: try:
self.ctranslate2_tokenizer = transformers.AutoTokenizer.from_pretrained(tokenizer, cache_dir=tokenizer_path) self.ctranslate2_tokenizer = transformers.AutoTokenizer.from_pretrained(tokenizer, cache_dir=tokenizer_path)
except Exception as e: except Exception as e:
import json printLog("error:changeCTranslate2Model()", e)
print(json.dumps({"status":348, "log": f"error:changeCTranslate2Model() {e}"}), flush=True) tokenizer_path = os_path.join("./weights", "ctranslate2", directory_name, "tokenizer")
tokenizer_path = os.path.join("./weights", "ctranslate2", directory_name, "tokenizer")
self.ctranslate2_tokenizer = transformers.AutoTokenizer.from_pretrained(tokenizer, cache_dir=tokenizer_path) self.ctranslate2_tokenizer = transformers.AutoTokenizer.from_pretrained(tokenizer, cache_dir=tokenizer_path)
self.is_loaded_ctranslate2_model = True self.is_loaded_ctranslate2_model = True

View File

@@ -5,6 +5,7 @@ from os import makedirs as os_makedirs
from requests import get as requests_get from requests import get as requests_get
from typing import Callable from typing import Callable
import hashlib import hashlib
from utils import printLog
ctranslate2_weights = { ctranslate2_weights = {
"Small": { # M2M-100 418M-parameter model "Small": { # M2M-100 418M-parameter model
@@ -75,14 +76,14 @@ def downloadCTranslate2Weight(root, weight_type="Small", callbackFunc=None):
file_size = int(res.headers.get('content-length', 0)) file_size = int(res.headers.get('content-length', 0))
total_chunk = 0 total_chunk = 0
with open(os_path.join(tmp_path, filename), 'wb') as file: with open(os_path.join(tmp_path, filename), 'wb') as file:
for chunk in res.iter_content(chunk_size=1024*5): for chunk in res.iter_content(chunk_size=1024*2000):
file.write(chunk) file.write(chunk)
if isinstance(callbackFunc, Callable): if isinstance(callbackFunc, Callable):
total_chunk += len(chunk) total_chunk += len(chunk)
callbackFunc(total_chunk/file_size) callbackFunc(total_chunk/file_size)
printLog(f"Downloading {filename}: {total_chunk/file_size:.0%}")
with ZipFile(os_path.join(tmp_path, filename)) as zf: with ZipFile(os_path.join(tmp_path, filename)) as zf:
zf.extractall(path) zf.extractall(path)
except Exception as e: except Exception as e:
import json printLog("error:downloadCTranslate2Weight()", e)
print(json.dumps({"status":348, "log": f"error:downloadCTranslate2Weight() {e}"}), flush=True)

View File

@@ -1,3 +1,5 @@
from typing import Any
import json
import random import random
from typing import Union from typing import Union
from os import path as os_path, rename as os_rename from os import path as os_path, rename as os_rename
@@ -69,4 +71,15 @@ def splitList(lst:list, split_count:int, to_shuffle:bool=False):
for i in range(0, len(lst), split_count): for i in range(0, len(lst), split_count):
sub_list = lst[i:i+split_count] sub_list = lst[i:i+split_count]
split_lists.append(sub_list) split_lists.append(sub_list)
return split_lists return split_lists
def encodeUtf8(data:str) -> dict:
data = {i: byte for i, byte in enumerate(data.encode('UTF-8'))}
return data
def decodeUtf8(data:dict) -> str:
data = bytes(data.values()).decode("UTF-8")
return data
def printLog(log:str, data:Any=None) -> None:
print(json.dumps({"status":348, "log":log, "data":str(data)}), flush=True)

View File

@@ -5,23 +5,15 @@ from subprocess import Popen
from threading import Thread from threading import Thread
from config import config from config import config
from model import model from model import model
from utils import getKeyByValue, isUniqueStrings from utils import getKeyByValue, isUniqueStrings, decodeUtf8, encodeUtf8, printLog
# Common # Common
def encodeUtf8(data:str) -> dict:
data = {i: byte for i, byte in enumerate(data.encode('UTF-8'))}
return data
def decodeUtf8(data:dict) -> str:
data = bytes(data.values()).decode("UTF-8")
return data
class DownloadSoftwareProgressBar: class DownloadSoftwareProgressBar:
def __init__(self, action): def __init__(self, action):
self.action = action self.action = action
def set(self, progress) -> None: def set(self, progress) -> None:
print(json.dumps({"status":348, "log": "Software Download Progress", "data":progress}), flush=True) printLog("Software Download Progress", progress)
self.action("download", { self.action("download", {
"status":200, "status":200,
"result":{ "result":{
@@ -34,7 +26,7 @@ class UpdateSoftwareProgressBar:
self.action = action self.action = action
def set(self, progress) -> None: def set(self, progress) -> None:
print(json.dumps({"status":348, "log": "Software Update Progress", "data":progress}), flush=True) printLog("Software Update Progress", progress)
self.action("update", { self.action("update", {
"status":200, "status":200,
"result":{ "result":{
@@ -43,29 +35,29 @@ class UpdateSoftwareProgressBar:
}) })
def callbackUpdateSoftware(data, action, *args, **kwargs) -> dict: def callbackUpdateSoftware(data, action, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackUpdateSoftware"}), flush=True) printLog("Update callbackUpdateSoftware")
download = DownloadSoftwareProgressBar(action) download = DownloadSoftwareProgressBar(action)
update = UpdateSoftwareProgressBar(action) update = UpdateSoftwareProgressBar(action)
model.updateSoftware(restart=True, download=download.set, update=update.set) model.updateSoftware(restart=True, download=download.set, update=update.set)
return {"status":200} return {"status":200}
def callbackRestartSoftware(*args, **kwargs) -> dict: def callbackRestartSoftware(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackRestartSoftware"}), flush=True) printLog("Restart callbackRestartSoftware")
model.reStartSoftware() model.reStartSoftware()
return {"status":200} return {"status":200}
def callbackFilepathLogs(*args, **kwargs) -> dict: def callbackFilepathLogs(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackFilepathLogs"}), flush=True) printLog("Open Logs Folder")
Popen(['explorer', config.PATH_LOGS.replace('/', '\\')], shell=True) Popen(['explorer', config.PATH_LOGS.replace('/', '\\')], shell=True)
return {"status":200} return {"status":200}
def callbackFilepathConfigFile(*args, **kwargs) -> dict: def callbackFilepathConfigFile(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackFilepathConfigFile"}), flush=True) printLog("Open Config File")
Popen(['explorer', config.PATH_LOCAL.replace('/', '\\')], shell=True) Popen(['explorer', config.PATH_LOCAL.replace('/', '\\')], shell=True)
return {"status":200} return {"status":200}
# def callbackEnableEasterEgg(): # def callbackEnableEasterEgg():
# print(json.dumps({"status":348, "log": "callbackEnableEasterEgg"}), flush=True) # printLog("Enable Easter Egg")
# config.IS_EASTER_EGG_ENABLED = True # config.IS_EASTER_EGG_ENABLED = True
# config.OVERLAY_UI_TYPE = "sakura" # config.OVERLAY_UI_TYPE = "sakura"
# return {"status":200, "result":config.IS_EASTER_EGG_ENABLED} # return {"status":200, "result":config.IS_EASTER_EGG_ENABLED}
@@ -439,7 +431,7 @@ def setTargetTranslateEngine(select):
config.CHOICE_OUTPUT_TRANSLATOR = select config.CHOICE_OUTPUT_TRANSLATOR = select
def setYourLanguageAndCountry(select:dict, *args, **kwargs) -> dict: def setYourLanguageAndCountry(select:dict, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "setYourLanguageAndCountry", "data":select}), flush=True) printLog("setYourLanguageAndCountry", select)
languages = config.SELECTED_TAB_YOUR_LANGUAGES languages = config.SELECTED_TAB_YOUR_LANGUAGES
languages[config.SELECTED_TAB_NO] = select languages[config.SELECTED_TAB_NO] = select
config.SELECTED_TAB_YOUR_LANGUAGES = languages config.SELECTED_TAB_YOUR_LANGUAGES = languages
@@ -456,7 +448,7 @@ def setYourLanguageAndCountry(select:dict, *args, **kwargs) -> dict:
} }
def setTargetLanguageAndCountry(select:dict, *args, **kwargs) -> dict: def setTargetLanguageAndCountry(select:dict, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "setTargetLanguageAndCountry", "data":select}), flush=True) printLog("setTargetLanguageAndCountry", select)
languages = config.SELECTED_TAB_TARGET_LANGUAGES languages = config.SELECTED_TAB_TARGET_LANGUAGES
languages[config.SELECTED_TAB_NO] = select languages[config.SELECTED_TAB_NO] = select
config.SELECTED_TAB_TARGET_LANGUAGES = languages config.SELECTED_TAB_TARGET_LANGUAGES = languages
@@ -473,7 +465,7 @@ def setTargetLanguageAndCountry(select:dict, *args, **kwargs) -> dict:
} }
def swapYourLanguageAndTargetLanguage(*args, **kwargs) -> dict: def swapYourLanguageAndTargetLanguage(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "swapYourLanguageAndTargetLanguage"}), flush=True) printLog("swapYourLanguageAndTargetLanguage")
your_language = config.SELECTED_TAB_YOUR_LANGUAGES[config.SELECTED_TAB_NO] your_language = config.SELECTED_TAB_YOUR_LANGUAGES[config.SELECTED_TAB_NO]
target_language = config.SELECTED_TAB_TARGET_LANGUAGES[config.SELECTED_TAB_NO] target_language = config.SELECTED_TAB_TARGET_LANGUAGES[config.SELECTED_TAB_NO]
setYourLanguageAndCountry(target_language) setYourLanguageAndCountry(target_language)
@@ -491,7 +483,7 @@ def swapYourLanguageAndTargetLanguage(*args, **kwargs) -> dict:
} }
def callbackSelectedLanguagePresetTab(selected_tab_no:str, *args, **kwargs) -> dict: def callbackSelectedLanguagePresetTab(selected_tab_no:str, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSelectedLanguagePresetTab", "data":selected_tab_no}), flush=True) printLog("callbackSelectedLanguagePresetTab", selected_tab_no)
config.SELECTED_TAB_NO = selected_tab_no config.SELECTED_TAB_NO = selected_tab_no
engines = config.SELECTED_TAB_YOUR_TRANSLATOR_ENGINES engines = config.SELECTED_TAB_YOUR_TRANSLATOR_ENGINES
@@ -515,38 +507,38 @@ def callbackSelectedLanguagePresetTab(selected_tab_no:str, *args, **kwargs) -> d
return {"status":200, "result":config.SELECTED_TAB_NO} return {"status":200, "result":config.SELECTED_TAB_NO}
def callbackSelectedTranslationEngine(selected_translation_engine:str, *args, **kwargs) -> dict: def callbackSelectedTranslationEngine(selected_translation_engine:str, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSelectedTranslationEngine", "data":selected_translation_engine}), flush=True) printLog("callbackSelectedTranslationEngine", selected_translation_engine)
setYourTranslateEngine(selected_translation_engine) setYourTranslateEngine(selected_translation_engine)
setTargetTranslateEngine(selected_translation_engine) setTargetTranslateEngine(selected_translation_engine)
return {"status":200, "result":selected_translation_engine} return {"status":200, "result":selected_translation_engine}
# command func # command func
def callbackEnableTranslation(*args, **kwargs) -> dict: def callbackEnableTranslation(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackEnableTranslation"}), flush=True) printLog("Enable Translation")
config.ENABLE_TRANSLATION = True config.ENABLE_TRANSLATION = True
if model.isLoadedCTranslate2Model() is False: if model.isLoadedCTranslate2Model() is False:
model.changeTranslatorCTranslate2Model() model.changeTranslatorCTranslate2Model()
return {"status":200, "result":config.ENABLE_TRANSLATION} return {"status":200, "result":config.ENABLE_TRANSLATION}
def callbackDisableTranslation(*args, **kwargs) -> dict: def callbackDisableTranslation(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackDisableTranslation"}), flush=True) printLog("Disable Translation")
config.ENABLE_TRANSLATION = False config.ENABLE_TRANSLATION = False
return {"status":200, "result":config.ENABLE_TRANSLATION} return {"status":200, "result":config.ENABLE_TRANSLATION}
def callbackEnableTranscriptionSend(data, action, *args, **kwargs) -> dict: def callbackEnableTranscriptionSend(data, action, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackEnableTranscriptionSend"}), flush=True) printLog("Enable Transcription Send")
config.ENABLE_TRANSCRIPTION_SEND = True config.ENABLE_TRANSCRIPTION_SEND = True
startThreadingTranscriptionSendMessage(action) startThreadingTranscriptionSendMessage(action)
return {"status":200, "result":config.ENABLE_TRANSCRIPTION_SEND} return {"status":200, "result":config.ENABLE_TRANSCRIPTION_SEND}
def callbackDisableTranscriptionSend(data, action, *args, **kwargs) -> dict: def callbackDisableTranscriptionSend(data, action, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackDisableTranscriptionSend"}), flush=True) printLog("Disable Transcription Send")
config.ENABLE_TRANSCRIPTION_SEND = False config.ENABLE_TRANSCRIPTION_SEND = False
stopThreadingTranscriptionSendMessage(action) stopThreadingTranscriptionSendMessage(action)
return {"status":200, "result":config.ENABLE_TRANSCRIPTION_SEND} return {"status":200, "result":config.ENABLE_TRANSCRIPTION_SEND}
def callbackEnableTranscriptionReceive(data, action, *args, **kwargs) -> dict: def callbackEnableTranscriptionReceive(data, action, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackEnableTranscriptionReceive"}), flush=True) printLog("Enable Transcription Receive")
config.ENABLE_TRANSCRIPTION_RECEIVE = True config.ENABLE_TRANSCRIPTION_RECEIVE = True
startThreadingTranscriptionReceiveMessage(action) startThreadingTranscriptionReceiveMessage(action)
@@ -556,34 +548,34 @@ def callbackEnableTranscriptionReceive(data, action, *args, **kwargs) -> dict:
return {"status":200, "result":config.ENABLE_TRANSCRIPTION_RECEIVE} return {"status":200, "result":config.ENABLE_TRANSCRIPTION_RECEIVE}
def callbackDisableTranscriptionReceive(data, action, *args, **kwargs) -> dict: def callbackDisableTranscriptionReceive(data, action, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackDisableTranscriptionReceive"}), flush=True) printLog("Disable Transcription Receive")
config.ENABLE_TRANSCRIPTION_RECEIVE = False config.ENABLE_TRANSCRIPTION_RECEIVE = False
stopThreadingTranscriptionReceiveMessage(action) stopThreadingTranscriptionReceiveMessage(action)
return {"status":200, "result":config.ENABLE_TRANSCRIPTION_RECEIVE} return {"status":200, "result":config.ENABLE_TRANSCRIPTION_RECEIVE}
def callbackEnableForeground(*args, **kwargs) -> dict: def callbackEnableForeground(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackEnableForeground"}), flush=True) printLog("Enable Foreground")
config.ENABLE_FOREGROUND = True config.ENABLE_FOREGROUND = True
return {"status":200, "result":config.ENABLE_FOREGROUND} return {"status":200, "result":config.ENABLE_FOREGROUND}
def callbackDisableForeground(*args, **kwargs) -> dict: def callbackDisableForeground(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackDisableForeground"}), flush=True) printLog("Disable Foreground")
config.ENABLE_FOREGROUND = False config.ENABLE_FOREGROUND = False
return {"status":200, "result":config.ENABLE_FOREGROUND} return {"status":200, "result":config.ENABLE_FOREGROUND}
def callbackEnableMainWindowSidebarCompactMode(*args, **kwargs) -> dict: def callbackEnableMainWindowSidebarCompactMode(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackEnableMainWindowSidebarCompactMode"}), flush=True) printLog("Enable MainWindow Sidebar Compact Mode")
config.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE = True config.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE = True
return {"status":200, "result":config.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE} return {"status":200, "result":config.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE}
def callbackDisableMainWindowSidebarCompactMode(*args, **kwargs) -> dict: def callbackDisableMainWindowSidebarCompactMode(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackDisableMainWindowSidebarCompactMode"}), flush=True) printLog("Disable MainWindow Sidebar Compact Mode")
config.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE = False config.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE = False
return {"status":200, "result":config.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE} return {"status":200, "result":config.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE}
# Config Window # Config Window
def callbackOpenConfigWindow(*args, **kwargs) -> dict: def callbackOpenConfigWindow(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackOpenConfigWindow"}), flush=True) printLog("Open Config Window")
if config.ENABLE_TRANSCRIPTION_SEND is True: if config.ENABLE_TRANSCRIPTION_SEND is True:
stopThreadingTranscriptionSendMessageOnOpenConfigWindow() stopThreadingTranscriptionSendMessageOnOpenConfigWindow()
if config.ENABLE_TRANSCRIPTION_RECEIVE is True: if config.ENABLE_TRANSCRIPTION_RECEIVE is True:
@@ -591,7 +583,7 @@ def callbackOpenConfigWindow(*args, **kwargs) -> dict:
return {"status":200} return {"status":200}
def callbackCloseConfigWindow(data, action, *args, **kwargs) -> dict: def callbackCloseConfigWindow(data, action, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackCloseConfigWindow"}), flush=True) printLog("Close Config Window")
model.stopCheckMicEnergy() model.stopCheckMicEnergy()
model.stopCheckSpeakerEnergy() model.stopCheckSpeakerEnergy()
@@ -605,14 +597,14 @@ def callbackCloseConfigWindow(data, action, *args, **kwargs) -> dict:
# Compact Mode Switch # Compact Mode Switch
def callbackEnableConfigWindowCompactMode(*args, **kwargs) -> dict: def callbackEnableConfigWindowCompactMode(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackEnableConfigWindowCompactMode"}), flush=True) printLog("Enable Config Window Compact Mode")
config.IS_CONFIG_WINDOW_COMPACT_MODE = True config.IS_CONFIG_WINDOW_COMPACT_MODE = True
model.stopCheckMicEnergy() model.stopCheckMicEnergy()
model.stopCheckSpeakerEnergy() model.stopCheckSpeakerEnergy()
return {"status":200, "result":config.IS_CONFIG_WINDOW_COMPACT_MODE} return {"status":200, "result":config.IS_CONFIG_WINDOW_COMPACT_MODE}
def callbackDisableConfigWindowCompactMode(*args, **kwargs) -> dict: def callbackDisableConfigWindowCompactMode(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackDisableConfigWindowCompactMode"}), flush=True) printLog("Disable Config Window Compact Mode")
config.IS_CONFIG_WINDOW_COMPACT_MODE = False config.IS_CONFIG_WINDOW_COMPACT_MODE = False
model.stopCheckMicEnergy() model.stopCheckMicEnergy()
model.stopCheckSpeakerEnergy() model.stopCheckSpeakerEnergy()
@@ -620,54 +612,54 @@ def callbackDisableConfigWindowCompactMode(*args, **kwargs) -> dict:
# Appearance Tab # Appearance Tab
def callbackSetTransparency(data, *args, **kwargs) -> dict: def callbackSetTransparency(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetTransparency", "data":data}), flush=True) printLog("Set Transparency", data)
config.TRANSPARENCY = int(data) config.TRANSPARENCY = int(data)
return {"status":200, "result":config.TRANSPARENCY} return {"status":200, "result":config.TRANSPARENCY}
def callbackSetAppearance(data, *args, **kwargs) -> dict: def callbackSetAppearance(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetAppearance", "data":data}), flush=True) printLog("Set Appearance", data)
config.APPEARANCE_THEME = data config.APPEARANCE_THEME = data
return {"status":200, "result":config.APPEARANCE_THEME} return {"status":200, "result":config.APPEARANCE_THEME}
def callbackSetUiScaling(data, *args, **kwargs) -> dict: def callbackSetUiScaling(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetUiScaling", "data":data}), flush=True) printLog("Set Ui Scaling", data)
config.UI_SCALING = data config.UI_SCALING = data
return {"status":200, "result":config.UI_SCALING} return {"status":200, "result":config.UI_SCALING}
def callbackSetTextboxUiScaling(data, *args, **kwargs) -> dict: def callbackSetTextboxUiScaling(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetTextboxUiScaling", "data":data}), flush=True) printLog("Set Textbox Ui Scaling", data)
config.TEXTBOX_UI_SCALING = int(data) config.TEXTBOX_UI_SCALING = int(data)
return {"status":200, "result":config.TEXTBOX_UI_SCALING} return {"status":200, "result":config.TEXTBOX_UI_SCALING}
def callbackSetMessageBoxRatio(data, *args, **kwargs) -> dict: def callbackSetMessageBoxRatio(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetMessageBoxRatio", "data":data}), flush=True) printLog("Set Message Box Ratio", data)
config.MESSAGE_BOX_RATIO = int(data) config.MESSAGE_BOX_RATIO = int(data)
return {"status":200, "result":config.MESSAGE_BOX_RATIO} return {"status":200, "result":config.MESSAGE_BOX_RATIO}
def callbackSetFontFamily(data, *args, **kwargs) -> dict: def callbackSetFontFamily(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetFontFamily", "data":data}), flush=True) printLog("Set Font Family", data)
config.FONT_FAMILY = data config.FONT_FAMILY = data
return {"status":200, "result":config.FONT_FAMILY} return {"status":200, "result":config.FONT_FAMILY}
def callbackSetUiLanguage(data, *args, **kwargs) -> dict: def callbackSetUiLanguage(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetUiLanguage", "data":data}), flush=True) printLog("Set UI Language", data)
data = getKeyByValue(config.SELECTABLE_UI_LANGUAGES_DICT, data) data = getKeyByValue(config.SELECTABLE_UI_LANGUAGES_DICT, data)
config.UI_LANGUAGE = data config.UI_LANGUAGE = data
return {"status":200, "result":config.UI_LANGUAGE} return {"status":200, "result":config.UI_LANGUAGE}
def callbackEnableRestoreMainWindowGeometry(data, *args, **kwargs) -> dict: def callbackEnableRestoreMainWindowGeometry(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackEnableRestoreMainWindowGeometry"}), flush=True) printLog("Enable Restore Main Window Geometry")
config.ENABLE_RESTORE_MAIN_WINDOW_GEOMETRY = True config.ENABLE_RESTORE_MAIN_WINDOW_GEOMETRY = True
return {"status":200, "result":config.ENABLE_RESTORE_MAIN_WINDOW_GEOMETRY} return {"status":200, "result":config.ENABLE_RESTORE_MAIN_WINDOW_GEOMETRY}
def callbackDisableRestoreMainWindowGeometry(*args, **kwargs) -> dict: def callbackDisableRestoreMainWindowGeometry(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackDisableRestoreMainWindowGeometry"}), flush=True) printLog("Disable Restore Main Window Geometry")
config.ENABLE_RESTORE_MAIN_WINDOW_GEOMETRY = True config.ENABLE_RESTORE_MAIN_WINDOW_GEOMETRY = True
return {"status":200, "result":config.ENABLE_RESTORE_MAIN_WINDOW_GEOMETRY} return {"status":200, "result":config.ENABLE_RESTORE_MAIN_WINDOW_GEOMETRY}
# Translation Tab # Translation Tab
def callbackEnableUseTranslationFeature(*args, **kwargs) -> dict: def callbackEnableUseTranslationFeature(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackEnableTranslationFeature"}), flush=True) printLog("Enable Translation Feature")
config.USE_TRANSLATION_FEATURE = True config.USE_TRANSLATION_FEATURE = True
if model.checkCTranslatorCTranslate2ModelWeight(): if model.checkCTranslatorCTranslate2ModelWeight():
@@ -688,7 +680,7 @@ def callbackEnableUseTranslationFeature(*args, **kwargs) -> dict:
} }
def callbackDisableUseTranslationFeature(*args, **kwargs) -> dict: def callbackDisableUseTranslationFeature(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackDisableTranslationFeature"}), flush=True) printLog("Disable Translation Feature")
config.USE_TRANSLATION_FEATURE = False config.USE_TRANSLATION_FEATURE = False
config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = False config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = False
return {"status":200, return {"status":200,
@@ -699,7 +691,7 @@ def callbackDisableUseTranslationFeature(*args, **kwargs) -> dict:
} }
def callbackSetCtranslate2WeightType(data, *args, **kwargs) -> dict: def callbackSetCtranslate2WeightType(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetCtranslate2WeightType", "data":data}), flush=True) printLog("Set CTranslate2 Weight Type", data)
config.CTRANSLATE2_WEIGHT_TYPE = str(data) config.CTRANSLATE2_WEIGHT_TYPE = str(data)
if model.checkCTranslatorCTranslate2ModelWeight(): if model.checkCTranslatorCTranslate2ModelWeight():
config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = False config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = False
@@ -722,7 +714,7 @@ class DownloadCTranslate2ProgressBar:
self.action = action self.action = action
def set(self, progress) -> None: def set(self, progress) -> None:
print(json.dumps({"status":348, "log": "CTranslate2 Weight Download Progress", "data":progress}), flush=True) printLog("CTranslate2 Weight Download Progress", progress)
self.action("download", { self.action("download", {
"status":200, "status":200,
"result":{ "result":{
@@ -731,13 +723,13 @@ class DownloadCTranslate2ProgressBar:
}) })
def callbackDownloadCtranslate2Weight(data, action, *args, **kwargs) -> dict: def callbackDownloadCtranslate2Weight(data, action, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackDownloadCtranslate2Weight"}), flush=True) printLog("Download CTranslate2 Weight")
download = DownloadCTranslate2ProgressBar(action) download = DownloadCTranslate2ProgressBar(action)
model.downloadCTranslate2ModelWeight(download.set) model.downloadCTranslate2ModelWeight(download.set)
return {"status":200} return {"status":200}
def callbackSetDeeplAuthKey(data, *args, **kwargs) -> dict: def callbackSetDeeplAuthKey(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetDeeplAuthKey", "data":data}), flush=True) printLog("Set DeepL Auth Key", data)
status = 400 status = 400
if len(data) == 36 or len(data) == 39: if len(data) == 36 or len(data) == 39:
result = model.authenticationTranslatorDeepLAuthKey(auth_key=data) result = model.authenticationTranslatorDeepLAuthKey(auth_key=data)
@@ -753,7 +745,7 @@ def callbackSetDeeplAuthKey(data, *args, **kwargs) -> dict:
return {"status":status, "result":config.AUTH_KEYS["DeepL_API"]} return {"status":status, "result":config.AUTH_KEYS["DeepL_API"]}
def callbackClearDeeplAuthKey(*args, **kwargs) -> dict: def callbackClearDeeplAuthKey(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackClearDeeplAuthKey"}), flush=True) printLog("Clear DeepL Auth Key")
auth_keys = config.AUTH_KEYS auth_keys = config.AUTH_KEYS
auth_keys["DeepL_API"] = None auth_keys["DeepL_API"] = None
config.AUTH_KEYS = auth_keys config.AUTH_KEYS = auth_keys
@@ -763,7 +755,7 @@ def callbackClearDeeplAuthKey(*args, **kwargs) -> dict:
# Transcription Tab # Transcription Tab
# Transcription (Mic) # Transcription (Mic)
def callbackSetMicHost(data, *args, **kwargs) -> dict: def callbackSetMicHost(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetMicHost", "data":data}), flush=True) printLog("Set Mic Host", data)
config.CHOICE_MIC_HOST = data config.CHOICE_MIC_HOST = data
config.CHOICE_MIC_DEVICE = model.getInputDefaultDevice() config.CHOICE_MIC_DEVICE = model.getInputDefaultDevice()
model.stopCheckMicEnergy() model.stopCheckMicEnergy()
@@ -775,7 +767,7 @@ def callbackSetMicHost(data, *args, **kwargs) -> dict:
} }
def callbackSetMicDevice(data, *args, **kwargs) -> dict: def callbackSetMicDevice(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetMicDevice", "data":data}), flush=True) printLog("Set Mic Device", data)
config.CHOICE_MIC_DEVICE = data config.CHOICE_MIC_DEVICE = data
model.stopCheckMicEnergy() model.stopCheckMicEnergy()
return {"status":200, return {"status":200,
@@ -785,7 +777,7 @@ def callbackSetMicDevice(data, *args, **kwargs) -> dict:
} }
def callbackSetMicEnergyThreshold(data, *args, **kwargs) -> dict: def callbackSetMicEnergyThreshold(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetMicEnergyThreshold", "data":data}), flush=True) printLog("Set Mic Energy Threshold", data)
status = 400 status = 400
data = int(data) data = int(data)
if 0 <= data <= config.MAX_MIC_ENERGY_THRESHOLD: if 0 <= data <= config.MAX_MIC_ENERGY_THRESHOLD:
@@ -794,12 +786,12 @@ def callbackSetMicEnergyThreshold(data, *args, **kwargs) -> dict:
return {"status": status, "result": config.INPUT_MIC_ENERGY_THRESHOLD} return {"status": status, "result": config.INPUT_MIC_ENERGY_THRESHOLD}
def callbackEnableMicDynamicEnergyThreshold(*args, **kwargs) -> dict: def callbackEnableMicDynamicEnergyThreshold(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackEnableMicDynamicEnergyThreshold"}), flush=True) printLog("Enable Mic Dynamic Energy Threshold")
config.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD = True config.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD = True
return {"status":200, "result":config.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD} return {"status":200, "result":config.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD}
def callbackDisableMicDynamicEnergyThreshold(*args, **kwargs) -> dict: def callbackDisableMicDynamicEnergyThreshold(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackDisableMicDynamicEnergyThreshold"}), flush=True) printLog("Disable Mic Dynamic Energy Threshold")
config.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD = False config.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD = False
return {"status":200, "result":config.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD} return {"status":200, "result":config.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD}
@@ -817,7 +809,7 @@ class ProgressBarMicEnergy:
self.action("error_device", {"status":400,"result": {"message":"No mic device detected."}}) self.action("error_device", {"status":400,"result": {"message":"No mic device detected."}})
def callbackEnableCheckMicThreshold(data, action, *args, **kwargs) -> dict: def callbackEnableCheckMicThreshold(data, action, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackEnableCheckMicThreshold"}), flush=True) printLog("Enable Check Mic Threshold")
progressbar_mic_energy = ProgressBarMicEnergy(action) progressbar_mic_energy = ProgressBarMicEnergy(action)
model.startCheckMicEnergy( model.startCheckMicEnergy(
progressbar_mic_energy.set, progressbar_mic_energy.set,
@@ -827,12 +819,12 @@ def callbackEnableCheckMicThreshold(data, action, *args, **kwargs) -> dict:
return {"status":200} return {"status":200}
def callbackDisableCheckMicThreshold(*args, **kwargs) -> dict: def callbackDisableCheckMicThreshold(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackDisableCheckMicThreshold"}), flush=True) printLog("Disable Check Mic Threshold")
model.stopCheckMicEnergy() model.stopCheckMicEnergy()
return {"status":200} return {"status":200}
def callbackSetMicRecordTimeout(data, *args, **kwargs) -> dict: def callbackSetMicRecordTimeout(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetMicRecordTimeout", "data":data}), flush=True) printLog("Set Mic Record Timeout", data)
try: try:
data = int(data) data = int(data)
if 0 <= data <= config.INPUT_MIC_PHRASE_TIMEOUT: if 0 <= data <= config.INPUT_MIC_PHRASE_TIMEOUT:
@@ -846,7 +838,7 @@ def callbackSetMicRecordTimeout(data, *args, **kwargs) -> dict:
return response return response
def callbackSetMicPhraseTimeout(data, *args, **kwargs) -> dict: def callbackSetMicPhraseTimeout(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetMicPhraseTimeout", "data":data}), flush=True) printLog("Set Mic Phrase Timeout", data)
try: try:
data = int(data) data = int(data)
if data >= config.INPUT_MIC_RECORD_TIMEOUT: if data >= config.INPUT_MIC_RECORD_TIMEOUT:
@@ -860,7 +852,7 @@ def callbackSetMicPhraseTimeout(data, *args, **kwargs) -> dict:
return response return response
def callbackSetMicMaxPhrases(data, *args, **kwargs) -> dict: def callbackSetMicMaxPhrases(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetMicMaxPhrases", "data":data}), flush=True) printLog("Set Mic Max Phrases", data)
try: try:
data = int(data) data = int(data)
if 0 <= data: if 0 <= data:
@@ -874,7 +866,7 @@ def callbackSetMicMaxPhrases(data, *args, **kwargs) -> dict:
return response return response
def callbackSetMicWordFilter(data, *args, **kwargs) -> dict: def callbackSetMicWordFilter(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetMicWordFilter", "data":data}), flush=True) printLog("Set Mic Word Filter", data)
data = str(data) data = str(data)
data = [w.strip() for w in data.split(",") if len(w.strip()) > 0] data = [w.strip() for w in data.split(",") if len(w.strip()) > 0]
# Copy the list # Copy the list
@@ -894,7 +886,7 @@ def callbackSetMicWordFilter(data, *args, **kwargs) -> dict:
return {"status":200, "result":config.INPUT_MIC_WORD_FILTER} return {"status":200, "result":config.INPUT_MIC_WORD_FILTER}
def callbackDeleteMicWordFilter(data, *args, **kwargs) -> dict: def callbackDeleteMicWordFilter(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackDeleteMicWordFilter", "data":data}), flush=True) printLog("Delete Mic Word Filter", data)
try: try:
new_input_mic_word_filter_list = config.INPUT_MIC_WORD_FILTER new_input_mic_word_filter_list = config.INPUT_MIC_WORD_FILTER
new_input_mic_word_filter_list.remove(str(data)) new_input_mic_word_filter_list.remove(str(data))
@@ -902,18 +894,18 @@ def callbackDeleteMicWordFilter(data, *args, **kwargs) -> dict:
model.resetKeywordProcessor() model.resetKeywordProcessor()
model.addKeywords() model.addKeywords()
except Exception: except Exception:
print(json.dumps({"status":348, "log": "callbackDeleteMicWordFilter There was no the target word in config.INPUT_MIC_WORD_FILTER"}), flush=True) printLog("Delete Mic Word Filter", "There was no the target word in config.INPUT_MIC_WORD_FILTER")
return {"status":200, "result":config.INPUT_MIC_WORD_FILTER} return {"status":200, "result":config.INPUT_MIC_WORD_FILTER}
# Transcription (Speaker) # Transcription (Speaker)
def callbackSetSpeakerDevice(data, *args, **kwargs) -> dict: def callbackSetSpeakerDevice(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetSpeakerDevice", "data":data}), flush=True) printLog("Set Speaker Device", data)
config.CHOICE_SPEAKER_DEVICE = data config.CHOICE_SPEAKER_DEVICE = data
model.stopCheckSpeakerEnergy() model.stopCheckSpeakerEnergy()
return {"status":200, "result":config.CHOICE_SPEAKER_DEVICE} return {"status":200, "result":config.CHOICE_SPEAKER_DEVICE}
def callbackSetSpeakerEnergyThreshold(data, *args, **kwargs) -> dict: def callbackSetSpeakerEnergyThreshold(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetSpeakerEnergyThreshold", "data":data}), flush=True) printLog("Set Speaker Energy Threshold", data)
try: try:
data = int(data) data = int(data)
if 0 <= data <= config.MAX_SPEAKER_ENERGY_THRESHOLD: if 0 <= data <= config.MAX_SPEAKER_ENERGY_THRESHOLD:
@@ -927,12 +919,12 @@ def callbackSetSpeakerEnergyThreshold(data, *args, **kwargs) -> dict:
return response return response
def callbackEnableSpeakerDynamicEnergyThreshold(*args, **kwargs) -> dict: def callbackEnableSpeakerDynamicEnergyThreshold(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackEnableSpeakerDynamicEnergyThreshold"}), flush=True) printLog("Enable Speaker Dynamic Energy Threshold")
config.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD = True config.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD = True
return {"status":200, "result":config.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD} return {"status":200, "result":config.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD}
def callbackDisableSpeakerDynamicEnergyThreshold(*args, **kwargs) -> dict: def callbackDisableSpeakerDynamicEnergyThreshold(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackDisableSpeakerDynamicEnergyThreshold"}), flush=True) printLog("Disable Speaker Dynamic Energy Threshold")
config.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD = False config.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD = False
return {"status":200, "result":config.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD} return {"status":200, "result":config.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD}
@@ -950,7 +942,7 @@ class ProgressBarSpeakerEnergy:
self.action("error_device", {"status":400,"result": {"message":"No mic device detected."}}) self.action("error_device", {"status":400,"result": {"message":"No mic device detected."}})
def callbackEnableCheckSpeakerThreshold(data, action, *args, **kwargs) -> dict: def callbackEnableCheckSpeakerThreshold(data, action, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackEnableCheckSpeakerThreshold"}), flush=True) printLog("Enable Check Speaker Threshold")
progressbar_speaker_energy = ProgressBarSpeakerEnergy(action) progressbar_speaker_energy = ProgressBarSpeakerEnergy(action)
model.startCheckSpeakerEnergy( model.startCheckSpeakerEnergy(
progressbar_speaker_energy.set, progressbar_speaker_energy.set,
@@ -960,12 +952,12 @@ def callbackEnableCheckSpeakerThreshold(data, action, *args, **kwargs) -> dict:
return {"status":200} return {"status":200}
def callbackDisableCheckSpeakerThreshold(*args, **kwargs) -> dict: def callbackDisableCheckSpeakerThreshold(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackDisableCheckSpeakerThreshold"}), flush=True) printLog("Disable Check Speaker Threshold")
model.stopCheckSpeakerEnergy() model.stopCheckSpeakerEnergy()
return {"status":200} return {"status":200}
def callbackSetSpeakerRecordTimeout(data, *args, **kwargs) -> dict: def callbackSetSpeakerRecordTimeout(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetSpeakerRecordTimeout", "data":data}), flush=True) printLog("Set Speaker Record Timeout", data)
try: try:
data = int(data) data = int(data)
if 0 <= data <= config.INPUT_SPEAKER_PHRASE_TIMEOUT: if 0 <= data <= config.INPUT_SPEAKER_PHRASE_TIMEOUT:
@@ -979,7 +971,7 @@ def callbackSetSpeakerRecordTimeout(data, *args, **kwargs) -> dict:
return response return response
def callbackSetSpeakerPhraseTimeout(data, *args, **kwargs) -> dict: def callbackSetSpeakerPhraseTimeout(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetSpeakerPhraseTimeout", "data":data}), flush=True) printLog("Set Speaker Phrase Timeout", data)
try: try:
data = int(data) data = int(data)
if 0 <= data and data >= config.INPUT_SPEAKER_RECORD_TIMEOUT: if 0 <= data and data >= config.INPUT_SPEAKER_RECORD_TIMEOUT:
@@ -993,7 +985,7 @@ def callbackSetSpeakerPhraseTimeout(data, *args, **kwargs) -> dict:
return response return response
def callbackSetSpeakerMaxPhrases(data, *args, **kwargs) -> dict: def callbackSetSpeakerMaxPhrases(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetSpeakerMaxPhrases", "data":data}), flush=True) printLog("Set Speaker Max Phrases", data)
try: try:
data = int(data) data = int(data)
if 0 <= data: if 0 <= data:
@@ -1008,7 +1000,7 @@ def callbackSetSpeakerMaxPhrases(data, *args, **kwargs) -> dict:
# Transcription (Internal AI Model) # Transcription (Internal AI Model)
def callbackEnableUseWhisperFeature(*args, **kwargs) -> dict: def callbackEnableUseWhisperFeature(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackEnableUserWhisperFeature"}), flush=True) printLog("Enable Whisper Feature")
config.USE_WHISPER_FEATURE = True config.USE_WHISPER_FEATURE = True
if model.checkTranscriptionWhisperModelWeight() is True: if model.checkTranscriptionWhisperModelWeight() is True:
config.IS_RESET_BUTTON_DISPLAYED_FOR_WHISPER = False config.IS_RESET_BUTTON_DISPLAYED_FOR_WHISPER = False
@@ -1025,7 +1017,7 @@ def callbackEnableUseWhisperFeature(*args, **kwargs) -> dict:
} }
def callbackDisableUseWhisperFeature(*args, **kwargs) -> dict: def callbackDisableUseWhisperFeature(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackDisableUserWhisperFeature"}), flush=True) printLog("Disable Whisper Feature")
config.USE_WHISPER_FEATURE = False config.USE_WHISPER_FEATURE = False
config.IS_RESET_BUTTON_DISPLAYED_FOR_WHISPER = False config.IS_RESET_BUTTON_DISPLAYED_FOR_WHISPER = False
config.SELECTED_TRANSCRIPTION_ENGINE = "Google" config.SELECTED_TRANSCRIPTION_ENGINE = "Google"
@@ -1038,7 +1030,7 @@ def callbackDisableUseWhisperFeature(*args, **kwargs) -> dict:
} }
def callbackSetWhisperWeightType(data, *args, **kwargs) -> dict: def callbackSetWhisperWeightType(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetWhisperWeightType", "data":data}), flush=True) printLog("Set Whisper Weight Type", data)
config.WHISPER_WEIGHT_TYPE = str(data) config.WHISPER_WEIGHT_TYPE = str(data)
if model.checkTranscriptionWhisperModelWeight() is True: if model.checkTranscriptionWhisperModelWeight() is True:
config.IS_RESET_BUTTON_DISPLAYED_FOR_WHISPER = False config.IS_RESET_BUTTON_DISPLAYED_FOR_WHISPER = False
@@ -1059,7 +1051,7 @@ class DownloadWhisperProgressBar:
self.action = action self.action = action
def set(self, progress) -> None: def set(self, progress) -> None:
print(json.dumps({"status":348, "log": "Whisper Weight Download Progress", "data":progress}), flush=True) printLog("Whisper Weight Download Progress", progress)
self.action("download", { self.action("download", {
"status":200, "status":200,
"result":{ "result":{
@@ -1068,14 +1060,14 @@ class DownloadWhisperProgressBar:
}) })
def callbackDownloadWhisperWeight(data, action, *args, **kwargs) -> dict: def callbackDownloadWhisperWeight(data, action, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackDownloadWhisperWeight"}), flush=True) printLog("Download Whisper Weight")
download = DownloadCTranslate2ProgressBar(action) download = DownloadCTranslate2ProgressBar(action)
model.downloadWhisperModelWeight(download.set) model.downloadWhisperModelWeight(download.set)
return {"status":200} return {"status":200}
# VR Tab # VR Tab
def callbackSetOverlaySettingsOpacity(data, *args, **kwargs) -> dict: def callbackSetOverlaySettingsOpacity(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetOverlaySettingsOpacity", "data":data}), flush=True) printLog("Set Overlay Settings Opacity", data)
pre_settings = config.OVERLAY_SETTINGS pre_settings = config.OVERLAY_SETTINGS
pre_settings["opacity"] = data pre_settings["opacity"] = data
config.OVERLAY_SETTINGS = pre_settings config.OVERLAY_SETTINGS = pre_settings
@@ -1083,7 +1075,7 @@ def callbackSetOverlaySettingsOpacity(data, *args, **kwargs) -> dict:
return {"status":200, "result":config.OVERLAY_SETTINGS["opacity"]} return {"status":200, "result":config.OVERLAY_SETTINGS["opacity"]}
def callbackSetOverlaySettingsUiScaling(data, *args, **kwargs) -> dict: def callbackSetOverlaySettingsUiScaling(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetOverlaySettingsUiScaling", "data":data}), flush=True) printLog("Set Overlay Settings Ui Scaling", data)
pre_settings = config.OVERLAY_SETTINGS pre_settings = config.OVERLAY_SETTINGS
pre_settings["ui_scaling"] = data pre_settings["ui_scaling"] = data
config.OVERLAY_SETTINGS = pre_settings config.OVERLAY_SETTINGS = pre_settings
@@ -1091,7 +1083,7 @@ def callbackSetOverlaySettingsUiScaling(data, *args, **kwargs) -> dict:
return {"status":200, "result":config.OVERLAY_SETTINGS["ui_scaling"]} return {"status":200, "result":config.OVERLAY_SETTINGS["ui_scaling"]}
def callbackEnableOverlaySmallLog(*args, **kwargs) -> dict: def callbackEnableOverlaySmallLog(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackEnableOverlaySmallLog"}), flush=True) printLog("Enable Overlay Small Log")
config.ENABLE_OVERLAY_SMALL_LOG = True config.ENABLE_OVERLAY_SMALL_LOG = True
if config.ENABLE_OVERLAY_SMALL_LOG is True and config.ENABLE_TRANSCRIPTION_RECEIVE is True: if config.ENABLE_OVERLAY_SMALL_LOG is True and config.ENABLE_TRANSCRIPTION_RECEIVE is True:
@@ -1100,7 +1092,7 @@ def callbackEnableOverlaySmallLog(*args, **kwargs) -> dict:
return {"status":200, "result":config.ENABLE_OVERLAY_SMALL_LOG} return {"status":200, "result":config.ENABLE_OVERLAY_SMALL_LOG}
def callbackDisableOverlaySmallLog(*args, **kwargs) -> dict: def callbackDisableOverlaySmallLog(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackDisableOverlaySmallLog"}), flush=True) printLog("Disable Overlay Small Log")
config.ENABLE_OVERLAY_SMALL_LOG = False config.ENABLE_OVERLAY_SMALL_LOG = False
if config.ENABLE_OVERLAY_SMALL_LOG is False: if config.ENABLE_OVERLAY_SMALL_LOG is False:
model.clearOverlayImage() model.clearOverlayImage()
@@ -1108,7 +1100,7 @@ def callbackDisableOverlaySmallLog(*args, **kwargs) -> dict:
return {"status":200, "result":config.ENABLE_OVERLAY_SMALL_LOG} return {"status":200, "result":config.ENABLE_OVERLAY_SMALL_LOG}
def callbackSetOverlaySmallLogSettingsXPos(data, *args, **kwargs) -> dict: def callbackSetOverlaySmallLogSettingsXPos(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetOverlaySmallLogSettingsXPos", "data":data}), flush=True) printLog("Set Overlay Small Log Settings X Pos", data)
pre_settings = config.OVERLAY_SMALL_LOG_SETTINGS pre_settings = config.OVERLAY_SMALL_LOG_SETTINGS
pre_settings["x_pos"] = data pre_settings["x_pos"] = data
config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings
@@ -1116,7 +1108,7 @@ def callbackSetOverlaySmallLogSettingsXPos(data, *args, **kwargs) -> dict:
return {"status":200, "result":config.OVERLAY_SMALL_LOG_SETTINGS["x_pos"]} return {"status":200, "result":config.OVERLAY_SMALL_LOG_SETTINGS["x_pos"]}
def callbackSetOverlaySmallLogSettingsYPos(data, *args, **kwargs) -> dict: def callbackSetOverlaySmallLogSettingsYPos(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetOverlaySmallLogSettingsYPos", "data":data}), flush=True) printLog("Set Overlay Small Log Settings Y Pos", data)
pre_settings = config.OVERLAY_SMALL_LOG_SETTINGS pre_settings = config.OVERLAY_SMALL_LOG_SETTINGS
pre_settings["y_pos"] = data pre_settings["y_pos"] = data
config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings
@@ -1124,7 +1116,7 @@ def callbackSetOverlaySmallLogSettingsYPos(data, *args, **kwargs) -> dict:
return {"status":200, "result":config.OVERLAY_SMALL_LOG_SETTINGS["y_pos"]} return {"status":200, "result":config.OVERLAY_SMALL_LOG_SETTINGS["y_pos"]}
def callbackSetOverlaySmallLogSettingsZPos(data, *args, **kwargs) -> dict: def callbackSetOverlaySmallLogSettingsZPos(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetOverlaySmallLogSettingsZPos", "data":data}), flush=True) printLog("Set Overlay Small Log Settings Z Pos", data)
pre_settings = config.OVERLAY_SMALL_LOG_SETTINGS pre_settings = config.OVERLAY_SMALL_LOG_SETTINGS
pre_settings["z_pos"] = data pre_settings["z_pos"] = data
config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings
@@ -1132,7 +1124,7 @@ def callbackSetOverlaySmallLogSettingsZPos(data, *args, **kwargs) -> dict:
return {"status":200, "result":config.OVERLAY_SMALL_LOG_SETTINGS["z_pos"]} return {"status":200, "result":config.OVERLAY_SMALL_LOG_SETTINGS["z_pos"]}
def callbackSetOverlaySmallLogSettingsXRotation(data, *args, **kwargs) -> dict: def callbackSetOverlaySmallLogSettingsXRotation(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetOverlaySmallLogSettingsXRotation", "data":data}), flush=True) printLog("Set Overlay Small Log Settings X Rotation", data)
pre_settings = config.OVERLAY_SMALL_LOG_SETTINGS pre_settings = config.OVERLAY_SMALL_LOG_SETTINGS
pre_settings["x_rotation"] = data pre_settings["x_rotation"] = data
config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings
@@ -1140,7 +1132,7 @@ def callbackSetOverlaySmallLogSettingsXRotation(data, *args, **kwargs) -> dict:
return {"status":200, "result":config.OVERLAY_SMALL_LOG_SETTINGS["x_rotation"]} return {"status":200, "result":config.OVERLAY_SMALL_LOG_SETTINGS["x_rotation"]}
def callbackSetOverlaySmallLogSettingsYRotation(data, *args, **kwargs) -> dict: def callbackSetOverlaySmallLogSettingsYRotation(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetOverlaySmallLogSettingsYRotation", "data":data}), flush=True) printLog("Set Overlay Small Log Settings Y Rotation", data)
pre_settings = config.OVERLAY_SMALL_LOG_SETTINGS pre_settings = config.OVERLAY_SMALL_LOG_SETTINGS
pre_settings["y_rotation"] = data pre_settings["y_rotation"] = data
config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings
@@ -1148,7 +1140,7 @@ def callbackSetOverlaySmallLogSettingsYRotation(data, *args, **kwargs) -> dict:
return {"status":200, "result":config.OVERLAY_SMALL_LOG_SETTINGS["y_rotation"]} return {"status":200, "result":config.OVERLAY_SMALL_LOG_SETTINGS["y_rotation"]}
def callbackSetOverlaySmallLogSettingsZRotation(data, *args, **kwargs) -> dict: def callbackSetOverlaySmallLogSettingsZRotation(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetOverlaySmallLogSettingsZRotation", "data":data}), flush=True) printLog("Set Overlay Small Log Settings Z Rotation", data)
pre_settings = config.OVERLAY_SMALL_LOG_SETTINGS pre_settings = config.OVERLAY_SMALL_LOG_SETTINGS
pre_settings["z_rotation"] = data pre_settings["z_rotation"] = data
config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings
@@ -1157,85 +1149,85 @@ def callbackSetOverlaySmallLogSettingsZRotation(data, *args, **kwargs) -> dict:
# Others Tab # Others Tab
def callbackEnableAutoClearMessageBox(*args, **kwargs) -> dict: def callbackEnableAutoClearMessageBox(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackEnableAutoClearMessageBox"}), flush=True) printLog("Enable Auto Clear Message Box")
config.ENABLE_AUTO_CLEAR_MESSAGE_BOX = True config.ENABLE_AUTO_CLEAR_MESSAGE_BOX = True
return {"status":200, "result":config.ENABLE_AUTO_CLEAR_MESSAGE_BOX} return {"status":200, "result":config.ENABLE_AUTO_CLEAR_MESSAGE_BOX}
def callbackDisableAutoClearMessageBox(*args, **kwargs) -> dict: def callbackDisableAutoClearMessageBox(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackDisableAutoClearMessageBox"}), flush=True) printLog("Disable Auto Clear Message Box")
config.ENABLE_AUTO_CLEAR_MESSAGE_BOX = False config.ENABLE_AUTO_CLEAR_MESSAGE_BOX = False
return {"status":200, "result":config.ENABLE_AUTO_CLEAR_MESSAGE_BOX} return {"status":200, "result":config.ENABLE_AUTO_CLEAR_MESSAGE_BOX}
def callbackEnableSendOnlyTranslatedMessages(*args, **kwargs) -> dict: def callbackEnableSendOnlyTranslatedMessages(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackEnableSendOnlyTranslatedMessages"}), flush=True) printLog("Enable Send Only Translated Messages")
config.ENABLE_SEND_ONLY_TRANSLATED_MESSAGES = True config.ENABLE_SEND_ONLY_TRANSLATED_MESSAGES = True
return {"status":200, "result":config.ENABLE_SEND_ONLY_TRANSLATED_MESSAGES} return {"status":200, "result":config.ENABLE_SEND_ONLY_TRANSLATED_MESSAGES}
def callbackDisableSendOnlyTranslatedMessages(*args, **kwargs) -> dict: def callbackDisableSendOnlyTranslatedMessages(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackDisableSendOnlyTranslatedMessages"}), flush=True) printLog("Disable Send Only Translated Messages")
config.ENABLE_SEND_ONLY_TRANSLATED_MESSAGES = False config.ENABLE_SEND_ONLY_TRANSLATED_MESSAGES = False
return {"status":200, "result":config.ENABLE_SEND_ONLY_TRANSLATED_MESSAGES} return {"status":200, "result":config.ENABLE_SEND_ONLY_TRANSLATED_MESSAGES}
def callbackSetSendMessageButtonType(data, *args, **kwargs) -> dict: def callbackSetSendMessageButtonType(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetSendMessageButtonType", "data":data}), flush=True) printLog("Set Send Message Button Type", data)
config.SEND_MESSAGE_BUTTON_TYPE = data config.SEND_MESSAGE_BUTTON_TYPE = data
return {"status":200, "result":config.SEND_MESSAGE_BUTTON_TYPE} return {"status":200, "result":config.SEND_MESSAGE_BUTTON_TYPE}
def callbackEnableNoticeXsoverlay(*args, **kwargs) -> dict: def callbackEnableNoticeXsoverlay(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackEnableNoticeXsoverlay"}), flush=True) printLog("Enable Notice Xsoverlay")
config.ENABLE_NOTICE_XSOVERLAY = True config.ENABLE_NOTICE_XSOVERLAY = True
return {"status":200, "result":config.ENABLE_NOTICE_XSOVERLAY} return {"status":200, "result":config.ENABLE_NOTICE_XSOVERLAY}
def callbackDisableNoticeXsoverlay(*args, **kwargs) -> dict: def callbackDisableNoticeXsoverlay(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackDisableNoticeXsoverlay"}), flush=True) printLog("Disable Notice Xsoverlay")
config.ENABLE_NOTICE_XSOVERLAY = False config.ENABLE_NOTICE_XSOVERLAY = False
return {"status":200, "result":config.ENABLE_NOTICE_XSOVERLAY} return {"status":200, "result":config.ENABLE_NOTICE_XSOVERLAY}
def callbackEnableAutoExportMessageLogs(*args, **kwargs) -> dict: def callbackEnableAutoExportMessageLogs(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackEnableAutoExportMessageLogs"}), flush=True) printLog("Enable Auto Export Message Logs")
config.ENABLE_LOGGER = True config.ENABLE_LOGGER = True
model.startLogger() model.startLogger()
return {"status":200, "result":config.ENABLE_LOGGER} return {"status":200, "result":config.ENABLE_LOGGER}
def callbackDisableAutoExportMessageLogs(*args, **kwargs) -> dict: def callbackDisableAutoExportMessageLogs(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackDisableAutoExportMessageLogs"}), flush=True) printLog("Disable Auto Export Message Logs")
config.ENABLE_LOGGER = False config.ENABLE_LOGGER = False
model.stopLogger() model.stopLogger()
return {"status":200, "result":config.ENABLE_LOGGER} return {"status":200, "result":config.ENABLE_LOGGER}
def callbackEnableVrcMicMuteSync(*args, **kwargs) -> dict: def callbackEnableVrcMicMuteSync(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackEnableVrcMicMuteSync"}), flush=True) printLog("Enable VRC Mic Mute Sync")
config.ENABLE_VRC_MIC_MUTE_SYNC = True config.ENABLE_VRC_MIC_MUTE_SYNC = True
model.startCheckMuteSelfStatus() model.startCheckMuteSelfStatus()
model.changeMicTranscriptStatus() model.changeMicTranscriptStatus()
return {"status":200, "result":config.ENABLE_VRC_MIC_MUTE_SYNC} return {"status":200, "result":config.ENABLE_VRC_MIC_MUTE_SYNC}
def callbackDisableVrcMicMuteSync(*args, **kwargs) -> dict: def callbackDisableVrcMicMuteSync(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackDisableVrcMicMuteSync"}), flush=True) printLog("Disable VRC Mic Mute Sync")
config.ENABLE_VRC_MIC_MUTE_SYNC = False config.ENABLE_VRC_MIC_MUTE_SYNC = False
model.stopCheckMuteSelfStatus() model.stopCheckMuteSelfStatus()
model.changeMicTranscriptStatus() model.changeMicTranscriptStatus()
return {"status":200, "result":config.ENABLE_VRC_MIC_MUTE_SYNC} return {"status":200, "result":config.ENABLE_VRC_MIC_MUTE_SYNC}
def callbackEnableSendMessageToVrc(*args, **kwargs) -> dict: def callbackEnableSendMessageToVrc(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackEnableSendMessageToVrc"}), flush=True) printLog("Enable Send Message To VRC")
config.ENABLE_SEND_MESSAGE_TO_VRC = True config.ENABLE_SEND_MESSAGE_TO_VRC = True
return {"status":200, "result":config.ENABLE_SEND_MESSAGE_TO_VRC} return {"status":200, "result":config.ENABLE_SEND_MESSAGE_TO_VRC}
def callbackDisableSendMessageToVrc(*args, **kwargs) -> dict: def callbackDisableSendMessageToVrc(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetEnableSendMessageToVrc"}), flush=True) printLog("Disable Send Message To VRC")
config.ENABLE_SEND_MESSAGE_TO_VRC = False config.ENABLE_SEND_MESSAGE_TO_VRC = False
return {"status":200, "result":config.ENABLE_SEND_MESSAGE_TO_VRC} return {"status":200, "result":config.ENABLE_SEND_MESSAGE_TO_VRC}
# Others (Message Formats(Send) # Others (Message Formats(Send)
def callbackSetSendMessageFormat(data, *args, **kwargs) -> dict: def callbackSetSendMessageFormat(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetSendMessageFormat", "data": str(data)}), flush=True) printLog("Set Send Message Format", data)
if isUniqueStrings(["[message]"], data) is True: if isUniqueStrings(["[message]"], data) is True:
config.SEND_MESSAGE_FORMAT = data config.SEND_MESSAGE_FORMAT = data
return {"status":200, "result":config.SEND_MESSAGE_FORMAT} return {"status":200, "result":config.SEND_MESSAGE_FORMAT}
def callbackSetSendMessageFormatWithT(data, *args, **kwargs) -> dict: def callbackSetSendMessageFormatWithT(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetReceivedMessageFormat", "data": str(data)}), flush=True) printLog("Set Send Message Format With Translation", data)
if len(data) > 0: if len(data) > 0:
if isUniqueStrings(["[message]", "[translation]"], data) is True: if isUniqueStrings(["[message]", "[translation]"], data) is True:
config.SEND_MESSAGE_FORMAT_WITH_T = data config.SEND_MESSAGE_FORMAT_WITH_T = data
@@ -1243,13 +1235,13 @@ def callbackSetSendMessageFormatWithT(data, *args, **kwargs) -> dict:
# Others (Message Formats(Received) # Others (Message Formats(Received)
def callbackSetReceivedMessageFormat(data, *args, **kwargs) -> dict: def callbackSetReceivedMessageFormat(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetReceivedMessageFormat", "data": str(data)}), flush=True) printLog("Set Received Message Format", data)
if isUniqueStrings(["[message]"], data) is True: if isUniqueStrings(["[message]"], data) is True:
config.RECEIVED_MESSAGE_FORMAT = data config.RECEIVED_MESSAGE_FORMAT = data
return {"status":200, "result":config.RECEIVED_MESSAGE_FORMAT} return {"status":200, "result":config.RECEIVED_MESSAGE_FORMAT}
def callbackSetReceivedMessageFormatWithT(data, *args, **kwargs) -> dict: def callbackSetReceivedMessageFormatWithT(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetReceivedMessageFormatWithT", "data": str(data)}), flush=True) printLog("Set Received Message Format With Translation", data)
if len(data) > 0: if len(data) > 0:
if isUniqueStrings(["[message]", "[translation]"], data) is True: if isUniqueStrings(["[message]", "[translation]"], data) is True:
config.RECEIVED_MESSAGE_FORMAT_WITH_T = data config.RECEIVED_MESSAGE_FORMAT_WITH_T = data
@@ -1257,36 +1249,36 @@ def callbackSetReceivedMessageFormatWithT(data, *args, **kwargs) -> dict:
# ---------------------Speaker2Chatbox--------------------- # ---------------------Speaker2Chatbox---------------------
def callbackEnableSendReceivedMessageToVrc(*args, **kwargs) -> dict: def callbackEnableSendReceivedMessageToVrc(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackEnableSendReceivedMessageToVrc"}), flush=True) printLog("Enable Send Received Message To VRC")
config.ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC = True config.ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC = True
return {"status":200, "result":config.ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC} return {"status":200, "result":config.ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC}
def callbackDisableSendReceivedMessageToVrc(*args, **kwargs) -> dict: def callbackDisableSendReceivedMessageToVrc(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackDisableSendReceivedMessageToVrc"}), flush=True) printLog("Disable Send Received Message To VRC")
config.ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC = False config.ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC = False
return {"status":200, "result":config.ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC} return {"status":200, "result":config.ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC}
# ---------------------Speaker2Chatbox--------------------- # ---------------------Speaker2Chatbox---------------------
def callbackEnableLogger(*args, **kwargs) -> dict: def callbackEnableLogger(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackEnableLogger"}), flush=True) printLog("Enable Logger")
config.ENABLE_LOGGER = True config.ENABLE_LOGGER = True
model.startLogger() model.startLogger()
return {"status":200, "result":config.ENABLE_LOGGER} return {"status":200, "result":config.ENABLE_LOGGER}
def callbackDisableLogger(*args, **kwargs) -> dict: def callbackDisableLogger(*args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackDisableLogger"}), flush=True) printLog("Disable Logger")
config.ENABLE_LOGGER = False config.ENABLE_LOGGER = False
model.stopLogger() model.stopLogger()
return {"status":200, "result":config.ENABLE_LOGGER} return {"status":200, "result":config.ENABLE_LOGGER}
# Advanced Settings Tab # Advanced Settings Tab
def callbackSetOscIpAddress(data, *args, **kwargs) -> dict: def callbackSetOscIpAddress(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetOscIpAddress", "data": str(data)}), flush=True) printLog("Set OSC IP Address", data)
config.OSC_IP_ADDRESS = str(data) config.OSC_IP_ADDRESS = str(data)
return {"status":200, "result":config.OSC_IP_ADDRESS} return {"status":200, "result":config.OSC_IP_ADDRESS}
def callbackSetOscPort(data, *args, **kwargs) -> dict: def callbackSetOscPort(data, *args, **kwargs) -> dict:
print(json.dumps({"status":348, "log": "callbackSetOscPort", "data": int(data)}), flush=True) printLog("Set OSC Port", data)
config.OSC_PORT = int(data) config.OSC_PORT = int(data)
return {"status":200, "result":config.OSC_PORT} return {"status":200, "result":config.OSC_PORT}
@@ -1303,13 +1295,13 @@ def getListOutputDevice(*args, **kwargs) -> dict:
return {"status":200, "result": model.getListOutputDevice()} return {"status":200, "result": model.getListOutputDevice()}
def init(endpoints:dict, *args, **kwargs) -> None: def init(endpoints:dict, *args, **kwargs) -> None:
print(json.dumps({"status":348, "log": "Start Initialization"}), flush=True) printLog("Start Initialization")
print(json.dumps({"status":348, "log": "Start InitSetTranslateEngine"}), flush=True) printLog("Start InitSetTranslateEngine")
initSetTranslateEngine() initSetTranslateEngine()
print(json.dumps({"status":348, "log": "Start Init LanguageAndCountry"}), flush=True) printLog("Start Init LanguageAndCountry")
initSetLanguageAndCountry() initSetLanguageAndCountry()
print(json.dumps({"status":348, "log": "Start check DeepL API Key"}), flush=True) printLog("Start check DeepL API Key")
if config.AUTH_KEYS["DeepL_API"] is not None: if config.AUTH_KEYS["DeepL_API"] is not None:
if model.authenticationTranslatorDeepLAuthKey(auth_key=config.AUTH_KEYS["DeepL_API"]) is False: if model.authenticationTranslatorDeepLAuthKey(auth_key=config.AUTH_KEYS["DeepL_API"]) is False:
# error update Auth key # error update Auth key
@@ -1318,11 +1310,11 @@ def init(endpoints:dict, *args, **kwargs) -> None:
config.AUTH_KEYS = auth_keys config.AUTH_KEYS = auth_keys
# set Translation Engine # set Translation Engine
print(json.dumps({"status":348, "log": "Set Translation Engine"}), flush=True) printLog("Set Translation Engine")
updateTranslationEngineAndEngineList() updateTranslationEngineAndEngineList()
# check Downloaded CTranslate2 Model Weight # check Downloaded CTranslate2 Model Weight
print(json.dumps({"status":348, "log": "Check Downloaded CTranslate2 Model Weight"}), flush=True) printLog("Check Downloaded CTranslate2 Model Weight")
if config.USE_TRANSLATION_FEATURE is True and model.checkCTranslatorCTranslate2ModelWeight() is False: if config.USE_TRANSLATION_FEATURE is True and model.checkCTranslatorCTranslate2ModelWeight() is False:
def callback(progress): def callback(progress):
print(json.dumps({ print(json.dumps({
@@ -1332,17 +1324,18 @@ def init(endpoints:dict, *args, **kwargs) -> None:
"progress":progress "progress":progress
} }
}), flush=True) }), flush=True)
printLog("Download CTranslate2 Model Weight")
model.downloadCTranslate2ModelWeight(callback) model.downloadCTranslate2ModelWeight(callback)
# set Transcription Engine # set Transcription Engine
print(json.dumps({"status":348, "log": "Set Transcription Engine"}), flush=True) printLog("Set Transcription Engine")
if config.USE_WHISPER_FEATURE is True: if config.USE_WHISPER_FEATURE is True:
config.SELECTED_TRANSCRIPTION_ENGINE = "Whisper" config.SELECTED_TRANSCRIPTION_ENGINE = "Whisper"
else: else:
config.SELECTED_TRANSCRIPTION_ENGINE = "Google" config.SELECTED_TRANSCRIPTION_ENGINE = "Google"
# check Downloaded Whisper Model Weight # check Downloaded Whisper Model Weight
print(json.dumps({"status":348, "log": "Check Downloaded Whisper Model Weight"}), flush=True) printLog("Check Downloaded Whisper Model Weight")
if config.USE_WHISPER_FEATURE is True and model.checkTranscriptionWhisperModelWeight() is False: if config.USE_WHISPER_FEATURE is True and model.checkTranscriptionWhisperModelWeight() is False:
def callback(progress): def callback(progress):
print(json.dumps({ print(json.dumps({
@@ -1355,22 +1348,22 @@ def init(endpoints:dict, *args, **kwargs) -> None:
model.downloadWhisperModelWeight(callback) model.downloadWhisperModelWeight(callback)
# set word filter # set word filter
print(json.dumps({"status":348, "log": "Set Word Filter"}), flush=True) printLog("Set Word Filter")
model.addKeywords() model.addKeywords()
# check Software Updated # check Software Updated
print(json.dumps({"status":348, "log": "Check Software Updated"}), flush=True) printLog("Check Software Updated")
if model.checkSoftwareUpdated() is True: if model.checkSoftwareUpdated() is True:
pass pass
# init logger # init logger
print(json.dumps({"status":348, "log": "Init Logger"}), flush=True) printLog("Init Logger")
if config.ENABLE_LOGGER is True: if config.ENABLE_LOGGER is True:
model.startLogger() model.startLogger()
# init OSC receive # init OSC receive
print(json.dumps({"status":348, "log": "Init OSC Receive"}), flush=True) printLog("Init OSC Receive")
model.startReceiveOSC() model.startReceiveOSC()
if config.ENABLE_VRC_MIC_MUTE_SYNC is True: if config.ENABLE_VRC_MIC_MUTE_SYNC is True:
model.startCheckMuteSelfStatus() model.startCheckMuteSelfStatus()
print(json.dumps({"status":348, "log": "End Initialization"}), flush=True) printLog("End Initialization")

View File

@@ -1,11 +1,9 @@
import warnings
warnings.simplefilter('ignore', RuntimeWarning)
import sys import sys
import json import json
import time import time
from config import config from config import config
import webui_controller as controller import webui_controller as controller
from utils import printLog
config_mapping = { config_mapping = {
"/config/version": "VERSION", "/config/version": "VERSION",
@@ -372,7 +370,7 @@ if __name__ == "__main__":
time.sleep(0.1) time.sleep(0.1)
for endpoint, value in controller_mapping.items(): for endpoint, value in controller_mapping.items():
print(json.dumps({"status":348, "log": f"endpoint: {endpoint}"})) printLog("endpoint", endpoint)
match endpoint: match endpoint:
case "/controller/callback_messagebox_press_key_enter": case "/controller/callback_messagebox_press_key_enter":