Python speech recognition very slow

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 08:06:28

问题


I am currently developing a smart assistant program (basically it is just listening to what the user says and based on that does something with the code). It was working fine up until today, when I switched to my laptop. The program does not print out any errors, but it also doesn't print out what I said. I'm using the Python Speech Recognition library version 3.8.1. Does anybody know of an alternative for this library? If yes, please try to explain how I would use it 'on the fly' (without first recording the file and then sending it to the server, more like real-time speech).

EDIT: I forgot to say it in the post, I'm using Python 3.

EDIT: Here's the code:

#!/usr/bin/env python3

import speech_recognition as sr


global x


def speech():

    try:
        with sr.Microphone() as source:
            global x
            r = sr.Recognizer()
            audio = r.listen(source)
            x = r.recognize_google(audio)
    except sr.UnknownValueError:
        print("No clue what you said, listening again... \n")
        speech()


if __name__ == '__main__':
    print('Listening and printing what I heard: \n')
    speech()
    print(x)

回答1:


I found that the problem was in the laptop's microphone. The speech recognition worked fine after I plugged in my Blue Snowball. I forced the program to use the Blue Snowball by going into pavucontrol and selecting the Blue Snowball under the recording tab.



来源:https://stackoverflow.com/questions/54492176/python-speech-recognition-very-slow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!