最近在研究离线语音识别,在运行以下代码时:
# -*- coding:utf-8 -*-
import speech_recognition as sr
def wav2txt(wav_file,language):
r = sr.Recognizer()
audio= ""
with sr.AudioFile(wav_file) as src:
audio= r.record(src)
print(r.recognize_sphinx(audio,language=language))
fp1=r'D:\pythondata\recording.wav'
wav2txt(fp1,"zh-CN")
出现错误提示:speech_recognition.RequestError: missing PocketSphinx phoneme dictionary file: "D:\software\python37\lib\site-packages\speech_recognition\pocketsphinx-data\zh-CN\pronounciation-dictionary.dict
请问有谁遇到过一样的问题?是如何解决的?
根据源码代码:
if not os.path.isfile(phoneme_dictionary_file):
raise RequestError("missing PocketSphinx phoneme dictionary file: "{}"".format(phoneme_dictionary_file))
在提示的目录下没有找到pronounciation-dictionary.dict文件,在zh-CN目录下应该有如下文件才可:
参考这里安装语音包的方法。
https://www.cda.cn/discuss/post/details/6049a6917669fa285d6f27b6