From ff7eb3c212195af71cd0ce4a3cd0c9a081d6ebda Mon Sep 17 00:00:00 2001 From: yum Date: Wed, 28 Jun 2023 20:35:10 -0700 Subject: Add toggle for debug mode Most transcription output is now gone by default. Users can enable a more verbose output by toggling `Enable debug mode`. Bugfix: Toggling off transcription would reset audio state, frequently resulting in the loss of the last few words spoken. --- GUI/GUI/GUI/Config.cpp | 3 +++ GUI/GUI/GUI/Config.h | 1 + GUI/GUI/GUI/Frame.cpp | 18 ++++++++++++++++++ GUI/GUI/GUI/Frame.h | 1 + GUI/GUI/GUI/PythonWrapper.cpp | 1 + 5 files changed, 24 insertions(+) (limited to 'GUI') diff --git a/GUI/GUI/GUI/Config.cpp b/GUI/GUI/GUI/Config.cpp index 4f730b5..d337f77 100644 --- a/GUI/GUI/GUI/Config.cpp +++ b/GUI/GUI/GUI/Config.cpp @@ -79,6 +79,7 @@ AppConfig::AppConfig(wxTextCtrl* out) remove_trailing_period(false), enable_uppercase_filter(false), enable_lowercase_filter(false), + enable_debug_mode(false), reset_on_toggle(true), gpu_idx(0), keybind("ctrl+x"), @@ -131,6 +132,7 @@ bool AppConfig::Serialize(const std::filesystem::path& path) { cm.Set("remove_trailing_period", remove_trailing_period); cm.Set("enable_uppercase_filter", enable_uppercase_filter); cm.Set("enable_lowercase_filter", enable_lowercase_filter); + cm.Set("enable_debug_mode", enable_debug_mode); cm.Set("reset_on_toggle", reset_on_toggle); cm.Set("gpu_idx", gpu_idx); cm.Set("keybind", keybind); @@ -196,6 +198,7 @@ bool AppConfig::Deserialize(const std::filesystem::path& path) { cm.Get("remove_trailing_period", c.remove_trailing_period); cm.Get("enable_uppercase_filter", c.enable_uppercase_filter); cm.Get("enable_lowercase_filter", c.enable_lowercase_filter); + cm.Get("enable_debug_mode", c.enable_debug_mode); cm.Get("reset_on_toggle", c.reset_on_toggle); cm.Get("gpu_idx", c.gpu_idx); cm.Get("keybind", c.keybind); diff --git a/GUI/GUI/GUI/Config.h b/GUI/GUI/GUI/Config.h index 6711d79..e4a9bf4 100644 --- a/GUI/GUI/GUI/Config.h +++ b/GUI/GUI/GUI/Config.h @@ -65,6 +65,7 @@ public: bool remove_trailing_period; bool enable_uppercase_filter; bool enable_lowercase_filter; + bool enable_debug_mode; bool reset_on_toggle; int gpu_idx; std::string keybind; diff --git a/GUI/GUI/GUI/Frame.cpp b/GUI/GUI/GUI/Frame.cpp index 1df60e7..706165b 100644 --- a/GUI/GUI/GUI/Frame.cpp +++ b/GUI/GUI/GUI/Frame.cpp @@ -47,6 +47,7 @@ namespace { ID_PY_APP_REMOVE_TRAILING_PERIOD, ID_PY_APP_ENABLE_UPPERCASE_FILTER, ID_PY_APP_ENABLE_LOWERCASE_FILTER, + ID_PY_APP_ENABLE_DEBUG_MODE, ID_PY_APP_RESET_ON_TOGGLE, ID_PY_APP_ROWS, ID_PY_APP_COLS, @@ -881,6 +882,16 @@ Frame::Frame() ); py_app_enable_lowercase_filter_ = py_app_enable_lowercase_filter; + auto* py_app_enable_debug_mode = new wxCheckBox(py_config_panel, + ID_PY_APP_ENABLE_DEBUG_MODE, "Enable debug mode"); + py_app_enable_debug_mode->SetValue(app_c_->enable_debug_mode); + py_app_enable_debug_mode->SetToolTip( + "If checked, the transcription engine will print out " + "additional information. Use this if you're debugging a " + "technical issue." + ); + py_app_enable_debug_mode_ = py_app_enable_debug_mode; + auto* py_app_reset_on_toggle = new wxCheckBox(py_config_panel, ID_PY_APP_RESET_ON_TOGGLE, "Reset transcript on toggle"); py_app_reset_on_toggle->SetValue(app_c_->reset_on_toggle); @@ -922,6 +933,8 @@ Frame::Frame() /*flags=*/wxEXPAND); sizer->Add(py_app_enable_lowercase_filter, /*proportion=*/0, /*flags=*/wxEXPAND); + sizer->Add(py_app_enable_debug_mode, /*proportion=*/0, + /*flags=*/wxEXPAND); sizer->Add(py_app_start_button, /*proportion=*/0, /*flags=*/wxEXPAND); sizer->Add(py_app_stop_button, /*proportion=*/0, @@ -1440,6 +1453,9 @@ void Frame::ApplyConfigToInputFields() auto* py_app_enable_lowercase_filter = static_cast(FindWindowById(ID_PY_APP_ENABLE_LOWERCASE_FILTER)); py_app_enable_lowercase_filter->SetValue(app_c_->enable_lowercase_filter); + auto* py_app_enable_debug_mode = static_cast(FindWindowById(ID_PY_APP_ENABLE_DEBUG_MODE)); + py_app_enable_debug_mode->SetValue(app_c_->enable_debug_mode); + auto* py_app_reset_on_toggle = static_cast(FindWindowById(ID_PY_APP_RESET_ON_TOGGLE)); py_app_reset_on_toggle->SetValue(app_c_->reset_on_toggle); @@ -2028,6 +2044,7 @@ void Frame::OnAppStart(wxCommandEvent& event) { const bool remove_trailing_period = py_app_remove_trailing_period_->GetValue(); const bool enable_uppercase_filter = py_app_enable_uppercase_filter_->GetValue(); const bool enable_lowercase_filter = py_app_enable_lowercase_filter_->GetValue(); + const bool enable_debug_mode = py_app_enable_debug_mode_->GetValue(); const bool reset_on_toggle = py_app_reset_on_toggle_->GetValue(); std::string rows_str = py_app_rows_->GetValue().ToStdString(); std::string cols_str = py_app_cols_->GetValue().ToStdString(); @@ -2126,6 +2143,7 @@ void Frame::OnAppStart(wxCommandEvent& event) { app_c_->remove_trailing_period = remove_trailing_period; app_c_->enable_uppercase_filter = enable_uppercase_filter; app_c_->enable_lowercase_filter = enable_lowercase_filter; + app_c_->enable_debug_mode = enable_debug_mode; app_c_->reset_on_toggle = reset_on_toggle; app_c_->gpu_idx = gpu_idx; app_c_->keybind = keybind; diff --git a/GUI/GUI/GUI/Frame.h b/GUI/GUI/GUI/Frame.h index 7afc005..46f5bcd 100644 --- a/GUI/GUI/GUI/Frame.h +++ b/GUI/GUI/GUI/Frame.h @@ -69,6 +69,7 @@ private: wxCheckBox* py_app_remove_trailing_period_; wxCheckBox* py_app_enable_uppercase_filter_; wxCheckBox* py_app_enable_lowercase_filter_; + wxCheckBox* py_app_enable_debug_mode_; wxCheckBox* py_app_reset_on_toggle_; wxCheckBox* unity_clear_osc_; diff --git a/GUI/GUI/GUI/PythonWrapper.cpp b/GUI/GUI/GUI/PythonWrapper.cpp index e6f10c2..c5421e8 100644 --- a/GUI/GUI/GUI/PythonWrapper.cpp +++ b/GUI/GUI/GUI/PythonWrapper.cpp @@ -493,6 +493,7 @@ std::future PythonWrapper::StartApp( "--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_debug_mode", config.enable_debug_mode ? "1" : "0", "--emotes_pickle", kEmotesPickle, "--gpu_idx", std::to_string(config.gpu_idx), "--keybind", Quote(config.keybind), -- cgit v1.2.3