Skullbash Skullbash - 2 months ago 14
Python Question

AttributeError: 'Recognizer' object has no attribute 'recognize'

I was trying the Speech Recognition module in Python (version 3.5) and have been getting the following error:

'AttributeError: 'Recognizer' object has no attribute 'recognize''

Here is the code I used.

import pyaudio
import speech_recognition as sr


with sr.Microphone() as source:

print("Speech was:" + r.recognize(audio))
except LookupError:
print('Speech not understood')

I found this code on Stack Overflow itself and also reading up the documentation from the Speech-Recognition module given here : however it is not executing in my system for some reason. I tried googling for a solution but could not find anyone with a similar kind of error.

I'd be grateful if someone could help me out with what is wrong here. Thanks in advance.


according to that documentation the Recognizer class don't have a method recognize and that is the meaning of the error you get, that come from

print("Speech was:" + r.recognize(audio))

here you are trying to call a method that don't exist, you have to use one of the several recognize_* method that the class offer instead, like recognize_google, recognize_wit, recognize_ibm or recognize_att