Closed Pop-Vlad closed 2 weeks ago
Here's what you can do in the meantime:
from whisper_mic import WhisperMic, get_logger
class CustomMic(WhisperMic):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def listen(self, timeout=None, phrase_time_limit=None):
self.logger.info("Listening...")
while self.result_queue.empty():
self._WhisperMic__listen_handler(timeout, phrase_time_limit)
while True:
if not self.result_queue.empty():
return self.result_queue.get()
def record(self, duration=None, offset=None):
self.logger.info("Listening...")
while self.result_queue.empty():
self._WhisperMic__record_handler(duration, offset)
while True:
if not self.result_queue.empty():
return self.result_queue.get()
And use that custom class instead
Running the followig code results in the process getting stuck when not speaking loud enough:
The issue seems to come from the function __transcribe, where self.result_queue is filled only when is_audio_loud_enough is true:
As a result, the functions listen and record get stuck in the following loop, because self.result_queue is always empty: