Reputation: 11
i'm testing out this module named Speech_Recognizer but for some reason it won't recognize my voice.here's the code:
import speech_recognition as sr
r=sr.Recognizer()
with sr.Microphone() as source:
print("speak:")
audio = r.listen(source)
try:
text = r.recognize_google(audio)
print("You said: {}".format(text))
except:
print("sorry couldn't hear that")
The main problem/the reason why I think it won't recognize my voice even when I'm shouting is that it's stuck at the print("speak") and won't do anything after that, I've even tried using a new earphone w mic but it still didn't work can anyone pls help me.
Upvotes: 0
Views: 106
Reputation: 892
You forgot to calibrate threshold of ambient noise. Add r.adjust_for_ambient_noise(source)
before the print("speak:")
line.
Upvotes: 1