diff options
| author | yum <yum.food.vr@gmail.com> | 2022-11-01 18:46:12 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2022-11-01 18:46:12 -0700 |
| commit | d0120a858c2fd76bf5b5271ba5275e50565f109d (patch) | |
| tree | 03c5f87ce9a718b0915bf9628bef73081a35fe29 | |
| parent | 0357119769154dbbfa77d317e6b575c9c337584f (diff) | |
Fix bug where some text would show up after saying 'Clear'
| -rw-r--r-- | osc_ctrl.py | 2 | ||||
| -rw-r--r-- | transcribe.py | 11 |
2 files changed, 7 insertions, 6 deletions
diff --git a/osc_ctrl.py b/osc_ctrl.py index 4c243f0..4f888c3 100644 --- a/osc_ctrl.py +++ b/osc_ctrl.py @@ -180,7 +180,7 @@ class OscTxState: # The message last sent to the board. last_msg_encoded = [] empty_cells_to_send_per_call = 1 - nonempty_cells_to_send_per_call = 2 + nonempty_cells_to_send_per_call = 1 # 0 indicates it's closed. 1 indicates half size. 2 indicates full size. board_size = 0 diff --git a/transcribe.py b/transcribe.py index 7cf4170..4400999 100644 --- a/transcribe.py +++ b/transcribe.py @@ -161,6 +161,10 @@ def resetAudioLocked(audio_state): resetDiskAudioLocked(audio_state, audio_state.VOICE_AUDIO_FILENAME) + audio_state.text = "" + audio_state.text_candidate = "" + osc_ctrl.clear(audio_state.osc_client) + def resetAudio(audio_state): audio_state.frames_lock.acquire() resetAudioLocked(audio_state) @@ -218,9 +222,6 @@ def transcribeAudio(audio_state, model): if len(words) > 0: if words[-1] == "clear": resetAudio(audio_state) - osc_ctrl.clear(audio_state.osc_client) - audio_state.text = "" - audio_state.text_candidate = "" audio_state.text_lock.release() audio_state.display_paused = False continue @@ -259,6 +260,7 @@ def transcribeAudio(audio_state, model): old_text = audio_state.text old_words = audio_state.text.split() new_words = text.split() + audio_state.text = string_matcher.matchStringList(old_words, new_words) if old_text != audio_state.text: # We think the user said something, so reset the amount of @@ -280,9 +282,8 @@ def sendAudio(audio_state): audio_state.text_lock.acquire() text = copy.deepcopy(audio_state.text) - audio_state.text_lock.release() - osc_ctrl.sendMessageLazy(audio_state.osc_client, text, tx_state) + audio_state.text_lock.release() # Pace this out time.sleep(0.01) |
