From 45f983b2f2670a79cbb83d2c8944d922015291be Mon Sep 17 00:00:00 2001 From: yum Date: Thu, 31 Aug 2023 23:06:33 -0700 Subject: transcribe.py now just reads from config file Duplicating config between args and config is a huge pain in the ass to maintain. Now we just launch using the config generated by the UI. ezpz. --- GUI/GUI/GUI/Frame.cpp | 4 +++- GUI/GUI/GUI/PythonWrapper.cpp | 41 +++++++++++------------------------------ GUI/GUI/GUI/PythonWrapper.h | 2 +- 3 files changed, 15 insertions(+), 32 deletions(-) (limited to 'GUI') diff --git a/GUI/GUI/GUI/Frame.cpp b/GUI/GUI/GUI/Frame.cpp index bc8e3ee..5416abe 100644 --- a/GUI/GUI/GUI/Frame.cpp +++ b/GUI/GUI/GUI/Frame.cpp @@ -2285,7 +2285,9 @@ void Frame::OnAppStart(wxCommandEvent& event) { } return true; }); - py_app_ = std::move(PythonWrapper::StartApp(*app_c_, transcribe_out_, + Log(transcribe_out_, "DEBUG::{}:: AppConfig::kConfigPath: {}\n", __func__, AppConfig::kConfigPath); + const std::string config_path(AppConfig::kConfigPath); + py_app_ = std::move(PythonWrapper::StartApp(config_path, transcribe_out_, std::move(out_cb), std::move(in_cb), std::move(run_cb), std::move(prestart_cb))); Log(transcribe_out_, "py app valid: {}\n", py_app_.valid()); diff --git a/GUI/GUI/GUI/PythonWrapper.cpp b/GUI/GUI/GUI/PythonWrapper.cpp index 71df5c5..a855b4c 100644 --- a/GUI/GUI/GUI/PythonWrapper.cpp +++ b/GUI/GUI/GUI/PythonWrapper.cpp @@ -459,7 +459,7 @@ bool PythonWrapper::InstallPip( } std::future PythonWrapper::StartApp( - const AppConfig& config, + const std::string& config_path, wxTextCtrl *out, const std::function&& out_cb, const std::function&& in_cb, @@ -467,46 +467,27 @@ std::future PythonWrapper::StartApp( const std::function&& prestart_cb) { return std::move(std::async(std::launch::async, - [&]( + []( + const std::string config_path, + wxTextCtrl *out, const std::function&& out_cb, const std::function&& in_cb, - const std::function&& run_cb) -> bool { + const std::function&& run_cb, + const std::function&& prestart_cb) -> bool { prestart_cb(); + Log(out, "DEBUG::{}:: config_path: {}\n", __func__, config_path); + return InvokeWithArgs({ "-u", // Unbuffered output "Resources/Scripts/transcribe.py", - "--mic", config.microphone, - "--language", config.language, - "--language_target", Quote(config.language_target), - "--model", config.model, - "--model_translation", config.model_translation, - "--chars_per_sync", std::to_string(config.chars_per_sync), - "--bytes_per_char", std::to_string(config.bytes_per_char), - "--button", Quote(config.button), - "--enable_local_beep", config.enable_local_beep ? "1" : "0", - "--rows", std::to_string(config.rows), - "--cols", std::to_string(config.cols), - // this is the max length of the audio buffer. 5 minutes - // is a reasonable approximation of infinity. - "--window_duration_s", "300", - "--cpu", config.use_cpu ? "1" : "0", - "--use_builtin", config.use_builtin ? "1" : "0", - "--enable_uwu_filter", config.enable_uwu_filter ? "1" : "0", - "--remove_trailing_period", config.remove_trailing_period ? "1" : "0", - "--enable_uppercase_filter", config.enable_uppercase_filter ? "1" : "0", - "--enable_lowercase_filter", config.enable_lowercase_filter ? "1" : "0", - "--enable_profanity_filter", config.enable_profanity_filter ? "1" : "0", - "--enable_debug_mode", config.enable_debug_mode ? "1" : "0", - "--emotes_pickle", kEmotesPickle, - "--gpu_idx", std::to_string(config.gpu_idx), - "--keybind", Quote(config.keybind), - "--reset_on_toggle", config.reset_on_toggle ? "1" : "0", + "--config", config_path, }, std::move(out_cb), std::move(in_cb), std::move(run_cb)); - }, std::move(out_cb), std::move(in_cb), std::move(run_cb))); + }, config_path, out, std::move(out_cb), std::move(in_cb), + std::move(run_cb), std::move(prestart_cb))); } bool PythonWrapper::GenerateAnimator( diff --git a/GUI/GUI/GUI/PythonWrapper.h b/GUI/GUI/GUI/PythonWrapper.h index 6366247..477224d 100644 --- a/GUI/GUI/GUI/PythonWrapper.h +++ b/GUI/GUI/GUI/PythonWrapper.h @@ -72,7 +72,7 @@ namespace PythonWrapper // parameters. We could persist those files so settings would persist across // app restarts. std::future StartApp( - const AppConfig& config, + const std::string& config_path, wxTextCtrl *out, const std::function&& out_cb, const std::function&& in_cb = [](std::string&) {}, -- cgit v1.2.3