0

enter image description here

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()
`
  • I highly recommend using a debugger to examine exactly what the error is. You can at least look at its type via `print(repr(e))` though, but not being able to debug your own programs is a severe handicap. There's a really great free debugger in PyCharm Community Edition. – Random Davis Aug 13 '21 at 20:56
  • Also what happens if you simply don't catch the exception? – Random Davis Aug 13 '21 at 21:05

0 Answers0