From 59a1d34285548ca673fe551df36a71f3f8421418 Mon Sep 17 00:00:00 2001 From: yum Date: Sat, 9 Sep 2023 20:02:17 -0700 Subject: Make min silence duration configurable in UI --- GUI/GUI/GUI/Config.cpp | 3 +++ GUI/GUI/GUI/Config.h | 1 + GUI/GUI/GUI/Frame.cpp | 21 +++++++++++++++++++++ GUI/GUI/GUI/Frame.h | 1 + 4 files changed, 26 insertions(+) (limited to 'GUI') diff --git a/GUI/GUI/GUI/Config.cpp b/GUI/GUI/GUI/Config.cpp index 8d5cdbf..1fc1aee 100644 --- a/GUI/GUI/GUI/Config.cpp +++ b/GUI/GUI/GUI/Config.cpp @@ -85,6 +85,7 @@ AppConfig::AppConfig(wxTextCtrl* out) enable_previews(true), enable_lock_at_spawn(true), gpu_idx(0), + min_silence_duration_ms(250), keybind("ctrl+x"), chars_per_sync(8), @@ -127,6 +128,7 @@ bool AppConfig::Serialize(const std::filesystem::path& path) { cm.Set("enable_previews", enable_previews); cm.Set("enable_lock_at_spawn", enable_lock_at_spawn); cm.Set("gpu_idx", gpu_idx); + cm.Set("min_silence_duration_ms", min_silence_duration_ms); cm.Set("keybind", keybind); cm.Set("chars_per_sync", chars_per_sync); @@ -182,6 +184,7 @@ bool AppConfig::Deserialize(const std::filesystem::path& path) { cm.Get("enable_previews", c.enable_previews); cm.Get("enable_lock_at_spawn", c.enable_lock_at_spawn); cm.Get("gpu_idx", c.gpu_idx); + cm.Get("min_silence_duration_ms", c.min_silence_duration_ms); cm.Get("keybind", c.keybind); cm.Get("chars_per_sync", c.chars_per_sync); diff --git a/GUI/GUI/GUI/Config.h b/GUI/GUI/GUI/Config.h index 6e82f14..808cf9e 100644 --- a/GUI/GUI/GUI/Config.h +++ b/GUI/GUI/GUI/Config.h @@ -71,6 +71,7 @@ public: bool enable_previews; bool enable_lock_at_spawn; int gpu_idx; + int min_silence_duration_ms; std::string keybind; // Unity and transcription shared settings. diff --git a/GUI/GUI/GUI/Frame.cpp b/GUI/GUI/GUI/Frame.cpp index a124ff1..d110a0c 100644 --- a/GUI/GUI/GUI/Frame.cpp +++ b/GUI/GUI/GUI/Frame.cpp @@ -75,6 +75,7 @@ namespace { ID_PY_APP_ROWS, ID_PY_APP_COLS, ID_PY_APP_GPU_IDX, + ID_PY_APP_MIN_SILENCE_DURATION_MS, ID_PY_APP_KEYBIND, ID_PY_APP_BROWSER_SRC_PORT, ID_PY_APP_COMMIT_FUZZ_THRESHOLD, @@ -753,6 +754,15 @@ Frame::Frame() "discrete GPU."); py_app_gpu_idx_ = py_app_gpu_idx; + auto* py_app_min_silence_duration_ms = new wxTextCtrl( + py_app_config_panel_pairs, ID_PY_APP_MIN_SILENCE_DURATION_MS, + std::to_string(app_c_->min_silence_duration_ms), wxDefaultPosition, + wxDefaultSize, /*style=*/0); + py_app_min_silence_duration_ms->SetToolTip( + "The minimum duration, in milliseconds, of a silence " + "used to segment speech."); + py_app_min_silence_duration_ms_ = py_app_min_silence_duration_ms; + auto* py_app_keybind = new wxTextCtrl( py_app_config_panel_pairs, ID_PY_APP_KEYBIND, app_c_->keybind, wxDefaultPosition, @@ -837,6 +847,11 @@ Frame::Frame() sizer->Add(py_app_gpu_idx, /*proportion=*/0, /*flags=*/wxEXPAND); + sizer->Add(new wxStaticText(py_app_config_panel_pairs, + wxID_ANY, /*label=*/"Minimum silence duration (ms):")); + sizer->Add(py_app_min_silence_duration_ms, /*proportion=*/0, + /*flags=*/wxEXPAND); + sizer->Add(new wxStaticText(py_app_config_panel_pairs, wxID_ANY, /*label=*/"Browser source port:")); sizer->Add(py_app_browser_src_port, /*proportion=*/0, @@ -1531,6 +1546,10 @@ void Frame::ApplyConfigToInputFields() py_app_gpu_idx->Clear(); py_app_gpu_idx->AppendText(std::to_string(app_c_->gpu_idx)); + auto* py_app_min_silence_duration_ms = static_cast(FindWindowById(ID_PY_APP_MIN_SILENCE_DURATION_MS)); + py_app_min_silence_duration_ms->Clear(); + py_app_min_silence_duration_ms->AppendText(std::to_string(app_c_->min_silence_duration_ms)); + auto* py_app_enable_local_beep = static_cast(FindWindowById(ID_PY_APP_ENABLE_LOCAL_BEEP)); py_app_enable_local_beep->SetValue(app_c_->enable_local_beep); @@ -2284,6 +2303,7 @@ void Frame::OnAppStart(wxCommandEvent& event) { ASSIGN_OR_RETURN_VOID(int, chars_per_sync, stoiInRange(transcribe_out_, kCharsPerSync[chars_per_sync_idx].ToStdString(), "chars_per_sync", 5, 24)); ASSIGN_OR_RETURN_VOID(int, bytes_per_char, stoiInRange(transcribe_out_, kBytesPerChar[bytes_per_char_idx].ToStdString(), "bytes_per_char", 1, 2)); ASSIGN_OR_RETURN_VOID(int, gpu_idx, stoiInRange(transcribe_out_, py_app_gpu_idx_->GetValue().ToStdString(), "gpu_idx", 0, 10)); + ASSIGN_OR_RETURN_VOID(int, min_silence_duration_ms, stoiInRange(transcribe_out_, py_app_min_silence_duration_ms_->GetValue().ToStdString(), "min_silence_duration_ms", 50, 5000)); ASSIGN_OR_RETURN_VOID(int, browser_src_port, stoiInRange(transcribe_out_, py_app_browser_src_port_->GetValue().ToStdString(), "browser_src_port", 1024, 65535)); std::string keybind = py_app_keybind_->GetValue().ToStdString(); @@ -2313,6 +2333,7 @@ void Frame::OnAppStart(wxCommandEvent& event) { app_c_->enable_previews = enable_previews; app_c_->enable_lock_at_spawn = enable_lock_at_spawn; app_c_->gpu_idx = gpu_idx; + app_c_->min_silence_duration_ms = min_silence_duration_ms; app_c_->keybind = keybind; app_c_->Serialize(AppConfig::kConfigPath); diff --git a/GUI/GUI/GUI/Frame.h b/GUI/GUI/GUI/Frame.h index d33db06..72ba6c4 100644 --- a/GUI/GUI/GUI/Frame.h +++ b/GUI/GUI/GUI/Frame.h @@ -38,6 +38,7 @@ private: wxTextCtrl* py_app_rows_; wxTextCtrl* py_app_cols_; wxTextCtrl* py_app_gpu_idx_; + wxTextCtrl* py_app_min_silence_duration_ms_; wxTextCtrl* py_app_keybind_; wxTextCtrl* py_app_browser_src_port_; wxTextCtrl* py_app_commit_fuzz_threshold_; -- cgit v1.2.3