summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--GUI/GUI/GUI/Config.cpp2
-rw-r--r--GUI/GUI/GUI/PythonWrapper.cpp61
-rw-r--r--Scripts/transcribe.py6
3 files changed, 5 insertions, 64 deletions
diff --git a/GUI/GUI/GUI/Config.cpp b/GUI/GUI/GUI/Config.cpp
index f35f95c..f45aa45 100644
--- a/GUI/GUI/GUI/Config.cpp
+++ b/GUI/GUI/GUI/Config.cpp
@@ -66,7 +66,7 @@ AppConfig::AppConfig(wxTextCtrl* out)
language("english"),
model("base.en"),
button("left joystick"),
- window_duration("120"),
+ window_duration("15"),
enable_local_beep(true),
use_cpu(false),
diff --git a/GUI/GUI/GUI/PythonWrapper.cpp b/GUI/GUI/GUI/PythonWrapper.cpp
index 3a7cc5d..e6b9a70 100644
--- a/GUI/GUI/GUI/PythonWrapper.cpp
+++ b/GUI/GUI/GUI/PythonWrapper.cpp
@@ -98,64 +98,6 @@ std::string DrainWin32Pipe(const HANDLE pipe) {
return oss.str();
}
-bool SetAffinityMask(
- HANDLE hProcess,
- const std::function<void(const std::string& out, const std::string& err)> out_cb)
-{
- // Set process affinity mask. This is an simple optimization pointed out by
- // a user. Constraining any of the processes used by the STT to a reduced
- // number of processors does not affect user-visible performance.
- {
- // Query processor information.
- SYSTEM_INFO sysinfo{};
- GetSystemInfo(&sysinfo);
- //sysinfo.dwNumberOfProcessors
-
- // Pick a random processor.
- unsigned int rand_num;
- auto err = rand_s(&rand_num);
- if (err) {
- std::ostringstream err_oss;
- err_oss << "Failed to get random number: " << err << std::endl;
- out_cb("", err_oss.str());
- return false;
- }
- // Constrain the processor ID to [1, num_processors).
- // We don't want to run on processor 0 since it receives system interrupts
- int processor_id = rand_num;
- switch (sysinfo.dwNumberOfProcessors) {
- // case 0 can never happen.
- case 1:
- processor_id = 0;
- case 2:
- processor_id = rand_num % 2;
- default:
- processor_id = (processor_id % (sysinfo.dwNumberOfProcessors - 1)) + 1;
- }
- DWORD_PTR affinity_mask = 0;
- processor_id = std::min(processor_id,
- static_cast<int>(sizeof(affinity_mask)));
- affinity_mask = 1LL << processor_id;
-
- if (!SetProcessAffinityMask(hProcess, affinity_mask)) {
- std::ostringstream err_oss;
- err_oss << "Failed to set affinity mask: " << GetWin32ErrMsg();
- out_cb("", err_oss.str());
- return false;
- }
-
-#if 0
- {
- std::ostringstream oss;
- oss << "Set affinity mask to " << affinity_mask <<
- ", i.e. processor " << processor_id << std::endl;
- out_cb(oss.str(), "");
- }
-#endif
- }
- return true;
-}
-
bool PythonWrapper::InvokeCommandWithArgs(const std::string& cmd,
std::vector<std::string>&& args,
const std::function<void(const std::string& out, const std::string& err)>&& out_cb,
@@ -339,9 +281,6 @@ bool PythonWrapper::InvokeCommandWithArgs(const std::string& cmd,
CloseHandle(pi.hThread);
});
- // Set affinity mask (best effort)
- SetAffinityMask(pi.hProcess, out_cb);
-
// While the process is running, drain output and send input every 10 ms.
DWORD timeout_ms = 10;
DWORD ret = WAIT_TIMEOUT;
diff --git a/Scripts/transcribe.py b/Scripts/transcribe.py
index 4d3169f..043ca0c 100644
--- a/Scripts/transcribe.py
+++ b/Scripts/transcribe.py
@@ -15,6 +15,7 @@ import langcodes
import pyaudio
import numpy as np
import steamvr
+import string_matcher
import sys
import threading
import time
@@ -249,8 +250,9 @@ def transcribeAudio(audio_state, model, use_cpu: bool):
last_transcribe_time = time.time()
continue
- old_text = copy.copy(audio_state.text)
- audio_state.text = text
+ old_text = audio_state.text
+ audio_state.text = string_matcher.matchStrings(audio_state.text,
+ text, window_size = 25);
now = time.time()
print("Transcription ({} seconds): {}".format(