Menu

python example file continuous_test.py "error"

Help
loek
2016-08-08
2016-08-11
  • loek

    loek - 2016-08-08

    I use the raspberry pi with jessie and I installed pocketsphinx with pip.
    When I run the example file continuoes_test.py I get this error:
    Can someone help me solve this problem.

    Traceback (most recent call last):
      File "continuous_test.py", line 16, in <module>
        decoder = Decoder(config)
      File "/usr/local/lib/python2.7/dist-packages/pocketsphinx/pocketsphinx.py", line 271, in __init__
        this = _pocketsphinx.new_Decoder(*args)
    RuntimeError: new_Decoder returned -1
    

    Below is the script:

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

    Last edit: Nickolay V. Shmyrev 2016-08-10
    • Nickolay V. Shmyrev

      MODELDIR = "../../../model"

      You didn't specify a path to the acoustic model properly here, you need to specify correct path:

      config.set_string('-logfn', '/dev/null')
      

      You can remove this line to get more details about the problem.

       
  • loek

    loek - 2016-08-11

    Thanks. The file continuoes_test.py is working now. With this test I can hear my voice in the speaker. But the other example files in the dir test are not working.
    Do you know an example that pocketsphinx say someting in the speaker.
    I mean python examples.

     

    Last edit: loek 2016-08-11

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.