安装SpeechRecognition模块
使用recognize_sphinx(),安装PocketSphinx
使用测试:
import speech_recognition as sr# obtain audio from the microphoner = sr.Recognizer()print(r)harvard = sr.AudioFile('input.wav')print(harvard)with harvard as source:audio = r.record(source)# recognize speech using Sphinxtry: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))
参考文献:
/zhangbijun1230/article/details/8341