【问题标题】:Missing acoustic model definition (mdef) with pocketsphinx-python缺少带有 pocketsphinx-python 的声学模型定义 (mdef)
【发布时间】:2016-03-03 13:37:39
【问题描述】:

我最近在 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()])

我的代码是完全偏离轨道还是我必须做其他事情才能让它工作?

【问题讨论】:

    标签: python-2.7 python-3.x speech-recognition pocketsphinx


    【解决方案1】:

    您需要找到模型的正确路径。如果你的模型在/home/inggrid/model/en-us,你需要写:

     config.set_string('-hmm', "/home/ingrid/model/en-us")
    

    请注意,即使路径中的单个字母不同,例如“_”而不是“-”,也会阻止计算机找到路径。你需要精确。如果不确定什么是相对路径,可以指定绝对路径。你可以从this tutorial了解更多关于路径的信息。

    hub4 是老机型,不推荐使用。对于 8khz,您可以使用this model

    【讨论】:

    • 谢谢!我正在加入我的路径(path.join(X,Y)),这显然让我感到困惑。也感谢您的模型!现在,我的认识更进一步了。虽然还没有得到实际的单词作为输出,只有&lt;sil&gt; [SPEECH] 等,所以我想我仍然缺少一些东西......
    • 您的输入格式很可能是错误的。它必须是 little endian 16bit 8khz PCM。
    • 我更改为 8kHz 并有一个 16 位的 wav 文件,所以我猜这意味着它也是小端和 PCM。但仍然无法正常工作。有什么地方可以问关于pocketsphinx的基本问题吗? wiki 和教程似乎没有包含我需要的基础知识,我无法访问论坛。聊天有用吗? (无法到达)
    • 聊天和论坛都适合您,您可以在这里找到详细信息cmusphinx.sourceforge.net/wiki/communicate 要获得帮助,您需要提供有关您看到的问题的更多详细信息 - 音频文件、您运行的代码等等。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-09
    • 2016-12-14
    • 1970-01-01
    相关资源
    最近更新 更多