diff options
Diffstat (limited to 'Scripts')
| -rw-r--r-- | Scripts/string_matcher.py | 10 | ||||
| -rw-r--r-- | Scripts/transcribe.py | 13 |
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: |
