如何解决和调试Python中的运行时错误:new_Ad返回-1

时间:2018-12-10 14:58:54

标签: python-2.7 raspberry-pi3 raspbian

我是python编程和Raspberry Pi的新手,我目前正在尝试在python 2.7的Raspberry Pi上编写一个python程序,该程序使用Pocketsphinx将语音转换为文本,但是当我尝试运行以下代码时遇到错误。我已经参考以下https://pypi.org/project/pocketsphinx/

编写了代码
import speech_recognition as sr
from pocketsphinx import get_model_path,get_data_path,LiveSpeech

model_path = get_model_path()

speech = LiveSpeech(
    verbose=False,
    sampling_rate=16000,
    buffer_size=2048,
    no_search=False,
    full_utt=False,
    hmm=os.path.join(model_path, 'en-us'),
    lm=os.path.join(model_path, 'en-us.lm.bin'),
    dic=os.path.join(model_path, 'cmudict-en-us.dict')
    )

for phrase in speech:
    print phrase

运行此代码时,出现以下错误:

Traceback (most recent call last):
  File "/home/pi/testing files/sppechtotextrecognition.py", line 15, in <module>
    dic=os.path.join(model_path,'cmudict-en-us.dict')
  File "/usr/local/lib/python2.7/dist-packages/pocketsphinx/__init__.py", line 206, in __init__
    self.ad = Ad(self.audio_device, self.sampling_rate)
  File "/usr/local/lib/python2.7/dist-packages/sphinxbase/ad_pulse.py", line 124, in __init__
    this = _ad_pulse.new_Ad(audio_device, sampling_rate)
RuntimeError: new_Ad returned -1

任何帮助/建议将不胜感激

0 个答案:

没有答案