作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我最近在 Lubuntu 15.10 上安装了 pocketsphinx-python
,我想对音频文件(最好是 8kH)进行语音识别。我收到一条错误消息,但我不明白,因为我的文件夹 /usr/share/pocketsphinx/model/hmm/en_US/
中有一个名为 mdef
的文件>,它说我不这样做:
INFO: feat.c(715): Initializing feature stream to type: '1s_c_d_dd', ceplen=13, CMN='current', VARNORM='no', AGC='none'
INFO: cmn.c(143): mean[0]= 12.00, mean[1..12]= 0.0
ERROR: "acmod.c", line 83: Folder 'pocketsphinx/model/en_us/hub4wsj_sc_8k/' does not contain acoustic model definition 'mdef'
Traceback (most recent call last):
File "web_speech_api.py", line 16, in <module>
decoder = Decoder(config)
File "/home/ingrid/.local/lib/python3.4/site-packages/pocketsphinx/pocketsphinx.py", line 271, in __init__
this = _pocketsphinx.new_Decoder(*args)
RuntimeError: new_Decoder returned -1
这是我的 Python3 脚本:
#!/usr/bin/env python
from os import environ, path
import sys
from pocketsphinx.pocketsphinx import *
from sphinxbase.sphinxbase import *
MODELDIR = "pocketsphinx/model"
DATADIR = "pocketsphinx/test/data"
# Create a decoder with certain model
config = Decoder.default_config()
config.set_string('-hmm', path.join(MODELDIR, 'en_us/hub4wsj_sc_8k/'))
config.set_string('-lm', path.join(MODELDIR, 'en_us/hub4.5000.DMP'))
config.set_string('-dict', path.join(MODELDIR, 'en_us/cmu07a.dic'))
decoder = Decoder(config)
# Decode streaming data.
decoder = Decoder(config)
decoder.start_utt()
stream = open(path.join(DATADIR, 'goforward.raw'), 'rb')
while True:
buf = stream.read(1024)
if buf:
decoder.process_raw(buf, False, False)
else:
break
decoder.end_utt()
print ('Best hypothesis segments: ', [seg.word for seg in decoder.seg()])
我的代码是否完全偏离了轨道,或者我还需要做些什么才能让它正常工作?
最佳答案
您需要模型的正确路径。如果你的模型在/home/ingrid/model/en-us,你需要这样写:
config.set_string('-hmm', "/home/ingrid/model/en-us")
请注意,即使路径中的单个字母不同,例如“_”而不是“-”也会阻止计算机找到路径。你需要精确。如果不确定什么是相对路径,可以指定绝对路径。您可以从 this tutorial 了解有关路径的更多信息.
hub4 是旧型号,不建议使用。对于 8khz,您可以使用 this model .
关于python-2.7 - pocketsphinx-python 缺少声学模型定义 (mdef),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35773734/
我已经将 so 文件复制到 libs 文件夹和 sync 文件夹以及 Assets 中的 assets.lst 文件。我还在应用程序中添加了 pocketsphinx-android-0.8-noli
我最近在 Lubuntu 15.10 上安装了 pocketsphinx-python,我想对音频文件(最好是 8kH)进行语音识别。我收到一条错误消息,但我不明白,因为我的文件夹 /usr/shar
我是一名优秀的程序员,十分优秀!