0

I'm facing error in pocketsphinx code. I have both pocketsphinx and sphinxbase installed. And I also have built both of these packages with Visual Studio. Here is the code:

 #!/usr/bin/python

from os import environ, path

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

MODELDIR = "../../../model"
DATADIR = "../../../test/data"

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'))
config.set_string('-logfn', '/dev/null')
decoder = Decoder(config)

stream = open(path.join(DATADIR, 'goforward.raw'), 'rb')
#stream = open('10001-90210-01803.wav', 'rb')

in_speech_bf = False
decoder.start_utt()
while True:
    buf = stream.read(1024)
    if buf:
        decoder.process_raw(buf, False, False)
        if decoder.get_in_speech() != in_speech_bf:
            in_speech_bf = decoder.get_in_speech()
            if not in_speech_bf:
                decoder.end_utt()
                print ('Result:', decoder.hyp().hypstr)
                decoder.start_utt()
    else:
        break
decoder.end_utt()

And here is the error:

this = _pocketsphinx.new_Decoder(*args)
RuntimeError: new_Decoder returned -1
Nikolay Shmyrev
  • 24,897
  • 5
  • 43
  • 87
Tauseef_Ahmed
  • 343
  • 3
  • 8
  • 18
  • Possible duplicate of [Pocketsphinx decoder initialization returns -1](https://stackoverflow.com/questions/38941443/pocketsphinx-decoder-initialization-returns-1) – Nikolay Shmyrev Aug 14 '17 at 17:36
  • You can remove the line `config.set_string('-logfn', '/dev/null')` to get more detailed error message. Your error is that MODELDIR does not point to the model folder, you can use absolute path if you are not sure about relative path. – Nikolay Shmyrev Aug 14 '17 at 17:37
  • Didn't work for me man. Tried both solutions. Any other suggestions? – Tauseef_Ahmed Aug 15 '17 at 19:14

0 Answers0