speech recognition python code not working

后端 未结 13 1751
傲寒
傲寒 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条回答
  • I guess the problem is with the duration. If you set some duration to the speech recognition engine the problem will be resolved. Try the following code:

    import speech_recognition as sr
    r = sr.Recognizer()                                                                                   
    with sr.Microphone() as source:                                                                      
        speak(sen)
        print("listening...")
        audio = r.record(source,duration=3)
        try:
            str=r.recognize_google(audio)
            print(str)
        except:
            print("some error occurred!")
    
    0 讨论(0)
提交回复
热议问题