👍️[Update] Main/Controller : データ送信の形を修正
This commit is contained in:
@@ -315,7 +315,7 @@ class Model:
|
|||||||
return update_flag
|
return update_flag
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def updateSoftware(restart:bool=True, func=None):
|
def updateSoftware(restart:bool=True, download=None, update=None):
|
||||||
def updateSoftwareTask():
|
def updateSoftwareTask():
|
||||||
filename = 'VRCT.zip'
|
filename = 'VRCT.zip'
|
||||||
program_name = 'VRCT.exe'
|
program_name = 'VRCT.exe'
|
||||||
@@ -336,8 +336,8 @@ class Model:
|
|||||||
for chunk in res.iter_content(chunk_size=1024*5):
|
for chunk in res.iter_content(chunk_size=1024*5):
|
||||||
file.write(chunk)
|
file.write(chunk)
|
||||||
total_chunk += len(chunk)
|
total_chunk += len(chunk)
|
||||||
if isinstance(func, Callable):
|
if isinstance(download, Callable):
|
||||||
func(progress=total_chunk/file_size, progress_type="downloading")
|
download(total_chunk/file_size)
|
||||||
print(f"downloaded {total_chunk}/{file_size}")
|
print(f"downloaded {total_chunk}/{file_size}")
|
||||||
|
|
||||||
with ZipFile(os_path.join(tmp_path, filename)) as zf:
|
with ZipFile(os_path.join(tmp_path, filename)) as zf:
|
||||||
@@ -346,8 +346,8 @@ class Model:
|
|||||||
for file_info in zf.infolist():
|
for file_info in zf.infolist():
|
||||||
extracted_files += 1
|
extracted_files += 1
|
||||||
zf.extract(file_info, os_path.join(current_directory, tmp_directory_name))
|
zf.extract(file_info, os_path.join(current_directory, tmp_directory_name))
|
||||||
if isinstance(func, Callable):
|
if isinstance(update, Callable):
|
||||||
func(progress=extracted_files/total_files, progress_type="extracting")
|
update(extracted_files/total_files)
|
||||||
print(f"extracted {extracted_files}/{total_files}")
|
print(f"extracted {extracted_files}/{total_files}")
|
||||||
|
|
||||||
copyfile(os_path.join(current_directory, folder_name, "batch", batch_name), os_path.join(current_directory, batch_name))
|
copyfile(os_path.join(current_directory, folder_name, "batch", batch_name), os_path.join(current_directory, batch_name))
|
||||||
|
|||||||
@@ -10,47 +10,59 @@ from utils import getKeyByValue, isUniqueStrings, strPctToInt
|
|||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
# Common
|
# Common
|
||||||
def callbackUpdateSoftware(func=None):
|
class DownloadProgressBar:
|
||||||
print(json.dumps({"log": "callbackUpdateSoftware"}), flush=True)
|
def __init__(self, action):
|
||||||
setMainWindowGeometry()
|
self.action = action
|
||||||
model.updateSoftware(restart=True, func=func)
|
|
||||||
|
|
||||||
def callbackRestartSoftware():
|
def set(self, progress) -> None:
|
||||||
|
print(json.dumps({"log": "Software Download Progress", "data":progress}), flush=True)
|
||||||
|
self.action("download", {
|
||||||
|
"status":200,
|
||||||
|
"result":{
|
||||||
|
"progress":progress
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
class UpdateProgressBar:
|
||||||
|
def __init__(self, action):
|
||||||
|
self.action = action
|
||||||
|
|
||||||
|
def set(self, progress) -> None:
|
||||||
|
print(json.dumps({"log": "Software Update Progress", "data":progress}), flush=True)
|
||||||
|
self.action("update", {
|
||||||
|
"status":200,
|
||||||
|
"result":{
|
||||||
|
"progress":progress
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
def callbackUpdateSoftware(data, action, *args, **kwargs) -> dict:
|
||||||
|
print(json.dumps({"log": "callbackUpdateSoftware"}), flush=True)
|
||||||
|
download = DownloadProgressBar(action)
|
||||||
|
update = UpdateProgressBar(action)
|
||||||
|
model.updateSoftware(restart=True, download=download.set, update=update.set)
|
||||||
|
return {"status":200}
|
||||||
|
|
||||||
|
def callbackRestartSoftware(*args, **kwargs) -> dict:
|
||||||
print(json.dumps({"log": "callbackRestartSoftware"}), flush=True)
|
print(json.dumps({"log": "callbackRestartSoftware"}), flush=True)
|
||||||
setMainWindowGeometry()
|
|
||||||
model.reStartSoftware()
|
model.reStartSoftware()
|
||||||
|
return {"status":200}
|
||||||
|
|
||||||
def callbackFilepathLogs():
|
def callbackFilepathLogs():
|
||||||
print(json.dumps({"log": "callbackFilepathLogs"}), flush=True)
|
print(json.dumps({"log": "callbackFilepathLogs"}), flush=True)
|
||||||
Popen(['explorer', config.PATH_LOGS.replace('/', '\\')], shell=True)
|
Popen(['explorer', config.PATH_LOGS.replace('/', '\\')], shell=True)
|
||||||
return "Success", 200
|
return {"status":200}
|
||||||
|
|
||||||
def callbackFilepathConfigFile():
|
def callbackFilepathConfigFile():
|
||||||
print(json.dumps({"log": "callbackFilepathConfigFile"}), flush=True)
|
print(json.dumps({"log": "callbackFilepathConfigFile"}), flush=True)
|
||||||
Popen(['explorer', config.PATH_LOCAL.replace('/', '\\')], shell=True)
|
Popen(['explorer', config.PATH_LOCAL.replace('/', '\\')], shell=True)
|
||||||
return "Success", 200
|
return {"status":200}
|
||||||
|
|
||||||
def callbackQuitVrct():
|
# def callbackEnableEasterEgg():
|
||||||
print(json.dumps({"log": "callbackQuitVrct"}), flush=True)
|
# print(json.dumps({"log": "callbackEnableEasterEgg"}), flush=True)
|
||||||
setMainWindowGeometry()
|
# config.IS_EASTER_EGG_ENABLED = True
|
||||||
|
# config.OVERLAY_UI_TYPE = "sakura"
|
||||||
def callbackEnableEasterEgg():
|
# return {"status":200, "result":config.IS_EASTER_EGG_ENABLED}
|
||||||
print(json.dumps({"log": "callbackEnableEasterEgg"}), flush=True)
|
|
||||||
config.IS_EASTER_EGG_ENABLED = True
|
|
||||||
config.OVERLAY_UI_TYPE = "sakura"
|
|
||||||
# view.printToTextbox_enableEasterEgg()
|
|
||||||
|
|
||||||
def setMainWindowGeometry():
|
|
||||||
# PRE_SCALING_INT = strPctToInt(view.getPreUiScaling())
|
|
||||||
# NEW_SCALING_INT = strPctToInt(config.UI_SCALING)
|
|
||||||
# MULTIPLY_FLOAT = (NEW_SCALING_INT / PRE_SCALING_INT)
|
|
||||||
# main_window_geometry = view.getMainWindowGeometry(return_int=True)
|
|
||||||
# main_window_geometry["width"] = str(int(main_window_geometry["width"] * MULTIPLY_FLOAT))
|
|
||||||
# main_window_geometry["height"] = str(int(main_window_geometry["height"] * MULTIPLY_FLOAT))
|
|
||||||
# main_window_geometry["x_pos"] = str(main_window_geometry["x_pos"])
|
|
||||||
# main_window_geometry["y_pos"] = str(main_window_geometry["y_pos"])
|
|
||||||
# config.MAIN_WINDOW_GEOMETRY = main_window_geometry
|
|
||||||
pass
|
|
||||||
|
|
||||||
def messageFormatter(format_type:str, translation, message):
|
def messageFormatter(format_type:str, translation, message):
|
||||||
if format_type == "RECEIVED":
|
if format_type == "RECEIVED":
|
||||||
@@ -74,7 +86,6 @@ def changeToCTranslate2Process():
|
|||||||
config.CHOICE_INPUT_TRANSLATOR = "CTranslate2"
|
config.CHOICE_INPUT_TRANSLATOR = "CTranslate2"
|
||||||
config.CHOICE_OUTPUT_TRANSLATOR = "CTranslate2"
|
config.CHOICE_OUTPUT_TRANSLATOR = "CTranslate2"
|
||||||
updateTranslationEngineAndEngineList()
|
updateTranslationEngineAndEngineList()
|
||||||
# view.printToTextbox_TranslationEngineLimitError()
|
|
||||||
|
|
||||||
# func transcription send message
|
# func transcription send message
|
||||||
class MicMessage:
|
class MicMessage:
|
||||||
@@ -83,12 +94,22 @@ class MicMessage:
|
|||||||
|
|
||||||
def send(self, message: Union[str, bool]) -> None:
|
def send(self, message: Union[str, bool]) -> None:
|
||||||
if isinstance(message, bool) and message is False:
|
if isinstance(message, bool) and message is False:
|
||||||
self.action({"status":"error", "message":"No mic device detected."})
|
self.action("error_device", {
|
||||||
|
"status":404,
|
||||||
|
"result": {
|
||||||
|
"message":"No mic device detected."
|
||||||
|
}
|
||||||
|
})
|
||||||
elif isinstance(message, str) and len(message) > 0:
|
elif isinstance(message, str) and len(message) > 0:
|
||||||
addSentMessageLog(message)
|
addSentMessageLog(message)
|
||||||
translation = ""
|
translation = ""
|
||||||
if model.checkKeywords(message):
|
if model.checkKeywords(message):
|
||||||
self.action("mic", {"status":"error", "message":f"Detected by word filter:{message}"})
|
self.action("word_filter", {
|
||||||
|
"status":200,
|
||||||
|
"result": {
|
||||||
|
"message":f"Detected by word filter:{message}"
|
||||||
|
}
|
||||||
|
})
|
||||||
return
|
return
|
||||||
elif model.detectRepeatSendMessage(message):
|
elif model.detectRepeatSendMessage(message):
|
||||||
return
|
return
|
||||||
@@ -98,6 +119,12 @@ class MicMessage:
|
|||||||
translation, success = model.getInputTranslate(message)
|
translation, success = model.getInputTranslate(message)
|
||||||
if success is False:
|
if success is False:
|
||||||
changeToCTranslate2Process()
|
changeToCTranslate2Process()
|
||||||
|
self.action("error_translation_engine", {
|
||||||
|
"status":404,
|
||||||
|
"result": {
|
||||||
|
"message":"translation engine limit error"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
if config.ENABLE_TRANSCRIPTION_SEND is True:
|
if config.ENABLE_TRANSCRIPTION_SEND is True:
|
||||||
if config.ENABLE_SEND_MESSAGE_TO_VRC is True:
|
if config.ENABLE_SEND_MESSAGE_TO_VRC is True:
|
||||||
@@ -110,7 +137,13 @@ class MicMessage:
|
|||||||
osc_message = messageFormatter("SEND", translation, message)
|
osc_message = messageFormatter("SEND", translation, message)
|
||||||
model.oscSendMessage(osc_message)
|
model.oscSendMessage(osc_message)
|
||||||
|
|
||||||
self.action("mic", {"status":"success", "message":message, "translation":translation})
|
self.action("mic", {
|
||||||
|
"status":200,
|
||||||
|
"result": {
|
||||||
|
"message":message,
|
||||||
|
"translation":translation
|
||||||
|
}
|
||||||
|
})
|
||||||
if config.ENABLE_LOGGER is True:
|
if config.ENABLE_LOGGER is True:
|
||||||
if len(translation) > 0:
|
if len(translation) > 0:
|
||||||
translation = f" ({translation})"
|
translation = f" ({translation})"
|
||||||
@@ -128,7 +161,12 @@ def startTranscriptionSendMessage(action:Callable[[dict], None]) -> None:
|
|||||||
|
|
||||||
def stopTranscriptionSendMessage(action:Callable[[dict], None]) -> None:
|
def stopTranscriptionSendMessage(action:Callable[[dict], None]) -> None:
|
||||||
model.stopMicTranscript()
|
model.stopMicTranscript()
|
||||||
action("mic", {"status":"success", "message":"Stopped sending messages"})
|
action("mic", {
|
||||||
|
"status":200,
|
||||||
|
"result":{
|
||||||
|
"message":"Stopped sending messages"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
def startThreadingTranscriptionSendMessage(action:Callable[[dict], None]) -> None:
|
def startThreadingTranscriptionSendMessage(action:Callable[[dict], None]) -> None:
|
||||||
th_startTranscriptionSendMessage = Thread(target=startTranscriptionSendMessage, args=(action,))
|
th_startTranscriptionSendMessage = Thread(target=startTranscriptionSendMessage, args=(action,))
|
||||||
@@ -164,7 +202,12 @@ class SpeakerMessage:
|
|||||||
|
|
||||||
def receive(self, message):
|
def receive(self, message):
|
||||||
if isinstance(message, bool) and message is False:
|
if isinstance(message, bool) and message is False:
|
||||||
self.action("speaker", {"status":"error", "message":"No mic device detected."})
|
self.action("error_device",{
|
||||||
|
"status":404,
|
||||||
|
"result": {
|
||||||
|
"message":"No mic device detected."
|
||||||
|
},
|
||||||
|
})
|
||||||
elif isinstance(message, str) and len(message) > 0:
|
elif isinstance(message, str) and len(message) > 0:
|
||||||
translation = ""
|
translation = ""
|
||||||
if model.detectRepeatReceiveMessage(message):
|
if model.detectRepeatReceiveMessage(message):
|
||||||
@@ -175,6 +218,12 @@ class SpeakerMessage:
|
|||||||
translation, success = model.getOutputTranslate(message)
|
translation, success = model.getOutputTranslate(message)
|
||||||
if success is False:
|
if success is False:
|
||||||
changeToCTranslate2Process()
|
changeToCTranslate2Process()
|
||||||
|
self.action("error_translation_engine", {
|
||||||
|
"status":404,
|
||||||
|
"result": {
|
||||||
|
"message":"translation engine limit error"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
if config.ENABLE_TRANSCRIPTION_RECEIVE is True:
|
if config.ENABLE_TRANSCRIPTION_RECEIVE is True:
|
||||||
if config.ENABLE_NOTICE_XSOVERLAY is True:
|
if config.ENABLE_NOTICE_XSOVERLAY is True:
|
||||||
@@ -197,7 +246,13 @@ class SpeakerMessage:
|
|||||||
# ------------Speaker2Chatbox------------
|
# ------------Speaker2Chatbox------------
|
||||||
|
|
||||||
# update textbox message log (Received)
|
# update textbox message log (Received)
|
||||||
self.action("speaker",{"status":"success", "message":message, "translation":translation})
|
self.action("speaker",{
|
||||||
|
"status":200,
|
||||||
|
"result": {
|
||||||
|
"message":message,
|
||||||
|
"translation":translation
|
||||||
|
}
|
||||||
|
})
|
||||||
if config.ENABLE_LOGGER is True:
|
if config.ENABLE_LOGGER is True:
|
||||||
if len(translation) > 0:
|
if len(translation) > 0:
|
||||||
translation = f" ({translation})"
|
translation = f" ({translation})"
|
||||||
@@ -209,7 +264,12 @@ def startTranscriptionReceiveMessage(action:Callable[[dict], None]) -> None:
|
|||||||
|
|
||||||
def stopTranscriptionReceiveMessage(action:Callable[[dict], None]) -> None:
|
def stopTranscriptionReceiveMessage(action:Callable[[dict], None]) -> None:
|
||||||
model.stopSpeakerTranscript()
|
model.stopSpeakerTranscript()
|
||||||
action({"status":"success", "message":"Stopped receiving messages"})
|
action("speaker", {
|
||||||
|
"status":200,
|
||||||
|
"result": {
|
||||||
|
"message":"Stopped receiving messages"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
def startThreadingTranscriptionReceiveMessage(action:Callable[[dict], None]) -> None:
|
def startThreadingTranscriptionReceiveMessage(action:Callable[[dict], None]) -> None:
|
||||||
th_startTranscriptionReceiveMessage = Thread(target=startTranscriptionReceiveMessage, args=(action,))
|
th_startTranscriptionReceiveMessage = Thread(target=startTranscriptionReceiveMessage, args=(action,))
|
||||||
@@ -239,51 +299,62 @@ def stopThreadingTranscriptionReceiveMessageOnOpenConfigWindow():
|
|||||||
th_stopTranscriptionReceiveMessage.start()
|
th_stopTranscriptionReceiveMessage.start()
|
||||||
|
|
||||||
# func message box
|
# func message box
|
||||||
def sendChatMessage(message):
|
class ChatMessage:
|
||||||
if len(message) > 0:
|
def __init__(self, action:Callable[[dict], None]) -> None:
|
||||||
addSentMessageLog(message)
|
self.action = action
|
||||||
translation = ""
|
|
||||||
if config.ENABLE_TRANSLATION is False:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
translation, success = model.getInputTranslate(message)
|
|
||||||
if success is False:
|
|
||||||
changeToCTranslate2Process()
|
|
||||||
|
|
||||||
# send OSC message
|
def send(self, message):
|
||||||
if config.ENABLE_SEND_MESSAGE_TO_VRC is True:
|
if len(message) > 0:
|
||||||
if config.ENABLE_SEND_ONLY_TRANSLATED_MESSAGES is True:
|
addSentMessageLog(message)
|
||||||
if config.ENABLE_TRANSLATION is False:
|
translation = ""
|
||||||
osc_message = messageFormatter("SEND", "", message)
|
if config.ENABLE_TRANSLATION is False:
|
||||||
else:
|
pass
|
||||||
osc_message = messageFormatter("SEND", "", translation)
|
|
||||||
else:
|
else:
|
||||||
osc_message = messageFormatter("SEND", translation, message)
|
translation, success = model.getInputTranslate(message)
|
||||||
model.oscSendMessage(osc_message)
|
if success is False:
|
||||||
|
changeToCTranslate2Process()
|
||||||
|
self.action("error_translation_engine", {
|
||||||
|
"status":404,
|
||||||
|
"result":{
|
||||||
|
"message":"translation engine limit error"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
# if config.ENABLE_OVERLAY_SMALL_LOG is True:
|
# send OSC message
|
||||||
# overlay_image = model.createOverlayImageShort(message, translation)
|
if config.ENABLE_SEND_MESSAGE_TO_VRC is True:
|
||||||
# model.updateOverlay(overlay_image)
|
if config.ENABLE_SEND_ONLY_TRANSLATED_MESSAGES is True:
|
||||||
# overlay_image = model.createOverlayImageLong("send", message, translation)
|
if config.ENABLE_TRANSLATION is False:
|
||||||
# model.updateOverlay(overlay_image)
|
osc_message = messageFormatter("SEND", "", message)
|
||||||
|
else:
|
||||||
|
osc_message = messageFormatter("SEND", "", translation)
|
||||||
|
else:
|
||||||
|
osc_message = messageFormatter("SEND", translation, message)
|
||||||
|
model.oscSendMessage(osc_message)
|
||||||
|
|
||||||
# update textbox message log (Sent)
|
# if config.ENABLE_OVERLAY_SMALL_LOG is True:
|
||||||
# view.printToTextbox_SentMessage(message, translation)
|
# overlay_image = model.createOverlayImageShort(message, translation)
|
||||||
if config.ENABLE_LOGGER is True:
|
# model.updateOverlay(overlay_image)
|
||||||
if len(translation) > 0:
|
# overlay_image = model.createOverlayImageLong("send", message, translation)
|
||||||
translation = f" ({translation})"
|
# model.updateOverlay(overlay_image)
|
||||||
model.logger.info(f"[SENT] {message}{translation}")
|
|
||||||
|
|
||||||
# delete message in entry message box
|
# update textbox message log (Sent)
|
||||||
if config.ENABLE_AUTO_CLEAR_MESSAGE_BOX is True:
|
if config.ENABLE_LOGGER is True:
|
||||||
# view.clearMessageBox()
|
if len(translation) > 0:
|
||||||
pass
|
translation = f" ({translation})"
|
||||||
|
model.logger.info(f"[SENT] {message}{translation}")
|
||||||
|
|
||||||
def messageBoxPressKeyEnter():
|
return {"status":200,
|
||||||
# model.oscStopSendTyping()
|
"result":{
|
||||||
# message = view.getTextFromMessageBox()
|
"message":message,
|
||||||
# sendChatMessage(message)
|
"translation":translation,
|
||||||
pass
|
"clear":config.ENABLE_AUTO_CLEAR_MESSAGE_BOX
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
def callbackMessageBoxPressKeyEnter(data, action, *args, **kwargs) -> dict:
|
||||||
|
chat = ChatMessage(action)
|
||||||
|
response = chat.send(data)
|
||||||
|
return response
|
||||||
|
|
||||||
def messageBoxPressKeyAny(e):
|
def messageBoxPressKeyAny(e):
|
||||||
if config.ENABLE_SEND_MESSAGE_TO_VRC is True:
|
if config.ENABLE_SEND_MESSAGE_TO_VRC is True:
|
||||||
@@ -304,24 +375,24 @@ def addSentMessageLog(sent_message):
|
|||||||
config.SENT_MESSAGES_LOG.append(sent_message)
|
config.SENT_MESSAGES_LOG.append(sent_message)
|
||||||
config.CURRENT_SENT_MESSAGES_LOG_INDEX = len(config.SENT_MESSAGES_LOG)
|
config.CURRENT_SENT_MESSAGES_LOG_INDEX = len(config.SENT_MESSAGES_LOG)
|
||||||
|
|
||||||
def updateMessageBox(index_offset):
|
# def updateMessageBox(index_offset):
|
||||||
if len(config.SENT_MESSAGES_LOG) == 0:
|
# if len(config.SENT_MESSAGES_LOG) == 0:
|
||||||
return
|
# return
|
||||||
try:
|
# try:
|
||||||
new_index = config.CURRENT_SENT_MESSAGES_LOG_INDEX + index_offset
|
# new_index = config.CURRENT_SENT_MESSAGES_LOG_INDEX + index_offset
|
||||||
target_message_text = config.SENT_MESSAGES_LOG[new_index]
|
# target_message_text = config.SENT_MESSAGES_LOG[new_index]
|
||||||
# view.replaceMessageBox(target_message_text)
|
# # view.replaceMessageBox(target_message_text)
|
||||||
config.CURRENT_SENT_MESSAGES_LOG_INDEX = new_index
|
# config.CURRENT_SENT_MESSAGES_LOG_INDEX = new_index
|
||||||
except IndexError:
|
# except IndexError:
|
||||||
pass
|
# pass
|
||||||
|
|
||||||
def messageBoxUpKeyPress():
|
# def messageBoxUpKeyPress():
|
||||||
if config.CURRENT_SENT_MESSAGES_LOG_INDEX > 0:
|
# if config.CURRENT_SENT_MESSAGES_LOG_INDEX > 0:
|
||||||
updateMessageBox(-1)
|
# updateMessageBox(-1)
|
||||||
|
|
||||||
def messageBoxDownKeyPress():
|
# def messageBoxDownKeyPress():
|
||||||
if config.CURRENT_SENT_MESSAGES_LOG_INDEX < len(config.SENT_MESSAGES_LOG) - 1:
|
# if config.CURRENT_SENT_MESSAGES_LOG_INDEX < len(config.SENT_MESSAGES_LOG) - 1:
|
||||||
updateMessageBox(1)
|
# updateMessageBox(1)
|
||||||
|
|
||||||
def updateTranslationEngineAndEngineList():
|
def updateTranslationEngineAndEngineList():
|
||||||
engine = config.CHOICE_INPUT_TRANSLATOR
|
engine = config.CHOICE_INPUT_TRANSLATOR
|
||||||
@@ -365,8 +436,8 @@ def setYourLanguageAndCountry(select:dict, *args, **kwargs) -> dict:
|
|||||||
config.SOURCE_LANGUAGE = select["language"]
|
config.SOURCE_LANGUAGE = select["language"]
|
||||||
config.SOURCE_COUNTRY = select["country"]
|
config.SOURCE_COUNTRY = select["country"]
|
||||||
updateTranslationEngineAndEngineList()
|
updateTranslationEngineAndEngineList()
|
||||||
return {"status":"success",
|
return {"status":200,
|
||||||
"data":{
|
"result":{
|
||||||
"your":{
|
"your":{
|
||||||
"language":config.SOURCE_LANGUAGE,
|
"language":config.SOURCE_LANGUAGE,
|
||||||
"country":config.SOURCE_COUNTRY
|
"country":config.SOURCE_COUNTRY
|
||||||
@@ -382,8 +453,8 @@ def setTargetLanguageAndCountry(select:dict, *args, **kwargs) -> dict:
|
|||||||
config.TARGET_LANGUAGE = select["language"]
|
config.TARGET_LANGUAGE = select["language"]
|
||||||
config.TARGET_COUNTRY = select["country"]
|
config.TARGET_COUNTRY = select["country"]
|
||||||
updateTranslationEngineAndEngineList()
|
updateTranslationEngineAndEngineList()
|
||||||
return {"status":"success",
|
return {"status":200,
|
||||||
"data":{
|
"result":{
|
||||||
"target":{
|
"target":{
|
||||||
"language":config.TARGET_LANGUAGE,
|
"language":config.TARGET_LANGUAGE,
|
||||||
"country":config.TARGET_COUNTRY
|
"country":config.TARGET_COUNTRY
|
||||||
@@ -397,8 +468,8 @@ def swapYourLanguageAndTargetLanguage(*args, **kwargs) -> dict:
|
|||||||
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)
|
||||||
setTargetLanguageAndCountry(your_language)
|
setTargetLanguageAndCountry(your_language)
|
||||||
return {"status":"success",
|
return {"status":200,
|
||||||
"data":{
|
"result":{
|
||||||
"your":{"language":config.SOURCE_LANGUAGE,
|
"your":{"language":config.SOURCE_LANGUAGE,
|
||||||
"country":config.SOURCE_COUNTRY,
|
"country":config.SOURCE_COUNTRY,
|
||||||
},
|
},
|
||||||
@@ -431,13 +502,13 @@ def callbackSelectedLanguagePresetTab(selected_tab_no:str, *args, **kwargs) -> d
|
|||||||
config.TARGET_LANGUAGE = select["language"]
|
config.TARGET_LANGUAGE = select["language"]
|
||||||
config.TARGET_COUNTRY = select["country"]
|
config.TARGET_COUNTRY = select["country"]
|
||||||
updateTranslationEngineAndEngineList()
|
updateTranslationEngineAndEngineList()
|
||||||
return {"status":"success", "data":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({"log": "callbackSelectedTranslationEngine", "data":selected_translation_engine}), flush=True)
|
print(json.dumps({"log": "callbackSelectedTranslationEngine", "data":selected_translation_engine}), flush=True)
|
||||||
setYourTranslateEngine(selected_translation_engine)
|
setYourTranslateEngine(selected_translation_engine)
|
||||||
setTargetTranslateEngine(selected_translation_engine)
|
setTargetTranslateEngine(selected_translation_engine)
|
||||||
return {"status":"success", "data":selected_translation_engine}
|
return {"status":200, "result":selected_translation_engine}
|
||||||
|
|
||||||
# command func
|
# command func
|
||||||
def callbackEnableTranslation(*args, **kwargs) -> dict:
|
def callbackEnableTranslation(*args, **kwargs) -> dict:
|
||||||
@@ -445,24 +516,24 @@ def callbackEnableTranslation(*args, **kwargs) -> dict:
|
|||||||
config.ENABLE_TRANSLATION = True
|
config.ENABLE_TRANSLATION = True
|
||||||
if model.isLoadedCTranslate2Model() is False:
|
if model.isLoadedCTranslate2Model() is False:
|
||||||
model.changeTranslatorCTranslate2Model()
|
model.changeTranslatorCTranslate2Model()
|
||||||
return {"status":"success", "data":config.ENABLE_TRANSLATION}
|
return {"status":200, "result":config.ENABLE_TRANSLATION}
|
||||||
|
|
||||||
def callbackDisableTranslation(*args, **kwargs) -> dict:
|
def callbackDisableTranslation(*args, **kwargs) -> dict:
|
||||||
print(json.dumps({"log": "callbackDisableTranslation"}), flush=True)
|
print(json.dumps({"log": "callbackDisableTranslation"}), flush=True)
|
||||||
config.ENABLE_TRANSLATION = False
|
config.ENABLE_TRANSLATION = False
|
||||||
return {"status":"success", "data":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({"log": "callbackEnableTranscriptionSend"}), flush=True)
|
print(json.dumps({"log": "callbackEnableTranscriptionSend"}), flush=True)
|
||||||
config.ENABLE_TRANSCRIPTION_SEND = True
|
config.ENABLE_TRANSCRIPTION_SEND = True
|
||||||
startThreadingTranscriptionSendMessage(action)
|
startThreadingTranscriptionSendMessage(action)
|
||||||
return {"status":"success", "data":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({"log": "callbackDisableTranscriptionSend"}), flush=True)
|
print(json.dumps({"log": "callbackDisableTranscriptionSend"}), flush=True)
|
||||||
config.ENABLE_TRANSCRIPTION_SEND = False
|
config.ENABLE_TRANSCRIPTION_SEND = False
|
||||||
stopThreadingTranscriptionSendMessage(action)
|
stopThreadingTranscriptionSendMessage(action)
|
||||||
return {"status":"success", "data":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({"log": "callbackEnableTranscriptionReceive"}), flush=True)
|
print(json.dumps({"log": "callbackEnableTranscriptionReceive"}), flush=True)
|
||||||
@@ -472,33 +543,33 @@ def callbackEnableTranscriptionReceive(data, action, *args, **kwargs) -> dict:
|
|||||||
if config.ENABLE_OVERLAY_SMALL_LOG is True:
|
if config.ENABLE_OVERLAY_SMALL_LOG is True:
|
||||||
if model.overlay.initialized is False and model.overlay.checkSteamvrRunning() is True:
|
if model.overlay.initialized is False and model.overlay.checkSteamvrRunning() is True:
|
||||||
model.startOverlay()
|
model.startOverlay()
|
||||||
return {"status":"success", "data":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({"log": "callbackDisableTranscriptionReceive"}), flush=True)
|
print(json.dumps({"log": "callbackDisableTranscriptionReceive"}), flush=True)
|
||||||
config.ENABLE_TRANSCRIPTION_RECEIVE = False
|
config.ENABLE_TRANSCRIPTION_RECEIVE = False
|
||||||
stopThreadingTranscriptionReceiveMessage(action)
|
stopThreadingTranscriptionReceiveMessage(action)
|
||||||
return {"status":"success", "data":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({"log": "callbackEnableForeground"}), flush=True)
|
print(json.dumps({"log": "callbackEnableForeground"}), flush=True)
|
||||||
config.ENABLE_FOREGROUND = True
|
config.ENABLE_FOREGROUND = True
|
||||||
return {"status":"success", "data":config.ENABLE_FOREGROUND}
|
return {"status":200, "result":config.ENABLE_FOREGROUND}
|
||||||
|
|
||||||
def callbackDisableForeground(*args, **kwargs) -> dict:
|
def callbackDisableForeground(*args, **kwargs) -> dict:
|
||||||
print(json.dumps({"log": "callbackDisableForeground"}), flush=True)
|
print(json.dumps({"log": "callbackDisableForeground"}), flush=True)
|
||||||
config.ENABLE_FOREGROUND = False
|
config.ENABLE_FOREGROUND = False
|
||||||
return {"status":"success", "data":config.ENABLE_FOREGROUND}
|
return {"status":200, "result":config.ENABLE_FOREGROUND}
|
||||||
|
|
||||||
def callbackEnableMainWindowSidebarCompactMode(*args, **kwargs) -> dict:
|
def callbackEnableMainWindowSidebarCompactMode(*args, **kwargs) -> dict:
|
||||||
print(json.dumps({"log": "callbackEnableMainWindowSidebarCompactMode"}), flush=True)
|
print(json.dumps({"log": "callbackEnableMainWindowSidebarCompactMode"}), flush=True)
|
||||||
config.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE = True
|
config.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE = True
|
||||||
return {"status":"success", "data":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({"log": "callbackDisableMainWindowSidebarCompactMode"}), flush=True)
|
print(json.dumps({"log": "callbackDisableMainWindowSidebarCompactMode"}), flush=True)
|
||||||
config.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE = False
|
config.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE = False
|
||||||
return {"status":"success", "data":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:
|
||||||
@@ -507,7 +578,7 @@ def callbackOpenConfigWindow(*args, **kwargs) -> dict:
|
|||||||
stopThreadingTranscriptionSendMessageOnOpenConfigWindow()
|
stopThreadingTranscriptionSendMessageOnOpenConfigWindow()
|
||||||
if config.ENABLE_TRANSCRIPTION_RECEIVE is True:
|
if config.ENABLE_TRANSCRIPTION_RECEIVE is True:
|
||||||
stopThreadingTranscriptionReceiveMessageOnOpenConfigWindow()
|
stopThreadingTranscriptionReceiveMessageOnOpenConfigWindow()
|
||||||
return {"status":"success"}
|
return {"status":200}
|
||||||
|
|
||||||
def callbackCloseConfigWindow(data, action, *args, **kwargs) -> dict:
|
def callbackCloseConfigWindow(data, action, *args, **kwargs) -> dict:
|
||||||
print(json.dumps({"log": "callbackCloseConfigWindow"}), flush=True)
|
print(json.dumps({"log": "callbackCloseConfigWindow"}), flush=True)
|
||||||
@@ -520,7 +591,7 @@ def callbackCloseConfigWindow(data, action, *args, **kwargs) -> dict:
|
|||||||
sleep(2)
|
sleep(2)
|
||||||
if config.ENABLE_TRANSCRIPTION_RECEIVE is True:
|
if config.ENABLE_TRANSCRIPTION_RECEIVE is True:
|
||||||
startThreadingTranscriptionReceiveMessageOnCloseConfigWindow(action)
|
startThreadingTranscriptionReceiveMessageOnCloseConfigWindow(action)
|
||||||
return {"status":"success"}
|
return {"status":200}
|
||||||
|
|
||||||
# Compact Mode Switch
|
# Compact Mode Switch
|
||||||
def callbackEnableConfigWindowCompactMode(*args, **kwargs) -> dict:
|
def callbackEnableConfigWindowCompactMode(*args, **kwargs) -> dict:
|
||||||
@@ -528,56 +599,56 @@ def callbackEnableConfigWindowCompactMode(*args, **kwargs) -> dict:
|
|||||||
config.IS_CONFIG_WINDOW_COMPACT_MODE = True
|
config.IS_CONFIG_WINDOW_COMPACT_MODE = True
|
||||||
model.stopCheckMicEnergy()
|
model.stopCheckMicEnergy()
|
||||||
model.stopCheckSpeakerEnergy()
|
model.stopCheckSpeakerEnergy()
|
||||||
return {"status":"success", "data":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({"log": "callbackDisableConfigWindowCompactMode"}), flush=True)
|
print(json.dumps({"log": "callbackDisableConfigWindowCompactMode"}), flush=True)
|
||||||
config.IS_CONFIG_WINDOW_COMPACT_MODE = False
|
config.IS_CONFIG_WINDOW_COMPACT_MODE = False
|
||||||
model.stopCheckMicEnergy()
|
model.stopCheckMicEnergy()
|
||||||
model.stopCheckSpeakerEnergy()
|
model.stopCheckSpeakerEnergy()
|
||||||
return {"status":"success", "data":config.IS_CONFIG_WINDOW_COMPACT_MODE}
|
return {"status":200, "result":config.IS_CONFIG_WINDOW_COMPACT_MODE}
|
||||||
|
|
||||||
# Appearance Tab
|
# Appearance Tab
|
||||||
def callbackSetTransparency(data, *args, **kwargs) -> dict:
|
def callbackSetTransparency(data, *args, **kwargs) -> dict:
|
||||||
print(json.dumps({"log": "callbackSetTransparency", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetTransparency", "data":data}), flush=True)
|
||||||
config.TRANSPARENCY = int(data)
|
config.TRANSPARENCY = int(data)
|
||||||
return {"status":"success", "data":config.TRANSPARENCY}
|
return {"status":200, "result":config.TRANSPARENCY}
|
||||||
|
|
||||||
def callbackSetAppearance(data, *args, **kwargs) -> dict:
|
def callbackSetAppearance(data, *args, **kwargs) -> dict:
|
||||||
print(json.dumps({"log": "callbackSetAppearance", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetAppearance", "data":data}), flush=True)
|
||||||
config.APPEARANCE_THEME = data
|
config.APPEARANCE_THEME = data
|
||||||
return {"status":"success", "data":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({"log": "callbackSetUiScaling", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetUiScaling", "data":data}), flush=True)
|
||||||
config.UI_SCALING = data
|
config.UI_SCALING = data
|
||||||
return {"status":"success", "data":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({"log": "callbackSetTextboxUiScaling", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetTextboxUiScaling", "data":data}), flush=True)
|
||||||
config.TEXTBOX_UI_SCALING = int(data)
|
config.TEXTBOX_UI_SCALING = int(data)
|
||||||
return {"status":"success", "data":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({"log": "callbackSetMessageBoxRatio", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetMessageBoxRatio", "data":data}), flush=True)
|
||||||
config.MESSAGE_BOX_RATIO = int(data)
|
config.MESSAGE_BOX_RATIO = int(data)
|
||||||
return {"status":"success", "data":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({"log": "callbackSetFontFamily", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetFontFamily", "data":data}), flush=True)
|
||||||
config.FONT_FAMILY = data
|
config.FONT_FAMILY = data
|
||||||
return {"status":"success", "data":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({"log": "callbackSetUiLanguage", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetUiLanguage", "data":data}), flush=True)
|
||||||
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":"success", "data":config.UI_LANGUAGE}
|
return {"status":200, "result":config.UI_LANGUAGE}
|
||||||
|
|
||||||
def callbackSetEnableRestoreMainWindowGeometry(data, *args, **kwargs) -> dict:
|
def callbackSetEnableRestoreMainWindowGeometry(data, *args, **kwargs) -> dict:
|
||||||
print(json.dumps({"log": "callbackSetEnableRestoreMainWindowGeometry", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetEnableRestoreMainWindowGeometry", "data":data}), flush=True)
|
||||||
config.ENABLE_RESTORE_MAIN_WINDOW_GEOMETRY = data
|
config.ENABLE_RESTORE_MAIN_WINDOW_GEOMETRY = data
|
||||||
return {"status":"success", "data":config.ENABLE_RESTORE_MAIN_WINDOW_GEOMETRY}
|
return {"status":200, "result":config.ENABLE_RESTORE_MAIN_WINDOW_GEOMETRY}
|
||||||
|
|
||||||
# Translation Tab
|
# Translation Tab
|
||||||
def callbackSetUseTranslationFeature(data, *args, **kwargs) -> dict:
|
def callbackSetUseTranslationFeature(data, *args, **kwargs) -> dict:
|
||||||
@@ -595,8 +666,8 @@ def callbackSetUseTranslationFeature(data, *args, **kwargs) -> dict:
|
|||||||
config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = True
|
config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = True
|
||||||
else:
|
else:
|
||||||
config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = False
|
config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = False
|
||||||
return {"status":"success",
|
return {"status":200,
|
||||||
"data":{
|
"result":{
|
||||||
"feature":config.USE_TRANSLATION_FEATURE,
|
"feature":config.USE_TRANSLATION_FEATURE,
|
||||||
"reset":config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION,
|
"reset":config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION,
|
||||||
},
|
},
|
||||||
@@ -614,8 +685,8 @@ def callbackSetCtranslate2WeightType(data, *args, **kwargs) -> dict:
|
|||||||
th_callback.start()
|
th_callback.start()
|
||||||
else:
|
else:
|
||||||
config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = True
|
config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = True
|
||||||
return {"status":"success",
|
return {"status":200,
|
||||||
"data":{
|
"result":{
|
||||||
"feature":config.CTRANSLATE2_WEIGHT_TYPE,
|
"feature":config.CTRANSLATE2_WEIGHT_TYPE,
|
||||||
"reset":config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION,
|
"reset":config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION,
|
||||||
},
|
},
|
||||||
@@ -623,19 +694,19 @@ def callbackSetCtranslate2WeightType(data, *args, **kwargs) -> dict:
|
|||||||
|
|
||||||
def callbackSetDeeplAuthKey(data, *args, **kwargs) -> dict:
|
def callbackSetDeeplAuthKey(data, *args, **kwargs) -> dict:
|
||||||
print(json.dumps({"log": "callbackSetDeeplAuthKey", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetDeeplAuthKey", "data":data}), flush=True)
|
||||||
status = "error"
|
status = 404
|
||||||
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)
|
||||||
if result is True:
|
if result is True:
|
||||||
key = data
|
key = data
|
||||||
status = "success"
|
status = 200
|
||||||
else:
|
else:
|
||||||
key = None
|
key = None
|
||||||
auth_keys = config.AUTH_KEYS
|
auth_keys = config.AUTH_KEYS
|
||||||
auth_keys["DeepL_API"] = key
|
auth_keys["DeepL_API"] = key
|
||||||
config.AUTH_KEYS = auth_keys
|
config.AUTH_KEYS = auth_keys
|
||||||
updateTranslationEngineAndEngineList()
|
updateTranslationEngineAndEngineList()
|
||||||
return {"status":status, "data":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({"log": "callbackClearDeeplAuthKey"}), flush=True)
|
print(json.dumps({"log": "callbackClearDeeplAuthKey"}), flush=True)
|
||||||
@@ -643,7 +714,7 @@ def callbackClearDeeplAuthKey(*args, **kwargs) -> dict:
|
|||||||
auth_keys["DeepL_API"] = None
|
auth_keys["DeepL_API"] = None
|
||||||
config.AUTH_KEYS = auth_keys
|
config.AUTH_KEYS = auth_keys
|
||||||
updateTranslationEngineAndEngineList()
|
updateTranslationEngineAndEngineList()
|
||||||
return {"status":"success", "data":config.AUTH_KEYS["DeepL_API"]}
|
return {"status":200, "result":config.AUTH_KEYS["DeepL_API"]}
|
||||||
|
|
||||||
# Transcription Tab
|
# Transcription Tab
|
||||||
# Transcription (Mic)
|
# Transcription (Mic)
|
||||||
@@ -652,8 +723,8 @@ def callbackSetMicHost(data, *args, **kwargs) -> dict:
|
|||||||
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()
|
||||||
return {"status":"success",
|
return {"status":200,
|
||||||
"data":{
|
"result":{
|
||||||
"host":config.CHOICE_MIC_HOST,
|
"host":config.CHOICE_MIC_HOST,
|
||||||
"device":config.CHOICE_MIC_DEVICE,
|
"device":config.CHOICE_MIC_DEVICE,
|
||||||
},
|
},
|
||||||
@@ -663,43 +734,43 @@ def callbackSetMicDevice(data, *args, **kwargs) -> dict:
|
|||||||
print(json.dumps({"log": "callbackSetMicDevice", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetMicDevice", "data":data}), flush=True)
|
||||||
config.CHOICE_MIC_DEVICE = data
|
config.CHOICE_MIC_DEVICE = data
|
||||||
model.stopCheckMicEnergy()
|
model.stopCheckMicEnergy()
|
||||||
return {"status":"success",
|
return {"status":200,
|
||||||
"data":{
|
"result":{
|
||||||
"host":config.CHOICE_MIC_HOST,
|
"host":config.CHOICE_MIC_HOST,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
def callbackSetMicEnergyThreshold(data, *args, **kwargs) -> dict:
|
def callbackSetMicEnergyThreshold(data, *args, **kwargs) -> dict:
|
||||||
print(json.dumps({"log": "callbackSetMicEnergyThreshold", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetMicEnergyThreshold", "data":data}), flush=True)
|
||||||
status = "error"
|
status = 404
|
||||||
data = int(data)
|
data = int(data)
|
||||||
if 0 <= data <= config.MAX_MIC_ENERGY_THRESHOLD:
|
if 0 <= data <= config.MAX_MIC_ENERGY_THRESHOLD:
|
||||||
config.INPUT_MIC_ENERGY_THRESHOLD = data
|
config.INPUT_MIC_ENERGY_THRESHOLD = data
|
||||||
status = "success"
|
status = 200
|
||||||
return {"status": status, "data": config.INPUT_MIC_ENERGY_THRESHOLD}
|
return {"status": status, "result": config.INPUT_MIC_ENERGY_THRESHOLD}
|
||||||
|
|
||||||
def callbackSetMicDynamicEnergyThreshold(data, *args, **kwargs) -> dict:
|
def callbackSetMicDynamicEnergyThreshold(data, *args, **kwargs) -> dict:
|
||||||
print(json.dumps({"log": "callbackSetMicDynamicEnergyThreshold", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetMicDynamicEnergyThreshold", "data":data}), flush=True)
|
||||||
config.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD = data
|
config.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD = data
|
||||||
return {"status":"success", "data":config.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD}
|
return {"status":200, "result":config.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD}
|
||||||
|
|
||||||
class ProgressBarEnergy:
|
class ProgressBarEnergy:
|
||||||
def __init__(self, action):
|
def __init__(self, action):
|
||||||
self.action = action
|
self.action = action
|
||||||
|
|
||||||
def set(self, energy) -> None:
|
def set(self, energy) -> None:
|
||||||
self.action("energy", {"status":"success", "energy":energy})
|
self.action("energy", {"status":200, "result":energy})
|
||||||
|
|
||||||
def callbackEnableCheckMicThreshold(data, action, *args, **kwargs) -> dict:
|
def callbackEnableCheckMicThreshold(data, action, *args, **kwargs) -> dict:
|
||||||
print(json.dumps({"log": "callbackEnableCheckMicThreshold"}), flush=True)
|
print(json.dumps({"log": "callbackEnableCheckMicThreshold"}), flush=True)
|
||||||
progressbar_mic_energy = ProgressBarEnergy(action)
|
progressbar_mic_energy = ProgressBarEnergy(action)
|
||||||
model.startCheckMicEnergy(progressbar_mic_energy.set)
|
model.startCheckMicEnergy(progressbar_mic_energy.set)
|
||||||
return {"status":"success"}
|
return {"status":200}
|
||||||
|
|
||||||
def callbackDisableCheckMicThreshold(*args, **kwargs) -> dict:
|
def callbackDisableCheckMicThreshold(*args, **kwargs) -> dict:
|
||||||
print(json.dumps({"log": "callbackDisableCheckMicThreshold"}), flush=True)
|
print(json.dumps({"log": "callbackDisableCheckMicThreshold"}), flush=True)
|
||||||
model.stopCheckMicEnergy()
|
model.stopCheckMicEnergy()
|
||||||
return {"status":"success"}
|
return {"status":200}
|
||||||
|
|
||||||
def callbackSetMicRecordTimeout(data, *args, **kwargs) -> dict:
|
def callbackSetMicRecordTimeout(data, *args, **kwargs) -> dict:
|
||||||
print(json.dumps({"log": "callbackSetMicRecordTimeout", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetMicRecordTimeout", "data":data}), flush=True)
|
||||||
@@ -710,9 +781,9 @@ def callbackSetMicRecordTimeout(data, *args, **kwargs) -> dict:
|
|||||||
else:
|
else:
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
except Exception:
|
except Exception:
|
||||||
response = {"status":"error", "message":"Error Mic Record Timeout"}
|
response = {"status":404, "result":{"message":"Error Mic Record Timeout"}}
|
||||||
else:
|
else:
|
||||||
response = {"status":"success", "data":config.INPUT_MIC_RECORD_TIMEOUT}
|
response = {"status":200, "result":config.INPUT_MIC_RECORD_TIMEOUT}
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def callbackSetMicPhraseTimeout(data, *args, **kwargs) -> dict:
|
def callbackSetMicPhraseTimeout(data, *args, **kwargs) -> dict:
|
||||||
@@ -724,9 +795,9 @@ def callbackSetMicPhraseTimeout(data, *args, **kwargs) -> dict:
|
|||||||
else:
|
else:
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
except Exception:
|
except Exception:
|
||||||
response = {"status":"error", "message":"Error Mic Phrase Timeout"}
|
response = {"status":404, "result":{"message":"Error Mic Phrase Timeout"}}
|
||||||
else:
|
else:
|
||||||
response = {"status":"success", "data":config.INPUT_MIC_PHRASE_TIMEOUT}
|
response = {"status":200, "result":config.INPUT_MIC_PHRASE_TIMEOUT}
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def callbackSetMicMaxPhrases(data, *args, **kwargs) -> dict:
|
def callbackSetMicMaxPhrases(data, *args, **kwargs) -> dict:
|
||||||
@@ -738,9 +809,9 @@ def callbackSetMicMaxPhrases(data, *args, **kwargs) -> dict:
|
|||||||
else:
|
else:
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
except Exception:
|
except Exception:
|
||||||
response = {"status":"error", "message":"Error Mic Max Phrases"}
|
response = {"status":404, "result":{"message":"Error Mic Max Phrases"}}
|
||||||
else:
|
else:
|
||||||
response = {"status":"success", "data":config.INPUT_MIC_MAX_PHRASES}
|
response = {"status":200, "result":config.INPUT_MIC_MAX_PHRASES}
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def callbackSetMicWordFilter(data, *args, **kwargs) -> dict:
|
def callbackSetMicWordFilter(data, *args, **kwargs) -> dict:
|
||||||
@@ -761,7 +832,7 @@ def callbackSetMicWordFilter(data, *args, **kwargs) -> dict:
|
|||||||
|
|
||||||
model.resetKeywordProcessor()
|
model.resetKeywordProcessor()
|
||||||
model.addKeywords()
|
model.addKeywords()
|
||||||
return {"status":"success", "data":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({"log": "callbackDeleteMicWordFilter", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackDeleteMicWordFilter", "data":data}), flush=True)
|
||||||
@@ -773,14 +844,14 @@ def callbackDeleteMicWordFilter(data, *args, **kwargs) -> dict:
|
|||||||
model.addKeywords()
|
model.addKeywords()
|
||||||
except Exception:
|
except Exception:
|
||||||
print("There was no the target word in config.INPUT_MIC_WORD_FILTER")
|
print("There was no the target word in config.INPUT_MIC_WORD_FILTER")
|
||||||
return {"status":"success", "data":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({"log": "callbackSetSpeakerDevice", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetSpeakerDevice", "data":data}), flush=True)
|
||||||
config.CHOICE_SPEAKER_DEVICE = data
|
config.CHOICE_SPEAKER_DEVICE = data
|
||||||
model.stopCheckSpeakerEnergy()
|
model.stopCheckSpeakerEnergy()
|
||||||
return {"status":"success", "data":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({"log": "callbackSetSpeakerEnergyThreshold", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetSpeakerEnergyThreshold", "data":data}), flush=True)
|
||||||
@@ -793,26 +864,26 @@ def callbackSetSpeakerEnergyThreshold(data, *args, **kwargs) -> dict:
|
|||||||
else:
|
else:
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
except Exception:
|
except Exception:
|
||||||
response = {"status":"error", "message":"Error Set Speaker Energy Threshold"}
|
response = {"status":404, "result":{"message":"Error Set Speaker Energy Threshold"}}
|
||||||
else:
|
else:
|
||||||
response = {"status":"success", "data":config.INPUT_SPEAKER_ENERGY_THRESHOLD}
|
response = {"status":200, "result":config.INPUT_SPEAKER_ENERGY_THRESHOLD}
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def callbackSetSpeakerDynamicEnergyThreshold(data, *args, **kwargs) -> dict:
|
def callbackSetSpeakerDynamicEnergyThreshold(data, *args, **kwargs) -> dict:
|
||||||
print(json.dumps({"log": "callbackSetSpeakerDynamicEnergyThreshold", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetSpeakerDynamicEnergyThreshold", "data":data}), flush=True)
|
||||||
config.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD = data
|
config.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD = data
|
||||||
return {"status":"success", "data":config.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD}
|
return {"status":200, "result":config.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD}
|
||||||
|
|
||||||
def callbackEnableCheckSpeakerThreshold(data, action, *args, **kwargs) -> dict:
|
def callbackEnableCheckSpeakerThreshold(data, action, *args, **kwargs) -> dict:
|
||||||
print(json.dumps({"log": "callbackEnableCheckSpeakerThreshold"}), flush=True)
|
print(json.dumps({"log": "callbackEnableCheckSpeakerThreshold"}), flush=True)
|
||||||
progressbar_speaker_energy = ProgressBarEnergy(action)
|
progressbar_speaker_energy = ProgressBarEnergy(action)
|
||||||
model.startCheckSpeakerEnergy(progressbar_speaker_energy.set)
|
model.startCheckSpeakerEnergy(progressbar_speaker_energy.set)
|
||||||
return {"status":"success"}
|
return {"status":200}
|
||||||
|
|
||||||
def callbackDisableCheckSpeakerThreshold(*args, **kwargs) -> dict:
|
def callbackDisableCheckSpeakerThreshold(*args, **kwargs) -> dict:
|
||||||
print(json.dumps({"log": "callbackDisableCheckSpeakerThreshold"}), flush=True)
|
print(json.dumps({"log": "callbackDisableCheckSpeakerThreshold"}), flush=True)
|
||||||
model.stopCheckSpeakerEnergy()
|
model.stopCheckSpeakerEnergy()
|
||||||
return {"status":"success"}
|
return {"status":200}
|
||||||
|
|
||||||
def callbackSetSpeakerRecordTimeout(data, *args, **kwargs) -> dict:
|
def callbackSetSpeakerRecordTimeout(data, *args, **kwargs) -> dict:
|
||||||
print(json.dumps({"log": "callbackSetSpeakerRecordTimeout", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetSpeakerRecordTimeout", "data":data}), flush=True)
|
||||||
@@ -823,9 +894,9 @@ def callbackSetSpeakerRecordTimeout(data, *args, **kwargs) -> dict:
|
|||||||
else:
|
else:
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
except Exception:
|
except Exception:
|
||||||
response = {"status":"error", "message":"Error Speaker Record Timeout"}
|
response = {"status":404, "result":{"message":"Error Speaker Record Timeout"}}
|
||||||
else:
|
else:
|
||||||
response = {"status":"success", "data":config.INPUT_SPEAKER_RECORD_TIMEOUT}
|
response = {"status":200, "result":config.INPUT_SPEAKER_RECORD_TIMEOUT}
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def callbackSetSpeakerPhraseTimeout(data, *args, **kwargs) -> dict:
|
def callbackSetSpeakerPhraseTimeout(data, *args, **kwargs) -> dict:
|
||||||
@@ -837,9 +908,9 @@ def callbackSetSpeakerPhraseTimeout(data, *args, **kwargs) -> dict:
|
|||||||
else:
|
else:
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
except Exception:
|
except Exception:
|
||||||
response = {"status":"error", "message":"Error Speaker Phrase Timeout"}
|
response = {"status":404, "result":{"message":"Error Speaker Phrase Timeout"}}
|
||||||
else:
|
else:
|
||||||
response = {"status":"success", "data":config.INPUT_SPEAKER_PHRASE_TIMEOUT}
|
response = {"status":200, "result":config.INPUT_SPEAKER_PHRASE_TIMEOUT}
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def callbackSetSpeakerMaxPhrases(data, *args, **kwargs) -> dict:
|
def callbackSetSpeakerMaxPhrases(data, *args, **kwargs) -> dict:
|
||||||
@@ -851,9 +922,9 @@ def callbackSetSpeakerMaxPhrases(data, *args, **kwargs) -> dict:
|
|||||||
else:
|
else:
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
except Exception:
|
except Exception:
|
||||||
response = {"status":"error", "message":"Error Speaker Max Phrases"}
|
response = {"status":404, "result":{"message":"Error Speaker Max Phrases"}}
|
||||||
else:
|
else:
|
||||||
response = {"status":"success", "data":config.INPUT_SPEAKER_MAX_PHRASES}
|
response = {"status":200, "result":config.INPUT_SPEAKER_MAX_PHRASES}
|
||||||
return response
|
return response
|
||||||
|
|
||||||
# Transcription (Internal AI Model)
|
# Transcription (Internal AI Model)
|
||||||
@@ -870,8 +941,8 @@ def callbackSetUserWhisperFeature(data, *args, **kwargs) -> dict:
|
|||||||
else:
|
else:
|
||||||
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"
|
||||||
return {"status":"success",
|
return {"status":200,
|
||||||
"data":{
|
"result":{
|
||||||
"feature":config.USE_WHISPER_FEATURE,
|
"feature":config.USE_WHISPER_FEATURE,
|
||||||
"transcription_engine":config.SELECTED_TRANSCRIPTION_ENGINE,
|
"transcription_engine":config.SELECTED_TRANSCRIPTION_ENGINE,
|
||||||
"reset":config.IS_RESET_BUTTON_DISPLAYED_FOR_WHISPER,
|
"reset":config.IS_RESET_BUTTON_DISPLAYED_FOR_WHISPER,
|
||||||
@@ -887,8 +958,8 @@ def callbackSetWhisperWeightType(data, *args, **kwargs) -> dict:
|
|||||||
else:
|
else:
|
||||||
config.IS_RESET_BUTTON_DISPLAYED_FOR_WHISPER = True
|
config.IS_RESET_BUTTON_DISPLAYED_FOR_WHISPER = True
|
||||||
config.SELECTED_TRANSCRIPTION_ENGINE = "Google"
|
config.SELECTED_TRANSCRIPTION_ENGINE = "Google"
|
||||||
return {"status":"success",
|
return {"status":200,
|
||||||
"data":{
|
"result":{
|
||||||
"weight_type":config.WHISPER_WEIGHT_TYPE,
|
"weight_type":config.WHISPER_WEIGHT_TYPE,
|
||||||
"transcription_engine":config.SELECTED_TRANSCRIPTION_ENGINE,
|
"transcription_engine":config.SELECTED_TRANSCRIPTION_ENGINE,
|
||||||
"reset":config.IS_RESET_BUTTON_DISPLAYED_FOR_WHISPER,
|
"reset":config.IS_RESET_BUTTON_DISPLAYED_FOR_WHISPER,
|
||||||
@@ -902,7 +973,7 @@ def callbackSetOverlaySettingsOpacity(data, *args, **kwargs) -> dict:
|
|||||||
pre_settings["opacity"] = data
|
pre_settings["opacity"] = data
|
||||||
config.OVERLAY_SETTINGS = pre_settings
|
config.OVERLAY_SETTINGS = pre_settings
|
||||||
model.updateOverlayImageOpacity()
|
model.updateOverlayImageOpacity()
|
||||||
return {"status":"success", "data":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({"log": "callbackSetOverlaySettingsUiScaling", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetOverlaySettingsUiScaling", "data":data}), flush=True)
|
||||||
@@ -910,7 +981,7 @@ def callbackSetOverlaySettingsUiScaling(data, *args, **kwargs) -> dict:
|
|||||||
pre_settings["ui_scaling"] = data
|
pre_settings["ui_scaling"] = data
|
||||||
config.OVERLAY_SETTINGS = pre_settings
|
config.OVERLAY_SETTINGS = pre_settings
|
||||||
model.updateOverlayImageUiScaling()
|
model.updateOverlayImageUiScaling()
|
||||||
return {"status":"success", "data":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({"log": "callbackEnableOverlaySmallLog"}), flush=True)
|
print(json.dumps({"log": "callbackEnableOverlaySmallLog"}), flush=True)
|
||||||
@@ -919,7 +990,7 @@ def callbackEnableOverlaySmallLog(*args, **kwargs) -> dict:
|
|||||||
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:
|
||||||
if model.overlay.initialized is False and model.overlay.checkSteamvrRunning() is True:
|
if model.overlay.initialized is False and model.overlay.checkSteamvrRunning() is True:
|
||||||
model.startOverlay()
|
model.startOverlay()
|
||||||
return {"status":"success", "data":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({"log": "callbackDisableOverlaySmallLog"}), flush=True)
|
print(json.dumps({"log": "callbackDisableOverlaySmallLog"}), flush=True)
|
||||||
@@ -927,7 +998,7 @@ def callbackDisableOverlaySmallLog(*args, **kwargs) -> dict:
|
|||||||
if config.ENABLE_OVERLAY_SMALL_LOG is False:
|
if config.ENABLE_OVERLAY_SMALL_LOG is False:
|
||||||
model.clearOverlayImage()
|
model.clearOverlayImage()
|
||||||
model.shutdownOverlay()
|
model.shutdownOverlay()
|
||||||
return {"status":"success", "data":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({"log": "callbackSetOverlaySmallLogSettingsXPos", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetOverlaySmallLogSettingsXPos", "data":data}), flush=True)
|
||||||
@@ -935,7 +1006,7 @@ def callbackSetOverlaySmallLogSettingsXPos(data, *args, **kwargs) -> dict:
|
|||||||
pre_settings["x_pos"] = data
|
pre_settings["x_pos"] = data
|
||||||
config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings
|
config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings
|
||||||
model.updateOverlayPosition()
|
model.updateOverlayPosition()
|
||||||
return {"status":"success", "data":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({"log": "callbackSetOverlaySmallLogSettingsYPos", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetOverlaySmallLogSettingsYPos", "data":data}), flush=True)
|
||||||
@@ -943,7 +1014,7 @@ def callbackSetOverlaySmallLogSettingsYPos(data, *args, **kwargs) -> dict:
|
|||||||
pre_settings["y_pos"] = data
|
pre_settings["y_pos"] = data
|
||||||
config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings
|
config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings
|
||||||
model.updateOverlayPosition()
|
model.updateOverlayPosition()
|
||||||
return {"status":"success", "data":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({"log": "callbackSetOverlaySmallLogSettingsZPos", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetOverlaySmallLogSettingsZPos", "data":data}), flush=True)
|
||||||
@@ -951,7 +1022,7 @@ def callbackSetOverlaySmallLogSettingsZPos(data, *args, **kwargs) -> dict:
|
|||||||
pre_settings["z_pos"] = data
|
pre_settings["z_pos"] = data
|
||||||
config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings
|
config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings
|
||||||
model.updateOverlayPosition()
|
model.updateOverlayPosition()
|
||||||
return {"status":"success", "data":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({"log": "callbackSetOverlaySmallLogSettingsXRotation", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetOverlaySmallLogSettingsXRotation", "data":data}), flush=True)
|
||||||
@@ -959,7 +1030,7 @@ def callbackSetOverlaySmallLogSettingsXRotation(data, *args, **kwargs) -> dict:
|
|||||||
pre_settings["x_rotation"] = data
|
pre_settings["x_rotation"] = data
|
||||||
config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings
|
config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings
|
||||||
model.updateOverlayPosition()
|
model.updateOverlayPosition()
|
||||||
return {"status":"success", "data":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({"log": "callbackSetOverlaySmallLogSettingsYRotation", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetOverlaySmallLogSettingsYRotation", "data":data}), flush=True)
|
||||||
@@ -967,7 +1038,7 @@ def callbackSetOverlaySmallLogSettingsYRotation(data, *args, **kwargs) -> dict:
|
|||||||
pre_settings["y_rotation"] = data
|
pre_settings["y_rotation"] = data
|
||||||
config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings
|
config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings
|
||||||
model.updateOverlayPosition()
|
model.updateOverlayPosition()
|
||||||
return {"status":"success", "data":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({"log": "callbackSetOverlaySmallLogSettingsZRotation", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetOverlaySmallLogSettingsZRotation", "data":data}), flush=True)
|
||||||
@@ -975,33 +1046,33 @@ def callbackSetOverlaySmallLogSettingsZRotation(data, *args, **kwargs) -> dict:
|
|||||||
pre_settings["z_rotation"] = data
|
pre_settings["z_rotation"] = data
|
||||||
config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings
|
config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings
|
||||||
model.updateOverlayPosition()
|
model.updateOverlayPosition()
|
||||||
return {"status":"success", "data":config.OVERLAY_SMALL_LOG_SETTINGS["z_rotation"]}
|
return {"status":200, "result":config.OVERLAY_SMALL_LOG_SETTINGS["z_rotation"]}
|
||||||
|
|
||||||
# Others Tab
|
# Others Tab
|
||||||
def callbackSetEnableAutoClearMessageBox(data, *args, **kwargs) -> dict:
|
def callbackSetEnableAutoClearMessageBox(data, *args, **kwargs) -> dict:
|
||||||
print(json.dumps({"log": "callbackSetEnableAutoClearMessageBox", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetEnableAutoClearMessageBox", "data":data}), flush=True)
|
||||||
config.ENABLE_AUTO_CLEAR_MESSAGE_BOX = data
|
config.ENABLE_AUTO_CLEAR_MESSAGE_BOX = data
|
||||||
return {"status":"success", "data":config.ENABLE_AUTO_CLEAR_MESSAGE_BOX}
|
return {"status":200, "result":config.ENABLE_AUTO_CLEAR_MESSAGE_BOX}
|
||||||
|
|
||||||
def callbackSetEnableSendOnlyTranslatedMessages(data, *args, **kwargs) -> dict:
|
def callbackSetEnableSendOnlyTranslatedMessages(data, *args, **kwargs) -> dict:
|
||||||
print(json.dumps({"log": "callbackSetEnableSendOnlyTranslatedMessages", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetEnableSendOnlyTranslatedMessages", "data":data}), flush=True)
|
||||||
config.ENABLE_SEND_ONLY_TRANSLATED_MESSAGES = data
|
config.ENABLE_SEND_ONLY_TRANSLATED_MESSAGES = data
|
||||||
return {"status":"success", "data":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({"log": "callbackSetSendMessageButtonType", "data":data}), flush=True)
|
print(json.dumps({"log": "callbackSetSendMessageButtonType", "data":data}), flush=True)
|
||||||
config.SEND_MESSAGE_BUTTON_TYPE = data
|
config.SEND_MESSAGE_BUTTON_TYPE = data
|
||||||
return {"status":"success", "data":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({"log": "callbackEnableNoticeXsoverlay"}), flush=True)
|
print(json.dumps({"log": "callbackEnableNoticeXsoverlay"}), flush=True)
|
||||||
config.ENABLE_NOTICE_XSOVERLAY = True
|
config.ENABLE_NOTICE_XSOVERLAY = True
|
||||||
return {"status":"success", "data":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({"log": "callbackDisableNoticeXsoverlay"}), flush=True)
|
print(json.dumps({"log": "callbackDisableNoticeXsoverlay"}), flush=True)
|
||||||
config.ENABLE_NOTICE_XSOVERLAY = False
|
config.ENABLE_NOTICE_XSOVERLAY = False
|
||||||
return {"status":"success", "data":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({"log": "callbackEnableAutoExportMessageLogs"}), flush=True)
|
print(json.dumps({"log": "callbackEnableAutoExportMessageLogs"}), flush=True)
|
||||||
@@ -1028,63 +1099,63 @@ def callbackDisableVrcMicMuteSync(*args, **kwargs) -> dict:
|
|||||||
def callbackEnableSendMessageToVrc(*args, **kwargs) -> dict:
|
def callbackEnableSendMessageToVrc(*args, **kwargs) -> dict:
|
||||||
print(json.dumps({"log": "callbackEnableSendMessageToVrc"}), flush=True)
|
print(json.dumps({"log": "callbackEnableSendMessageToVrc"}), flush=True)
|
||||||
config.ENABLE_SEND_MESSAGE_TO_VRC = True
|
config.ENABLE_SEND_MESSAGE_TO_VRC = True
|
||||||
return {"status":"success", "data":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({"log": "callbackSetEnableSendMessageToVrc"}), flush=True)
|
print(json.dumps({"log": "callbackSetEnableSendMessageToVrc"}), flush=True)
|
||||||
config.ENABLE_SEND_MESSAGE_TO_VRC = False
|
config.ENABLE_SEND_MESSAGE_TO_VRC = False
|
||||||
return {"status":"success", "data":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({"log": "callbackSetSendMessageFormat", "data": str(data)}), flush=True)
|
print(json.dumps({"log": "callbackSetSendMessageFormat", "data": str(data)}), flush=True)
|
||||||
if isUniqueStrings(["[message]"], data) is True:
|
if isUniqueStrings(["[message]"], data) is True:
|
||||||
config.SEND_MESSAGE_FORMAT = data
|
config.SEND_MESSAGE_FORMAT = data
|
||||||
return {"status":"success", "data":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({"log": "callbackSetReceivedMessageFormat", "data": str(data)}), flush=True)
|
print(json.dumps({"log": "callbackSetReceivedMessageFormat", "data": str(data)}), flush=True)
|
||||||
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
|
||||||
return {"status":"success", "data":config.SEND_MESSAGE_FORMAT_WITH_T}
|
return {"status":200, "result":config.SEND_MESSAGE_FORMAT_WITH_T}
|
||||||
|
|
||||||
# Others (Message Formats(Received)
|
# Others (Message Formats(Received)
|
||||||
def callbackSetReceivedMessageFormat(data, *args, **kwargs) -> dict:
|
def callbackSetReceivedMessageFormat(data, *args, **kwargs) -> dict:
|
||||||
print(json.dumps({"log": "callbackSetReceivedMessageFormat", "data": str(data)}), flush=True)
|
print(json.dumps({"log": "callbackSetReceivedMessageFormat", "data": str(data)}), flush=True)
|
||||||
if isUniqueStrings(["[message]"], data) is True:
|
if isUniqueStrings(["[message]"], data) is True:
|
||||||
config.RECEIVED_MESSAGE_FORMAT = data
|
config.RECEIVED_MESSAGE_FORMAT = data
|
||||||
return {"status":"success", "data":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({"log": "callbackSetReceivedMessageFormatWithT", "data": str(data)}), flush=True)
|
print(json.dumps({"log": "callbackSetReceivedMessageFormatWithT", "data": str(data)}), flush=True)
|
||||||
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
|
||||||
return {"status":"success", "data":config.RECEIVED_MESSAGE_FORMAT_WITH_T}
|
return {"status":200, "result":config.RECEIVED_MESSAGE_FORMAT_WITH_T}
|
||||||
|
|
||||||
# ---------------------Speaker2Chatbox---------------------
|
# ---------------------Speaker2Chatbox---------------------
|
||||||
def callbackEnableSendReceivedMessageToVrc(*args, **kwargs) -> dict:
|
def callbackEnableSendReceivedMessageToVrc(*args, **kwargs) -> dict:
|
||||||
print(json.dumps({"log": "callbackEnableSendReceivedMessageToVrc"}), flush=True)
|
print(json.dumps({"log": "callbackEnableSendReceivedMessageToVrc"}), flush=True)
|
||||||
config.ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC = True
|
config.ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC = True
|
||||||
return {"status":"success", "data":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({"log": "callbackDisableSendReceivedMessageToVrc"}), flush=True)
|
print(json.dumps({"log": "callbackDisableSendReceivedMessageToVrc"}), flush=True)
|
||||||
config.ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC = False
|
config.ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC = False
|
||||||
return {"status":"success", "data":config.ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC}
|
return {"status":200, "result":config.ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC}
|
||||||
# ---------------------Speaker2Chatbox---------------------
|
# ---------------------Speaker2Chatbox---------------------
|
||||||
|
|
||||||
# Advanced Settings Tab
|
# Advanced Settings Tab
|
||||||
def callbackSetOscIpAddress(data, *args, **kwargs) -> dict:
|
def callbackSetOscIpAddress(data, *args, **kwargs) -> dict:
|
||||||
print(json.dumps({"log": "callbackSetOscIpAddress", "data": str(data)}), flush=True)
|
print(json.dumps({"log": "callbackSetOscIpAddress", "data": str(data)}), flush=True)
|
||||||
config.OSC_IP_ADDRESS = str(data)
|
config.OSC_IP_ADDRESS = str(data)
|
||||||
return {"status":"success", "data":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({"log": "callbackSetOscPort", "data": int(data)}), flush=True)
|
print(json.dumps({"log": "callbackSetOscPort", "data": int(data)}), flush=True)
|
||||||
config.OSC_PORT = int(data)
|
config.OSC_PORT = int(data)
|
||||||
return {"status":"success", "data":config.OSC_PORT}
|
return {"status":200, "result":config.OSC_PORT}
|
||||||
|
|
||||||
def getListLanguageAndCountry():
|
def getListLanguageAndCountry():
|
||||||
return model.getListLanguageAndCountry()
|
return model.getListLanguageAndCountry()
|
||||||
|
|||||||
@@ -97,10 +97,11 @@ controller_mapping = {
|
|||||||
"/controller/list_mic_host": controller.getListInputHost,
|
"/controller/list_mic_host": controller.getListInputHost,
|
||||||
"/controller/list_mic_device": controller.getListInputDevice,
|
"/controller/list_mic_device": controller.getListInputDevice,
|
||||||
"/controller/list_speaker_device": controller.getListOutputDevice,
|
"/controller/list_speaker_device": controller.getListOutputDevice,
|
||||||
# "/controller/callback_update_software": controller.callbackUpdateSoftware,
|
"/controller/callback_update_software": controller.callbackUpdateSoftware,
|
||||||
# "/controller/callback_restart_software": controller.callbackRestartSoftware,
|
"/controller/callback_restart_software": controller.callbackRestartSoftware,
|
||||||
"/controller/callback_filepath_logs": controller.callbackFilepathLogs,
|
"/controller/callback_filepath_logs": controller.callbackFilepathLogs,
|
||||||
"/controller/callback_filepath_config_file": controller.callbackFilepathConfigFile,
|
"/controller/callback_filepath_config_file": controller.callbackFilepathConfigFile,
|
||||||
|
# "/controller/callback_enable_easter_egg": controller.callbackEnableEasterEgg,
|
||||||
"/controller/callback_open_config_window": controller.callbackOpenConfigWindow,
|
"/controller/callback_open_config_window": controller.callbackOpenConfigWindow,
|
||||||
"/controller/callback_close_config_window": controller.callbackCloseConfigWindow,
|
"/controller/callback_close_config_window": controller.callbackCloseConfigWindow,
|
||||||
"/controller/callback_enable_main_window_sidebar_compact_mode": controller.callbackEnableMainWindowSidebarCompactMode,
|
"/controller/callback_enable_main_window_sidebar_compact_mode": controller.callbackEnableMainWindowSidebarCompactMode,
|
||||||
@@ -111,6 +112,7 @@ controller_mapping = {
|
|||||||
"/controller/callback_disable_transcription_send": controller.callbackDisableTranscriptionSend,
|
"/controller/callback_disable_transcription_send": controller.callbackDisableTranscriptionSend,
|
||||||
"/controller/callback_enable_transcription_receive": controller.callbackEnableTranscriptionReceive,
|
"/controller/callback_enable_transcription_receive": controller.callbackEnableTranscriptionReceive,
|
||||||
"/controller/callback_disable_transcription_receive": controller.callbackDisableTranscriptionReceive,
|
"/controller/callback_disable_transcription_receive": controller.callbackDisableTranscriptionReceive,
|
||||||
|
"/controller/callback_messagebox_press_key_enter": controller.callbackMessageBoxPressKeyEnter,
|
||||||
"/controller/callback_enable_foreground": controller.callbackEnableForeground,
|
"/controller/callback_enable_foreground": controller.callbackEnableForeground,
|
||||||
"/controller/callback_disable_foreground": controller.callbackDisableForeground,
|
"/controller/callback_disable_foreground": controller.callbackDisableForeground,
|
||||||
"/controller/set_your_language_and_country": controller.setYourLanguageAndCountry,
|
"/controller/set_your_language_and_country": controller.setYourLanguageAndCountry,
|
||||||
@@ -185,12 +187,40 @@ controller_mapping = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
action_mapping = {
|
action_mapping = {
|
||||||
"/controller/callback_close_config_window": {"mic":"/action/transcription_send_message", "speaker":"/action/transcription_receive_message"},
|
"/controller/callback_update_software": {
|
||||||
"/controller/callback_enable_transcription_send": {"mic":"/action/transcription_send_message"},
|
"download":"/action/download_software",
|
||||||
"/controller/callback_disable_transcription_send": {"mic":"/action/transcription_send_stopped"},
|
"update":"/action/update_software"
|
||||||
"/controller/callback_enable_transcription_receive": {"speaker":"/action/transcription_receive_message"},
|
},
|
||||||
"/controller/callback_disable_transcription_receive": {"speaker":"/action/transcription_receive_stopped"},
|
"/controller/callback_close_config_window": {
|
||||||
"/controller/callback_enable_check_mic_threshold": {"mic":"/action/check_mic_threshold_energy"},
|
"mic":"/action/transcription_send_mic_message",
|
||||||
|
"speaker":"/action/transcription_receive_speaker_message",
|
||||||
|
"error_device":"/action/error_device",
|
||||||
|
"error_translation_engine":"/action/error_translation_engine",
|
||||||
|
"word_filter":"/action/word_filter",
|
||||||
|
},
|
||||||
|
"/controller/callback_enable_transcription_send": {
|
||||||
|
"mic":"/action/transcription_send_mic_message",
|
||||||
|
"error_device":"/action/error_device",
|
||||||
|
"error_translation_engine":"/action/error_translation_engine",
|
||||||
|
"word_filter":"/action/word_filter",
|
||||||
|
},
|
||||||
|
"/controller/callback_disable_transcription_send": {
|
||||||
|
"mic":"/action/transcription_send_mic_message_stopped"
|
||||||
|
},
|
||||||
|
"/controller/callback_enable_transcription_receive": {
|
||||||
|
"speaker":"/action/transcription_receive_speaker_message",
|
||||||
|
"error_device":"/action/error_device",
|
||||||
|
"error_translation_engine":"/action/error_translation_engine",
|
||||||
|
},
|
||||||
|
"/controller/callback_disable_transcription_receive": {
|
||||||
|
"speaker":"/action/transcription_receive_speaker_message_stopped"
|
||||||
|
},
|
||||||
|
"/controller/callback_enable_check_mic_threshold": {
|
||||||
|
"mic":"/action/check_mic_threshold_energy"
|
||||||
|
},
|
||||||
|
"/controller/callback_messagebox_press_key_enter": {
|
||||||
|
"error_translation_engine":"/action/error_translation_engine"
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
def handleConfigRequest(endpoint):
|
def handleConfigRequest(endpoint):
|
||||||
@@ -214,18 +244,21 @@ def handleControllerRequest(endpoint, data=None):
|
|||||||
response = handler(data, Action(action_endpoint).transmit)
|
response = handler(data, Action(action_endpoint).transmit)
|
||||||
else:
|
else:
|
||||||
response = handler(data)
|
response = handler(data)
|
||||||
status = 200
|
status = response.get("status", None)
|
||||||
return response, status
|
result = response.get("result", None)
|
||||||
|
return result, status
|
||||||
|
|
||||||
class Action:
|
class Action:
|
||||||
def __init__(self, endpoints:dict) -> None:
|
def __init__(self, endpoints:dict) -> None:
|
||||||
self.endpoints = endpoints
|
self.endpoints = endpoints
|
||||||
|
|
||||||
def transmit(self, key:str, data:dict) -> None:
|
def transmit(self, key:str, data:dict) -> None:
|
||||||
|
status = data.get("status", None)
|
||||||
|
result = data.get("result", None)
|
||||||
response = {
|
response = {
|
||||||
"endpoint": self.endpoints[key],
|
"endpoint": self.endpoints[key],
|
||||||
"status": 200,
|
"status": status,
|
||||||
"data": data,
|
"result": result,
|
||||||
}
|
}
|
||||||
response = json.dumps(response)
|
response = json.dumps(response)
|
||||||
print(response, flush=True)
|
print(response, flush=True)
|
||||||
@@ -291,7 +324,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
controller.init()
|
controller.init()
|
||||||
print(json.dumps({"init_key_from_py": "Initialization from Python."}), flush=True)
|
print(json.dumps({"log": "Initialization from Python."}), flush=True)
|
||||||
while True:
|
while True:
|
||||||
main()
|
main()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|||||||
Reference in New Issue
Block a user