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", diff --git a/src-python/webui_controller.py b/src-python/webui_controller.py index a8cab2d2..a008b18d 100644 --- a/src-python/webui_controller.py +++ b/src-python/webui_controller.py @@ -1294,7 +1294,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() @@ -1313,6 +1313,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: @@ -1320,6 +1333,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 = {