0
I am making a program that will return me a response according to what I tell him, for that I used the Speechrecognition library to take what I say and pass as parameter, only that I realized that if I do not say anything is issued an error and the program ends, That’s why I didn’t end up saying anything, so I was wondering if there’s any way I could get him to wait for me to talk? The code:
def escutar_microfone():
microfone = sr.Recognizer()
with sr.Microphone() as source:
microfone.adjust_for_ambient_noise(source)
print("Fale, estou escutando!!")
audio = microfone.listen(source)
try:
frase = microfone.recognize_google(audio, language='pt-BR')
return frase.lower()
except:
print("Erro")