1

I'm trying to use this library to work with speech recognition. I'm just using the basic usage script they made available here.

Here is the script:

#!/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()])

And here is the error:

RuntimeError                              Traceback (most recent call last)
<ipython-input-14-fdecd3fd35b8> in <module>()
      4 config.set_string('-lm', path.join(MODELDIR, 'en-us/en-us.lm.bin'))
      5 config.set_string('-dict', path.join(MODELDIR, 'en-us/cmudict-en-us.dict'))
----> 6 decoder = Decoder(config)

C:\Programmes\lib\site-packages\pocketsphinx\pocketsphinx.py in __init__(self, *args)
    270         __init__(Decoder self, Config config) -> Decoder
    271         """
--> 272         this = _pocketsphinx.new_Decoder(*args)
    273         try:
    274             self.this.append(this)

RuntimeError: new_Decoder returned -1

I checked in well if everything is well installed and I got an audio on the internet to test.

Nikolay Shmyrev
  • 24,897
  • 5
  • 43
  • 87
marin
  • 923
  • 2
  • 18
  • 26

0 Answers0