speech_recognition
speech_recognition copied to clipboard
Listen function stays active for too long
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
You can try lowering r.pause_threshold
. Just don't lower it to low or it won't catch your entire phrase.
Hello Adrien. Did you solve the problem? ... I have the same issue :(
Same issue here. Is there a way to set a maximum time to record?