I am running the following code in Python 2.7 with pyAudio installed.
import speech_recognition as sr r = sr.Recognizer() with sr.Microphone() as source:
Put the Try and Except inside the indentation.
Here is my Working code:-
while True: r = sr.Recognizer() with sr.Microphone() as source: print("Say Something") audio=r.listen(source) try: print(r.recognize_google(audio),"\n") except: pass