Recgonizer.listen never stop listening
Steps to reproduce
-
(How do you make the issue happen? Does it happen every time you try it?) """ I run this code:
def init_speech(): print("Listening...") play_audio('sounds/when.wav') r = sr.Recognizer()
OPENING THE MICROPHONE AS source
with sr.Microphone() as source: print("Say something") #listening with the recognizer object, and passing it the sorce.
r.adjust_for_ambient_noise(source) audio = r.listen(source=source,timeout=10)play_audio('sounds/fill.wav') command = ""
try: command = r.recognize_sphinx(audio) except: print("Couldn't understand you")
print("Your Command",command)
init_speech()
YES IT HAPPENS EVERY TIME I TRY IT """ 2. see '1.' 3. no audio files except the ones that plays in the end and start, both of them working. if I run in my code the method "recogniser.listen(source)" the code never stops listen. if I run in my code the method "recogniser.record(souce)" it goes to the "except"
Expected behaviour
I expected that the recogniser will understand me, and it will print what I said.
Actual behaviour
if my code was: recognizer.record(), the code printed out (as I told it) "Couldn't understand you" if my code was: recognizer.listen(), it never stopped listening. so I add "timeout=10", but after 10 seconds the program crashed saying:
"raise WaitTimeoutError("listening timed out while waiting for phrase to start"
speech_recognition.WaitTimeoutError: listening timed out while waiting for phrase to start"
System information
(Delete all the statements that don't apply.)
My system is: Macosx Catalina
My Python version is : 3.7
My Pip version is : pip3
My SpeechRecognition library version is : 3.6.3
My PyAudio library version is: 0.2.11
My microphones are: ['Built-in Microphone', 'Built-in Output'] (this is the output of the command was written here.)
My working microphones are: couldn't run this common "print(sr.Microphone.list_working_microphones()", the problem I got running it is: """ AttributeError: type object 'Microphone' has no attribute 'list_working_microphones' """
I installed PocketSphinx from: I didn't , I'm working with a course from Udemy. and it didn't said I need it.
1st off please use code tags, as it makes your code much easier to read. Extending from this, please try the example code for microphones and tell me how you go.