From 1c056bf385d2c48f6e4f77da513060c04415252c Mon Sep 17 00:00:00 2001 From: yum Date: Sun, 22 Jan 2023 15:05:54 -0800 Subject: Enable using built-in chatbox VRChat exposes a built-in chatbox which can be seen by anyone who has it enabled. This was not the case when I started this project: the chatbox would only be visible to friends. Since this is clearly useful, enabling the STT on public models, let's enable sending data to it. Caveats: * The built-in chatbox has anti-spam tech which limits us to updating about once every 2 seconds. The custom chatbox has no such limitation and is thus typically much faster. --- GUI/GUI/GUI/Config.cpp | 8 +++++--- GUI/GUI/GUI/Config.h | 1 + GUI/GUI/GUI/Frame.cpp | 13 +++++++++++++ GUI/GUI/GUI/Frame.h | 1 + GUI/GUI/GUI/PythonWrapper.cpp | 1 + 5 files changed, 21 insertions(+), 3 deletions(-) (limited to 'GUI') diff --git a/GUI/GUI/GUI/Config.cpp b/GUI/GUI/GUI/Config.cpp index 9ce498a..4e6eb48 100644 --- a/GUI/GUI/GUI/Config.cpp +++ b/GUI/GUI/GUI/Config.cpp @@ -77,7 +77,8 @@ TranscriptionAppConfig::TranscriptionAppConfig() cols("48"), window_duration("15"), enable_local_beep(true), - use_cpu(false) + use_cpu(false), + use_builtin(false) {} bool TranscriptionAppConfig::Serialize(const std::filesystem::path& path) { @@ -94,8 +95,8 @@ bool TranscriptionAppConfig::Serialize(const std::filesystem::path& path) { root["window_duration"] << ryml::to_substr(window_duration); root["enable_local_beep"] << enable_local_beep; root["use_cpu"] << use_cpu; - - return Config::Serialize(path, &t); + root["use_builtin"] << use_builtin; + return Config::Serialize(path, &t); } bool TranscriptionAppConfig::Deserialize(const std::filesystem::path& path) { @@ -123,6 +124,7 @@ bool TranscriptionAppConfig::Deserialize(const std::filesystem::path& path) { root.get_if("window_duration", &c.window_duration); root.get_if("enable_local_beep", &c.enable_local_beep); root.get_if("use_cpu", &c.use_cpu); + root.get_if("use_builtin", &c.use_builtin); *this = std::move(c); return true; diff --git a/GUI/GUI/GUI/Config.h b/GUI/GUI/GUI/Config.h index 985380b..fe7b862 100644 --- a/GUI/GUI/GUI/Config.h +++ b/GUI/GUI/GUI/Config.h @@ -46,6 +46,7 @@ public: std::string window_duration; bool enable_local_beep; bool use_cpu; + bool use_builtin; }; // Represents the configurable fields for the Unity app. diff --git a/GUI/GUI/GUI/Frame.cpp b/GUI/GUI/GUI/Frame.cpp index f26cbec..f9c7998 100644 --- a/GUI/GUI/GUI/Frame.cpp +++ b/GUI/GUI/GUI/Frame.cpp @@ -35,6 +35,7 @@ namespace { ID_PY_APP_MODEL_PANEL, ID_PY_APP_ENABLE_LOCAL_BEEP, ID_PY_APP_USE_CPU, + ID_PY_APP_USE_BUILTIN, ID_PY_APP_ROWS, ID_PY_APP_COLS, ID_PY_APP_WINDOW_DURATION, @@ -433,6 +434,15 @@ Frame::Frame() ); py_app_use_cpu_ = py_app_use_cpu; + auto* py_app_use_builtin = new wxCheckBox(py_config_panel, + ID_PY_APP_USE_CPU, "Use built-in chatbox"); + py_app_use_builtin->SetValue(py_c.use_builtin); + py_app_use_builtin->SetToolTip( + "If checked, text will be sent to the built-in text box " + "instead of one attached to the current avatar." + ); + py_app_use_builtin_ = py_app_use_builtin; + auto* py_app_start_button = new wxButton(py_config_panel, ID_PY_APP_START_BUTTON, "Begin transcribing"); auto* py_app_stop_button = new wxButton(py_config_panel, ID_PY_APP_STOP_BUTTON, "Stop transcribing"); @@ -443,6 +453,7 @@ Frame::Frame() sizer->Add(py_app_config_panel_pairs, /*proportion=*/0, /*flags=*/wxEXPAND); sizer->Add(py_app_enable_local_beep, /*proportion=*/0, /*flags=*/wxEXPAND); sizer->Add(py_app_use_cpu, /*proportion=*/0, /*flags=*/wxEXPAND); + sizer->Add(py_app_use_builtin, /*proportion=*/0, /*flags=*/wxEXPAND); sizer->Add(py_app_start_button, /*proportion=*/0, /*flags=*/wxEXPAND); sizer->Add(py_app_stop_button, /*proportion=*/0, /*flags=*/wxEXPAND); } @@ -935,6 +946,7 @@ void Frame::OnAppStart(wxCommandEvent& event) { } const bool enable_local_beep = py_app_enable_local_beep_->GetValue(); const bool use_cpu = py_app_use_cpu_->GetValue(); + const bool use_builtin = py_app_use_builtin_->GetValue(); std::string rows_str = py_app_rows_->GetValue().ToStdString(); std::string cols_str = py_app_cols_->GetValue().ToStdString(); std::string window_duration_str = py_app_window_duration_->GetValue().ToStdString(); @@ -978,6 +990,7 @@ void Frame::OnAppStart(wxCommandEvent& event) { py_c.window_duration = std::to_string(window_duration); py_c.enable_local_beep = enable_local_beep; py_c.use_cpu = use_cpu; + py_c.use_builtin = use_builtin; py_c.Serialize(TranscriptionAppConfig::kConfigPath); wxProcess* p = PythonWrapper::StartApp(std::move(cb), py_c); diff --git a/GUI/GUI/GUI/Frame.h b/GUI/GUI/GUI/Frame.h index cd62127..621715b 100644 --- a/GUI/GUI/GUI/Frame.h +++ b/GUI/GUI/GUI/Frame.h @@ -51,6 +51,7 @@ private: wxCheckBox* py_app_enable_local_beep_; wxCheckBox* py_app_use_cpu_; + wxCheckBox* py_app_use_builtin_; wxProcess* py_app_; wxTimer py_app_drain_; diff --git a/GUI/GUI/GUI/PythonWrapper.cpp b/GUI/GUI/GUI/PythonWrapper.cpp index 5581739..f26072a 100644 --- a/GUI/GUI/GUI/PythonWrapper.cpp +++ b/GUI/GUI/GUI/PythonWrapper.cpp @@ -159,6 +159,7 @@ wxProcess* PythonWrapper::StartApp( "--cols", config.cols, "--window_duration_s", config.window_duration, "--cpu", config.use_cpu ? "1" : "0", + "--use_builtin", config.use_builtin ? "1" : "0", }, std::move(exit_callback)); } -- cgit v1.2.3