SpeechRecogniton module is too slow in python

后端 未结 1 780
有刺的猬
有刺的猬 2021-01-15 01:44

I was trying to use Speech Recognition for my Deep Learning Chatbot to get the input from the user. Actually my Speech-Recognition function code is this:

def          


        
相关标签:
1条回答
  • 2021-01-15 02:25

    The duration parameter is deprecated now. Ref StackOverflow question.
    Instead use phrase_time_limit or timeout.

    Here is the block of code using phrase_time_limit:

    import speech_recognition as sr
    def myCommand():
        r = sr.Recognizer()
        with sr.Microphone() as source:
            audio = r.listen(source, phrase_time_limit = 5)  
        try:
            command = r.recognize_google(audio).lower()
            print("you said: " + command)
            
        except sr.UnknownValueError:
            print("Sorry, Cant understand, Please say again")
            command = myCommand()
        return command
    

    This works perfectly fine.

    0 讨论(0)
提交回复
热议问题