pocketsphinx-python icon indicating copy to clipboard operation
pocketsphinx-python copied to clipboard

RuntimeError: new_Decoder returned -1

Open menon92 opened this issue 8 years ago • 5 comments

I am try to running the example code bellow and getting error

INFO: feat.c(715): Initializing feature stream to type: '1s_c_d_dd', ceplen=13, CMN='live', VARNORM='no', AGC='none'
ERROR: "acmod.c", line 79: Folder 'pocketsphinx/model/en-us/en-us' does not contain acoustic model definition 'mdef'
Traceback (most recent call last):
  File "/home/menon/speech/hello_ps.py", line 15, in <module>
    decoder = Decoder(config)
  File "/usr/local/lib/python2.7/dist-packages/pocketsphinx/pocketsphinx.py", line 260, in __init__
    this = _pocketsphinx.new_Decoder(*args)
RuntimeError: new_Decoder returned -1

My Code:

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

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/en-us'))
config.set_string('-lm', path.join(MODELDIR, 'en-us/en-us.lm.bin'))
config.set_string('-dict', path.join(MODELDIR, 'en-us/cmudict-en-us.dict'))
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()])

How can i solve this problem .

Thanks

menon92 avatar Jun 03 '17 10:06 menon92

config.set_string('-hmm', path.join(MODELDIR, 'en-us'))
config.set_string('-lm', path.join(MODELDIR, 'en-us.lm.bin'))
config.set_string('-dict', path.join(MODELDIR, 'cmudict-en-us.dict'))

rainyear avatar Sep 06 '17 04:09 rainyear

I am facing the same error. I made changes to config file.

Traceback (most recent call last): File "/home/sg/mycroft-core/mycroft/client/speech/main.py", line 172, in main() File "/home/sg/mycroft-core/mycroft/client/speech/main.py", line 141, in main loop = RecognizerLoop() File "/home/sg/mycroft-core/mycroft/client/speech/listener.py", line 205, in init self._load_config() File "/home/sg/mycroft-core/mycroft/client/speech/listener.py", line 233, in _load_config self.create_hot_word_engines() File "/home/sg/mycroft-core/mycroft/client/speech/listener.py", line 261, in create_hot_word_engines threshold, 16000, lang) File "/home/sg/mycroft-core/mycroft/client/speech/recognizer/pocketsphinx_recognizer.py", line 42, in init File "/home/sg/.virtualenvs/mycroft/local/lib/python2.7/site-packages/pocketsphinx/pocketsphinx.py", line 271, in init this = _pocketsphinx.new_Decoder(*args) RuntimeError: new_Decoder returned -1

UW-SG avatar Nov 12 '17 01:11 UW-SG

Same problem for me too @UW-SG Are you able to fix it .

bhaveshAn avatar Mar 27 '18 13:03 bhaveshAn

Hi, I've faced with same problem to. Just check the folders with installed pocketsphinx packages and verify if the MODELDIR and DATADIR path are correct and .set_string to.

In my case package were installed in this folder. /home/user-name/.pyenv/versions/general/lib/python3.6/site-packages/pocketsphinx/model. And there was no folder 'test' and nested 'en-us' folder.

pobedyn avatar Apr 19 '18 08:04 pobedyn

This solved my problem

https://stackoverflow.com/questions/44339312/new-decoder-returned-1-when-trying-to-run-pocketsphinx-on-raspberry-pi/51346264#51346264

choudharykrish avatar Jul 15 '18 07:07 choudharykrish