1.安装python373x64
2.安装依赖库
pocketsphinx-0.1.15-cp37-cp37m-win_amd64.whl
PyAudio-0.2.11-cp37-cp37m-win_amd64.whl
python -m pip install pocketsphinx-0.1.15-cp37-cp37m-win_amd64.whl
python -m pip install PyAudio-0.2.11-cp37-cp37m-win_amd64.whl
python -m pip install SpeechRecognition
3.下载中文识别包
cmusphinx-zh-cn-5.2.tar.gz
解压到Python373x64\Lib\site-packages\speech_recognition\pocketsphinx-data\zh-CN目录下(此目录自行创建),把解压出来的zh_cn.cd_cont_5000文件夹重命名为acoustic-model,zh_cn.lm.bin重命名为language-model.lm.bin,zh_cn.dic重命名为pronounciation-dictionary.dict。
4.编写代码测试
import speech_recognition as sr
r = sr.Recognizer() #调用识别器
test = sr.AudioFile("test.wav") #导入语音文件
with test as source:
audio = r.record(source)
type(audio)
c=r.recognize_sphinx(audio, language='zh-cn') #识别输出
print(c)
5.下载test.wav
提取码: t3vp
6.测试结果