1. 程式人生 > >win+python實現離線語音識別

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