Code:
def get_audio() -> str:
r = sr.Recognizer()
with sr.Microphone() as microphone:
print("Listening ...")
audio = r.listen(microphone) # stuck at this line
print("Sopped Listening")
said = ""
try:
said = r.recognize_google(audio)
except Exception as e:
return str(e)
return said
So when I run the function, it prints "Listening...", goes to the next line and nothing happens. It never gets to "Stopped listening" line. It is guaranteed that there is a connected microphone used by the OS. So might be the problem?