From 519ab571378216cf7f6c1202566af2cf59987efb Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Wed, 28 Aug 2024 11:36:17 +0900 Subject: [PATCH 1/5] =?UTF-8?q?=F0=9F=97=91=EF=B8=8F[Removal]=20update/res?= =?UTF-8?q?tart=E5=87=A6=E7=90=86=E3=82=92=E5=88=A5=E3=83=97=E3=83=AD?= =?UTF-8?q?=E3=82=B0=E3=83=A9=E3=83=A0=E3=81=AB=E4=BB=BB=E3=81=9B=E3=82=8B?= =?UTF-8?q?=E3=81=9F=E3=82=81=E3=83=90=E3=83=83=E3=83=81=E5=87=A6=E7=90=86?= =?UTF-8?q?=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- batch/restart.bat | 9 --------- batch/update.bat | 20 -------------------- package.json | 2 +- 3 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 batch/restart.bat delete mode 100644 batch/update.bat diff --git a/batch/restart.bat b/batch/restart.bat deleted file mode 100644 index b3327d40..00000000 --- a/batch/restart.bat +++ /dev/null @@ -1,9 +0,0 @@ -@if not "%~0"=="%~dp0.\%~nx0" start /min cmd /c,"%~dp0.\%~nx0" %* & goto :eof - -set name=%1 -set local_path=%~dp0 - -taskkill /im %name% /F -ping -n 2 127.0.0.1 > nul -START "" "%local_path%%name%" -del /f "%~dp0%~nx0" \ No newline at end of file diff --git a/batch/update.bat b/batch/update.bat deleted file mode 100644 index 36087ca3..00000000 --- a/batch/update.bat +++ /dev/null @@ -1,20 +0,0 @@ -@if not "%~0"=="%~dp0.\%~nx0" start /min cmd /c,"%~dp0.\%~nx0" %* & goto :eof - -set exe_name=%1 -set folder_name=%2 -set folder_tmp=%3 -set restart=%4 -set local_path=%~dp0 - -taskkill /im %exe_name% /F -ping -n 2 127.0.0.1 > nul -del /f "%local_path%%exe_name%" -rmdir /s /q "%local_path%%folder_name%" -xcopy "%local_path%%folder_tmp%" "%local_path%" /E /I -rmdir /s /q "%local_path%%folder_tmp%" - -if %restart% == True ( - START "" "%local_path%%exe_name%" -) - -del /f "%~dp0%~nx0" \ No newline at end of file diff --git a/package.json b/package.json index 071b97dc..d3e91e6f 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "type": "module", "scripts": { "setup-python": "install.bat", - "build-python": "pyinstaller -F src-python/webui_mainloop.py --add-data ./fonts;fonts/ --add-data ./batch;batch/ --add-data .venv/Lib/site-packages/zeroconf;zeroconf/ --add-data .venv/Lib/site-packages/openvr;openvr/ --distpath src-tauri/bin --exclude-module pandas --exclude-module matplotlib --exclude-module PyQt5 --clean -n backend-x86_64-pc-windows-msvc", + "build-python": "pyinstaller -F src-python/webui_mainloop.py --add-data ./fonts;fonts/ --add-data .venv/Lib/site-packages/zeroconf;zeroconf/ --add-data .venv/Lib/site-packages/openvr;openvr/ --distpath src-tauri/bin --exclude-module pandas --exclude-module matplotlib --exclude-module PyQt5 --clean -n backend-x86_64-pc-windows-msvc --icon=./src-ui/assets/chato_icon_fill.png", "vite": "vite", "vite-build": "vite build", "vite-preview": "vite preview", From caab8f746b397028798795ee73a4e0f0a1f71e54 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Wed, 28 Aug 2024 11:39:34 +0900 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=91=8D=EF=B8=8F[Update]=20Controller?= =?UTF-8?q?=20:=20=E8=B5=B7=E5=8B=95=E6=99=82=E3=81=AB=E3=83=A2=E3=83=87?= =?UTF-8?q?=E3=83=AB=E3=81=AEweight=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E3=82=92=E3=83=80=E3=82=A6=E3=83=B3=E3=83=AD=E3=83=BC=E3=83=89?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-python/webui_controller.py | 28 +++++++++++++++++++++++++++- src-python/webui_mainloop.py | 14 ++++++++------ 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src-python/webui_controller.py b/src-python/webui_controller.py index 47003ba5..515e4e7d 100644 --- a/src-python/webui_controller.py +++ b/src-python/webui_controller.py @@ -1292,7 +1292,7 @@ def getListInputDevice(*args, **kwargs) -> dict: def getListOutputDevice(*args, **kwargs) -> dict: return {"status":200, "result": model.getListOutputDevice()} -def init(): +def init(endpoints:dict, *args, **kwargs) -> None: print(json.dumps({"status":348, "log": "Start Initialization"}), flush=True) print(json.dumps({"status":348, "log": "Start InitSetTranslateEngine"}), flush=True) initSetTranslateEngine() @@ -1311,6 +1311,19 @@ def init(): print(json.dumps({"status":348, "log": "Set Translation Engine"}), flush=True) updateTranslationEngineAndEngineList() + # check Downloaded CTranslate2 Model Weight + print(json.dumps({"status":348, "log": "Check Downloaded CTranslate2 Model Weight"}), flush=True) + if config.USE_TRANSLATION_FEATURE is True and model.checkCTranslatorCTranslate2ModelWeight() is False: + def callback(progress): + print(json.dumps({ + "endpoint":endpoints["ctranslate2"], + "status":200, + "result":{ + "progress":progress + } + }), flush=True) + model.downloadCTranslate2ModelWeight(callback) + # set Transcription Engine print(json.dumps({"status":348, "log": "Set Transcription Engine"}), flush=True) if config.USE_WHISPER_FEATURE is True: @@ -1318,6 +1331,19 @@ def init(): else: config.SELECTED_TRANSCRIPTION_ENGINE = "Google" + # check Downloaded Whisper Model Weight + print(json.dumps({"status":348, "log": "Check Downloaded Whisper Model Weight"}), flush=True) + if config.USE_WHISPER_FEATURE is True and model.checkTranscriptionWhisperModelWeight() is False: + def callback(progress): + print(json.dumps({ + "endpoint":endpoints["whisper"], + "status":200, + "result":{ + "progress":progress + } + }), flush=True) + model.downloadWhisperModelWeight(callback) + # set word filter print(json.dumps({"status":348, "log": "Set Word Filter"}), flush=True) model.addKeywords() diff --git a/src-python/webui_mainloop.py b/src-python/webui_mainloop.py index 485e5057..a6d73a19 100644 --- a/src-python/webui_mainloop.py +++ b/src-python/webui_mainloop.py @@ -326,14 +326,18 @@ def main(): print(response, flush=True) if __name__ == "__main__": + print(json.dumps({"status":200, "endpoint": "/initialization/start", "result":True}), flush=True) + controller.init({ + "ctranslate2": action_mapping["/controller/callback_download_ctranslate2_weight"]["download"], + "whisper": action_mapping["/controller/callback_download_whisper_weight"]["download"], + }) + print(json.dumps({"status":200, "endpoint": "/initialization/completed", "result":True}), flush=True) + print(json.dumps({"status":348, "log": "Initialization from Python."}), flush=True) + process = "main" match process: case "main": try: - print(json.dumps({"status":200, "endpoint": "/initialization/start", "result":True}), flush=True) - controller.init() - print(json.dumps({"status":200, "endpoint": "/initialization/completed", "result":True}), flush=True) - print(json.dumps({"status":348, "log": "Initialization from Python."}), flush=True) while True: main() except Exception: @@ -342,7 +346,6 @@ if __name__ == "__main__": traceback.print_exc(file=f) case "test": - controller.init() response_data, status = handleControllerRequest("/controller/callback_download_ctranslate2_weight") response = { "status": status, @@ -360,7 +363,6 @@ if __name__ == "__main__": case "test_all": import time - controller.init() for endpoint, value in config_mapping.items(): response_data, status = handleConfigRequest(endpoint) response = { From 652e336d86e03685321ec556d5811cc4d8cbf752 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Thu, 29 Aug 2024 10:37:56 +0900 Subject: [PATCH 3/5] =?UTF-8?q?[Update/WIP]=20=E3=83=A1=E3=83=83=E3=82=BB?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E9=80=81=E4=BF=A1=E3=83=AA=E3=82=AF=E3=82=A8?= =?UTF-8?q?=E3=82=B9=E3=83=88=E6=99=82=E3=81=ABid=E3=82=92=E4=BB=98?= =?UTF-8?q?=E4=B8=8E=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-ui/logics/useMainFunction.js | 8 ------- src-ui/logics/useMessage.js | 36 +++++++++++++++++-------------- src-ui/logics/useReceiveRoutes.js | 7 +++++- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src-ui/logics/useMainFunction.js b/src-ui/logics/useMainFunction.js index cae1c4e6..c91d6785 100644 --- a/src-ui/logics/useMainFunction.js +++ b/src-ui/logics/useMainFunction.js @@ -82,12 +82,4 @@ export const useMainFunction = () => { }, currentForegroundStatus: currentForegroundStatus, }; -}; - -const asyncTestFunction = (...args) => { - return new Promise((resolve) => { - setTimeout(() => { - resolve(...args); - }, 3000); - }); }; \ No newline at end of file diff --git a/src-ui/logics/useMessage.js b/src-ui/logics/useMessage.js index 7522c6cc..5318a896 100644 --- a/src-ui/logics/useMessage.js +++ b/src-ui/logics/useMessage.js @@ -10,8 +10,12 @@ export const useMessage = () => { return { sendMessage: (message) => { - asyncStdoutToPython({id: "send_message", data: message}); const uuid = crypto.randomUUID(); + const send_message_object = { + id: uuid, + message: message, + }; + asyncStdoutToPython("/controller/callback_messagebox_press_key_enter", send_message_object); addMessageLogsStatus({ id: uuid, @@ -20,26 +24,16 @@ export const useMessage = () => { created_at: generateTimeData(), messages: { original: message, - translated: [ - message, - ], + translated: [], }, }); - - setTimeout(() => { - const updateItemById = (id) => (prevItems) => { - return prevItems.map(item => { - if (item.id === id) { - item.status = "ok"; - } - return item; - }); - }; - updateMessageLogsStatus(updateItemById(uuid)); - }, 3000); }, currentMessageLogsStatus: currentMessageLogsStatus, + updateSentMessageLog: (payload) => { + const data = payload.data; + updateMessageLogsStatus(updateItemById(data.id)); + }, addSentMessageLog: (payload) => { const data = payload.data; const message_object = generateMessageObject(data, "sent"); @@ -72,4 +66,14 @@ const generateMessageObject = (data, category) => { translated: [], }, }; +}; + + +const updateItemById = (id) => (prev_items) => { + return prev_items.map(item => { + if (item.id === id) { + item.status = "ok"; + } + return item; + }); }; \ No newline at end of file diff --git a/src-ui/logics/useReceiveRoutes.js b/src-ui/logics/useReceiveRoutes.js index be471b9e..bfd33756 100644 --- a/src-ui/logics/useReceiveRoutes.js +++ b/src-ui/logics/useReceiveRoutes.js @@ -9,7 +9,11 @@ export const useReceiveRoutes = () => { updateTranscriptionReceiveStatus, } = useMainFunction(); - const { addSentMessageLog, addReceivedMessageLog } = useMessage(); + const { + updateSentMessageLog, + addSentMessageLog, + addReceivedMessageLog, + } = useMessage(); const { updateSoftwareVersion, @@ -25,6 +29,7 @@ export const useReceiveRoutes = () => { "/config/version": updateSoftwareVersion, + "/controller/callback_messagebox_press_key_enter": updateSentMessageLog, "/action/transcription_send_mic_message": addSentMessageLog, "/action/transcription_receive_speaker_message": addReceivedMessageLog }; From 090483543bcb735292035841b5fa8d413195b47e Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Fri, 30 Aug 2024 23:46:51 +0900 Subject: [PATCH 4/5] =?UTF-8?q?=F0=9F=9A=A7[WIP/TEST]=20Controller=20:=20?= =?UTF-8?q?=E3=83=81=E3=83=A3=E3=83=83=E3=83=88=E6=99=82=E3=81=ABID?= =?UTF-8?q?=E3=82=92=E4=BB=98=E4=B8=8E=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-python/webui_controller.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src-python/webui_controller.py b/src-python/webui_controller.py index 47003ba5..a8cab2d2 100644 --- a/src-python/webui_controller.py +++ b/src-python/webui_controller.py @@ -303,7 +303,9 @@ class ChatMessage: def __init__(self, action:Callable[[dict], None]) -> None: self.action = action - def send(self, message): + def send(self, data): + id = data["id"] + message = data["message"] if len(message) > 0: addSentMessageLog(message) translation = "" @@ -345,9 +347,9 @@ class ChatMessage: return {"status":200, "result":{ + "id":id, "message":message, "translation":translation, - "clear":config.ENABLE_AUTO_CLEAR_MESSAGE_BOX }, } From bc59cf6089d17fcf8750d6649046728a9177a182 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Sat, 31 Aug 2024 11:04:11 +0900 Subject: [PATCH 5/5] =?UTF-8?q?=F0=9F=9A=A7[WIP/TEST]=20Controller=20:=20s?= =?UTF-8?q?tdio=E3=81=A7=E3=81=AEtauri=E3=81=A8python=E3=81=AE=E9=80=9A?= =?UTF-8?q?=E4=BF=A1=E3=82=92utf8=E3=81=A7=E3=82=A8=E3=83=B3=E3=82=B3?= =?UTF-8?q?=E3=83=BC=E3=83=89/=E3=83=87=E3=82=B3=E3=83=BC=E3=83=89?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-python/webui_controller.py | 19 ++++++++++++++----- src-python/webui_mainloop.py | 3 --- src-ui/logics/useMessage.js | 3 ++- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src-python/webui_controller.py b/src-python/webui_controller.py index a008b18d..6d95a930 100644 --- a/src-python/webui_controller.py +++ b/src-python/webui_controller.py @@ -5,11 +5,17 @@ from subprocess import Popen from threading import Thread from config import config from model import model -# from view import view -from utils import getKeyByValue, isUniqueStrings, strPctToInt -import argparse +from utils import getKeyByValue, isUniqueStrings # 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: def __init__(self, action): self.action = action @@ -305,7 +311,7 @@ class ChatMessage: def send(self, data): id = data["id"] - message = data["message"] + message = decodeUtf8(data["message"]) if len(message) > 0: addSentMessageLog(message) translation = "" @@ -345,6 +351,8 @@ class ChatMessage: translation = f" ({translation})" model.logger.info(f"[SENT] {message}{translation}") + message = encodeUtf8(message) + translation = encodeUtf8(translation) return {"status":200, "result":{ "id":id, @@ -1364,4 +1372,5 @@ def init(endpoints:dict, *args, **kwargs) -> None: print(json.dumps({"status":348, "log": "Init OSC Receive"}), flush=True) model.startReceiveOSC() if config.ENABLE_VRC_MIC_MUTE_SYNC is True: - model.startCheckMuteSelfStatus() \ No newline at end of file + model.startCheckMuteSelfStatus() + print(json.dumps({"status":348, "log": "End Initialization"}), flush=True) \ No newline at end of file diff --git a/src-python/webui_mainloop.py b/src-python/webui_mainloop.py index a6d73a19..b9790f10 100644 --- a/src-python/webui_mainloop.py +++ b/src-python/webui_mainloop.py @@ -326,13 +326,10 @@ def main(): print(response, flush=True) if __name__ == "__main__": - print(json.dumps({"status":200, "endpoint": "/initialization/start", "result":True}), flush=True) controller.init({ "ctranslate2": action_mapping["/controller/callback_download_ctranslate2_weight"]["download"], "whisper": action_mapping["/controller/callback_download_whisper_weight"]["download"], }) - print(json.dumps({"status":200, "endpoint": "/initialization/completed", "result":True}), flush=True) - print(json.dumps({"status":348, "log": "Initialization from Python."}), flush=True) process = "main" match process: diff --git a/src-ui/logics/useMessage.js b/src-ui/logics/useMessage.js index 5318a896..296bd1ed 100644 --- a/src-ui/logics/useMessage.js +++ b/src-ui/logics/useMessage.js @@ -7,13 +7,14 @@ import { useStdoutToPython } from "./useStdoutToPython"; export const useMessage = () => { const { currentMessageLogsStatus, addMessageLogsStatus, updateMessageLogsStatus } = useMessageLogsStatus(); const { asyncStdoutToPython } = useStdoutToPython(); + const encoder = new TextEncoder(); return { sendMessage: (message) => { const uuid = crypto.randomUUID(); const send_message_object = { id: uuid, - message: message, + message: encoder.encode(message), }; asyncStdoutToPython("/controller/callback_messagebox_press_key_enter", send_message_object);