如何使用 python 在 pocketsphinx 中配置西班牙语?

How can I configure Spanish in pocketsphinx with python?

我正在尝试使用 Pocketsphinx 进行语音识别 Ubuntu 32b 和 python 2.7

我是西班牙人,我想使用西班牙模型,但是由于信息有限和我在这个特定领域的知识很少,所以很难。很难找到安装步骤的简单来源。

使用 16khz 16 位单声道格式录制示例文件 hola.wav

然后安装pocketsphinx-python

sudo apt-get install -y python python-dev python-pip build-essential swig git
git clone --recursive https://github.com/cmusphinx/pocketsphinx-python
cd pocketsphinx-python
sudo python setup.py install

然后从 cmusphinx 网站下载西班牙语 models

然后写个脚本试试运行吧,应该是这样的:

#!/usr/bin/env python
from os import environ, path

from pocketsphinx.pocketsphinx import *
from sphinxbase.sphinxbase import *

# Here is the configuration for Spanish
config = Decoder.default_config()
config.set_string('-hmm', 'cmusphinx-es-5.2/model_parameters/voxforge_es_sphinx.cd_ptm_4000')
config.set_string('-lm', 'es-20k.lm.gz')
config.set_string('-dict', 'es.dict')
decoder = Decoder(config)

# Decode streaming data.
decoder = Decoder(config)
decoder.start_utt()
stream = open('hola.wav', '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()])

要了解有关 CMUSphinx 的更多信息,请阅读 tutorial