Skip to content

Commit

Permalink
Avoid waiting state when data are present. Reduce size of chunks from…
Browse files Browse the repository at this point in the history
… recorder to 1024.

This improves responsiveness  and allows to have smaller chunks from recorder
  • Loading branch information
Papoteur committed Oct 24, 2021
1 parent 9c2c183 commit d7469cb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nerd-dictation
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def file_remove_if_exists(filepath: str) -> bool:


def enqueue_output(vosk_out, queue):
for block in iter(partial(vosk_out.read, 16384), b""):
for block in iter(partial(vosk_out.read, 1024), b""):
queue.put(block)


Expand Down Expand Up @@ -649,7 +649,7 @@ def text_from_vosk_pipe(
# Skip idling in the event dictation can't keep up with the recording.
idle_time_curr = time.time()
idle_time_test = idle_time - (idle_time_curr - idle_time_prev)
if idle_time_test > 0.0:
if vosk_queue.empty() and idle_time_test > 0.0:
# Prevents excessive processor load.
time.sleep(idle_time_test)
idle_time_prev = time.time()
Expand Down

0 comments on commit d7469cb

Please sign in to comment.