summaryrefslogtreecommitdiffstats
path: root/Scripts
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2023-01-04 09:52:02 -0800
committeryum <yum.food.vr@gmail.com>2023-01-04 10:03:39 -0800
commit66d311b3267620995e5c35b16f3fba18ed0c48f3 (patch)
tree88411e37c442d66cc34e3f6f22683ce2976a5743 /Scripts
parent6bed3a15edf134fa176ca4866b4346017bc97ada (diff)
Bugfix: user-provided paths may now contain spaces
Previously, paths containing spaces would be interpreted by python's argument parser as multiple separate arguments, causing it to fail. Now we escape paths inside PythonWrapper using std::quoted(). * Improve PII filtering. Python output would contain multiple path separators (like C:\\Users\\foo\\), defeating the PII regex. * Silence compiler warning in PII filter. * Document usability improvements. * Transcription layer exponential backoff goes to ~infinity when paused. This is a hack, since we really don't need to transcribe at all when paused, but it lets us keep the code simple. Good enough until the next rewrite. * Shader only samples background when necessary. * Limit matchStrings() print()s to DEBUG mode
Diffstat (limited to 'Scripts')
-rw-r--r--Scripts/string_matcher.py10
-rw-r--r--Scripts/transcribe.py13
2 files changed, 15 insertions, 8 deletions
diff --git a/Scripts/string_matcher.py b/Scripts/string_matcher.py
index 686056c..26241f2 100644
--- a/Scripts/string_matcher.py
+++ b/Scripts/string_matcher.py
@@ -52,7 +52,8 @@ def matchSpaceDelimitedStrings(old_text: str, new_text: str, window_size = 4) ->
def matchStrings(old_text: str, new_text: str, window_size = 3) -> str:
if old_text == new_text:
- print("STRING MATCH exception path 1")
+ if DEBUG:
+ print("STRING MATCH exception path 1")
return old_text
elif len(old_text) >= window_size and len(new_text) >= window_size:
# Find the window where the cumulative string distance
@@ -105,9 +106,10 @@ def matchStrings(old_text: str, new_text: str, window_size = 3) -> str:
new_text[best_match_j:]))
return old_prefix + new_text[best_match_j:]
else:
- print("STRING MATCH exception path 2")
- print(" OLD: {}".format(old_text))
- print(" NEW: {}".format(new_text))
+ if DEBUG:
+ print("STRING MATCH exception path 2")
+ print(" OLD: {}".format(old_text))
+ print(" NEW: {}".format(new_text))
return new_text
if __name__ == "__main__":
diff --git a/Scripts/transcribe.py b/Scripts/transcribe.py
index 4d36e53..7f07efe 100644
--- a/Scripts/transcribe.py
+++ b/Scripts/transcribe.py
@@ -88,7 +88,7 @@ class AudioState:
def sleepInterruptible(self, dur_s, stride_ms = 5):
dur_ms = dur_s * 1000.0
timeout = time.time() + dur_s
- while self.audio_paused and time.time() < timeout:
+ while self.audio_paused and self.run_app and time.time() < timeout:
time.sleep(stride_ms / 1000.0)
def dumpMicDevices():
@@ -263,9 +263,14 @@ def transcribeAudio(audio_state, model, use_cpu: bool):
audio_state.transcribe_no_change_count += 1
longer_sleep_dur = audio_state.transcribe_sleep_duration
longer_sleep_dur += audio_state.transcribe_sleep_duration_min_s * (1.3**audio_state.transcribe_no_change_count)
- audio_state.transcribe_sleep_duration = min(
- audio_state.transcribe_sleep_duration_max_s,
- longer_sleep_dur)
+ if audio_state.audio_paused:
+ audio_state.transcribe_sleep_duration = min(
+ 1000 * 1000,
+ longer_sleep_dur)
+ else:
+ audio_state.transcribe_sleep_duration = min(
+ audio_state.transcribe_sleep_duration_max_s,
+ longer_sleep_dur)
text = transcribe(audio_state, model, audio_state.frames, use_cpu)
if not text: