speech_recognition icon indicating copy to clipboard operation
speech_recognition copied to clipboard

Listen function stays active for too long

Open Adrien-a0 opened this issue 2 years ago • 3 comments

So just using the standard import speech_recognition as sr r = sr.Recognizer() speech = sr.Microphone(device_index=1) with speech as source: audio = r.adjust_for_ambient_noise(source) audio = r.listen(source) try: recog = r.recognize_google(audio, language = 'en-US') key="GOOGLE_SPEECH_RECOGNITION_API_KEY") # instead of `r.recognize_google(audio)`` print("You said: " + recog) read=True

The only issue I'm having is that i want to say one or two word commands, however the listen function seems to stay active for too long. As far as i understand the function listens until silence is detected, but there must be some sort of delay before it switches off? I feel like this delay is too long for the purposes of what i want to do as i see multiple commands returned in one listen period. Can i pass this through as an argument in the listen function? Or alternatively can this value be changed in the source code easily. Thanks

Adrien-a0 avatar Apr 06 '22 11:04 Adrien-a0

You can try lowering r.pause_threshold. Just don't lower it to low or it won't catch your entire phrase.

Ccode-lang avatar May 25 '22 18:05 Ccode-lang

Hello Adrien. Did you solve the problem? ... I have the same issue :(

HectorCamacho avatar Jul 25 '22 21:07 HectorCamacho

Same issue here. Is there a way to set a maximum time to record?

void4 avatar Oct 07 '22 18:10 void4