From c18b6842757e1a40f27bd940a810e32f3a0c485c Mon Sep 17 00:00:00 2001 From: yum Date: Fri, 24 Feb 2023 13:31:11 -0800 Subject: Add HTML for BrowserSource Browser source queries /api/transcript at 10Hz via jquery and renders the response. --- BrowserSource/index.html | 28 ++++++++++++++++++++++++++++ GUI/GUI/GUI/BrowserSource.h | 19 ++++++++++++++++--- GUI/GUI/GUI/WhisperCPP.cpp | 1 + GUI/package.ps1 | 1 + 4 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 BrowserSource/index.html diff --git a/BrowserSource/index.html b/BrowserSource/index.html new file mode 100644 index 0000000..decdba2 --- /dev/null +++ b/BrowserSource/index.html @@ -0,0 +1,28 @@ + + + + TaSTT + + + +
+ + + diff --git a/GUI/GUI/GUI/BrowserSource.h b/GUI/GUI/GUI/BrowserSource.h index 0334088..6387d1c 100644 --- a/GUI/GUI/GUI/BrowserSource.h +++ b/GUI/GUI/GUI/BrowserSource.h @@ -17,6 +17,9 @@ #include +#include +#include + #include OATPP_CODEGEN_BEGIN(DTO) class AppDto : public oatpp::DTO @@ -24,7 +27,7 @@ class AppDto : public oatpp::DTO DTO_INIT(AppDto, DTO) DTO_FIELD(Int32, statusCode); - DTO_FIELD(String, message); + DTO_FIELD(String, transcript); }; #include OATPP_CODEGEN_END(DTO) @@ -39,12 +42,21 @@ public: {} public: - ENDPOINT("GET", "/", root) { + ENDPOINT("GET", "/api/transcript", transcription) { auto dto = AppDto::createShared(); dto->statusCode = 200; - dto->message = "Hello World!"; + dto->transcript = "Hello World!"; + return createDtoResponse(Status::CODE_200, dto); } + + ENDPOINT("GET", "/", root) { + auto html_path = std::filesystem::path("Resources/BrowserSource/index.html"); + std::ifstream html_ifs(html_path); + std::vector resp(4096 * 16, 0); + html_ifs.read(resp.data(), resp.size()); + return createResponse(Status::CODE_200, resp.data()); + } }; #include OATPP_CODEGEN_END(ApiController) @@ -60,3 +72,4 @@ private: const uint16_t port_; wxTextCtrl* const out_; }; + diff --git a/GUI/GUI/GUI/WhisperCPP.cpp b/GUI/GUI/GUI/WhisperCPP.cpp index c532123..2e872f9 100644 --- a/GUI/GUI/GUI/WhisperCPP.cpp +++ b/GUI/GUI/GUI/WhisperCPP.cpp @@ -320,6 +320,7 @@ void WhisperCPP::Start(const AppConfig& c) { static const std::vector banned_words{ " [BLANK_AUDIO]", " [SOUND]", + " [ Silence ]", }; const sSegment* const segments = results->getSegments(); diff --git a/GUI/package.ps1 b/GUI/package.ps1 index 7e5d2e9..bac7147 100644 --- a/GUI/package.ps1 +++ b/GUI/package.ps1 @@ -84,6 +84,7 @@ cp -Recurse ../Scripts TaSTT/Resources/Scripts cp -Recurse ../Shaders TaSTT/Resources/Shaders cp -Recurse ../Sounds TaSTT/Resources/Sounds cp -Recurse ../UnityAssets TaSTT/Resources/UnityAssets +cp -Recurse ../BrowserSource TaSTT/Resources/BrowserSource cp GUI/x64/$release/GUI.exe TaSTT/TaSTT.exe cp GUI/GUI/Whisper/Whisper.dll TaSTT/Whisper.dll mkdir TaSTT/Resources/Models -- cgit v1.2.3