Search code examples
pythonpython-3.xspeech-recognitiongoogle-speech-api

Speech recognition for Python 3.4 thats easy to work?


I wish to get a simple speech recognition that works. I have been looking at this on speech_recognition, When I execute the code the following error occurs

import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source:                
    audio = r.listen(source)                  

try:
    print("You said " + r.recognize(audio))    
except LookupError:                            




print("You said " + r.recognize(audio))    # recognize speech using Google       Speech Recognition
AttributeError: 'Recognizer' object has no attribute 'recognize'

    print("Could not understand audio")

This was copied from their examples on their web page


Solution

  • I got it working.

    import speech_recognition as sr
    
    # obtain audio from the microphone
    r = sr.Recognizer()
    with sr.Microphone() as source:
        print("Say something!")
        audio = r.listen(source)
    
    print(r.recognize_google(audio))