bambocher / pocketsphinx-python

Python interface to CMU Sphinxbase and Pocketsphinx libraries
https://pypi.python.org/pypi/pocketsphinx
Other
373 stars 187 forks source link

RuntimeError: new_Decoder returned -1 #24

Open menon92 opened 7 years ago

menon92 commented 7 years ago

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

rainyear commented 7 years ago
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'))
UW-SG commented 7 years ago

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

bhaveshAn commented 6 years ago

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

pobedyn commented 6 years ago

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.

choudharykrish commented 6 years ago

This solved my problem

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