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 takeCommand():
'''
It takes user's voice as input
'''
r=sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
r.pause_threshold = 1
audio=r.listen(source)
try:
print("Recognizing...")
query = r.recognize_google(audio, language="en-in")
print(f"Recognized Command: {query}")
except Exception as e:
print(e)
print("I didn't recognize what you said please repeat")
return "None"
return query
takeCommand()
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…