win+python实现离线语音识别

安装SpeechRecognition模块
使用recognize_sphinx(),安装PocketSphinx
win+python实现离线语音识别_第1张图片使用测试:

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

你可能感兴趣的:(python学习)