Skip to content Skip to sidebar Skip to footer

Python, Speech Recognition Stuck At 'listening...'

The code is stuck at listening ( audio=r.listen(source) line) and doesn't go beyond it. No error messages or anything else. My code: import speech_recognition as sr def takeComman

Solution 1:

I just checked the link you posted in the comment.

There is this code:

with mic as source:
    audio = r.listen(source)

If this code does not work, one reason could be that the microphone picks up too much ambient noise.

The solution may be

with mic as source:
    r.adjust_for_ambient_noise(source)
    audio = r.listen(source)

Solution 2:

I didn't work with this library; but I think r.listen(source) is a blocking function (method). A blocking method is a method that blocks code from continuing execution until it is done (returned). Your app is waiting for r.listen(source) to finish.

You should put print("Recognizing...") before it. Also as I read here, r.listen(source) will return result (finish) when it detects silence (probably after a voice). So your code should continue execution after it detects silence.

Solution 3:

The solution is you have to set some arguments in the listen() method.

For example:

audio=r.listen(source,timeout=8,phrase_time_limit=8)

Post a Comment for "Python, Speech Recognition Stuck At 'listening...'"