Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes infinite loop when mic input is too quiet #76

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

FontaineRiant
Copy link

see issue #67

@mallorbc
Copy link
Owner

mallorbc commented May 15, 2024

Thanks for the PR.

Looking at the existing code, the issue, and your PR, the current code is definitely an issue, but I am not sure if this is the appropriate solution. I think code like how the listen handler may be better, where it errors out under some circumstances. This fix would be under the record handler. I still need to actually test this though, your solution may be best

def __listen_handler(self, timeout, phrase_time_limit):
try:
with self.source as microphone:
audio = self.recorder.listen(source=microphone, timeout=timeout, phrase_time_limit=phrase_time_limit)
self.__record_load(0, audio)
audio_data = self.__get_all_audio()
self.__transcribe(data=audio_data)
except sr.WaitTimeoutError:
self.result_queue.put_nowait("Timeout: No speech detected within the specified time.")
except sr.UnknownValueError:
self.result_queue.put_nowait("Speech recognition could not understand audio.")

I will test out your code as well as my idea and fix it ASAP.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants