diff --git a/RealtimeSTT/audio_recorder.py b/RealtimeSTT/audio_recorder.py index e7ff91c..34d534d 100644 --- a/RealtimeSTT/audio_recorder.py +++ b/RealtimeSTT/audio_recorder.py @@ -53,6 +53,7 @@ import os import re import gc +import queue # Set OpenMP runtime duplicate library handling to OK (Use only for development!) os.environ['KMP_DUPLICATE_LIB_OK'] = 'TRUE' @@ -1258,7 +1259,7 @@ def _recording_worker(self): try: - data = self.audio_queue.get() + data = self.audio_queue.get(True, 1) if self.on_recorded_chunk: self.on_recorded_chunk(data) @@ -1275,8 +1276,11 @@ def _recording_worker(self): while (self.audio_queue.qsize() > self.allowed_latency_limit): - data = self.audio_queue.get() + data = self.audio_queue.get(True, 1) + except queue.Empty: + continue + except BrokenPipeError: print("BrokenPipeError _recording_worker") self.is_running = False