sometimes i get this error sometimes I don't it comes and goes, is there a way to fix? did i make a mistake somewhere in the code?
def audio():
r = sr.Recognizer()
with sr.Microphone() as source:
r.adjust_for_ambient_noise(source, duration=1)
audio = r.listen(source)
said = ''
try:
said = r.recognize_google(audio)
print(said)
except Exception as e:
print('expection: ' + str(e))
return said.lower()
text = audio()
`