win+python实现离线语音识别

安装SpeechRecognition模块
使用recognize_sphinx(),安装PocketSphinx
在这里插入图片描述使用测试:

import speech_recognition as sr

# obtain audio from the microphone
r = sr.Recognizer()
print(r)
harvard = sr.AudioFile('input.wav')
print(harvard)
with harvard as source:
    audio = r.record(source)
# recognize speech using Sphinx
try:
    print("Sphinx thinks you said " + r.recognize_sphinx(audio))
except sr.UnknownValueError:
    print("Sphinx could not understand audio")
except sr.RequestError as e:
    print("Sphinx error; {0}".format(e))

参考文献:
https://blog.csdn.net/zhangbijun1230/article/details/83420031

猜你喜欢

转载自blog.csdn.net/weixin_40490238/article/details/84841825