speech recognition python code not working

后端 未结 13 1788
傲寒
傲寒 2020-12-15 10:23

I am running the following code in Python 2.7 with pyAudio installed.

import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source:             


        
13条回答
  •  误落风尘
    2020-12-15 11:00

    Put the Try and Except inside the indentation.

    Here is my Working code:-

    while True:
        r = sr.Recognizer()
            with sr.Microphone() as source:
                print("Say Something")
                audio=r.listen(source)
            try:    
                print(r.recognize_google(audio),"\n")
            except:
                pass
    

提交回复
热议问题