Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Python pocketsphinx 'module' object has no attribute 'Decoder' #3

Closed

Description

@Arti3DPlayer

I try to run simple example of using pocketsphinx. I have installed all libraries, plugins that was needed... Python 2.7.6. But still get an error:

pocketsphinx 'module' object has no attribute 'Decoder'

import sys,os 
import pocketsphinx as ps 
import sphinxbase


def decodeSpeech(hmmd,lmdir,dictp,wavfile):
    speechRec = ps.Decoder(hmm = hmmd, lm = lmdir, dict = dictp)
    wavFile = file(wavfile,'rb')
    wavFile.seek(44)
    speechRec.decode_raw(wavFile)
    result = speechRec.get_hyp()
    return result[0]


if __name__ == "__main__":
    hmdir = '/usr/share/pocketsphinx/model/hmm/wsj1'
    lmd   = '/usr/share/pocketsphinx/model/lm/wsj/wlist5o.3e-7.vp.tg.lm.DMP'
    dictd = '/usr/share/pocketsphinx/model/lm/wsj/wlist5o.dic'
    wavfile = "msg_12c3da80-c6be-11e3-9430-eb6ba5ab4d1f.wav"
    recognised = decodeSpeech(hmdir,lmd,dictd,wavfile)

Activity

  1. Arti3DPlayer commented on Apr 12, 2015

    @Arti3DPlayer
    Author

    print dir(ps)
    ['builtins', 'doc', 'file', 'loader', 'name', 'package', 'path']

    print ps.__file__

    /usr/local/lib/python2.7/dist-packages/pocketsphinx-0.0.4-py2.7-linux-x86_64.egg‌​/pocketsphinx/__init__.pyc
    
  2. sebpiq commented on Jun 18, 2015

    @sebpiq

    Same error here :(

  3. sebpiq commented on Jun 18, 2015

    @sebpiq

    And from ipython the import sometimes work (and I get the Decoder), sometimes I receive the error ValueError: PyCapsule_GetPointer called with invalid PyCapsule object

  4. sidja commented on Sep 25, 2015

    @sidja

    Same here

  5. nshmyrev commented on Oct 17, 2015

    @nshmyrev
    Contributor

    PyCapsule error means you are using very outdated pocketsphinx version 0.8. Please use latest version.

  6. added a commit that references this issue on Nov 24, 2015
  7. Virenferns commented on Apr 18, 2019

    @Virenferns

    I am facing this error while running this code:
    TypeError: init() got an unexpected keyword argument 'hmm'

    CODE:
    from os import environ, path
    import sys,os
    import pocketsphinx as ps
    import sphinxbase
    print (dir(ps))

    MODELDIR = "C:\Anaconda3\Lib\site-packages\pocketsphinx\model"
    DATADIR = "C:\Anaconda3\Lib\site-packages\pocketsphinx\data"

    def decodeSpeech(hmmd,lmdir,dictp,wavfile):
    speechRec = ps.Decoder(hmm = hmmd, lm = lmdir, dict = dictp)
    wavFile = os(wavfile,'rb')
    wavFile.seek(44)
    speechRec.decode_raw(wavFile)
    result = speechRec.get_hyp()
    return result[0]

    if name == "main":
    hmdir = path.join(MODELDIR, 'en-us/en-us')
    lmd = path.join(MODELDIR, 'en-us/en-us.lm.bin')
    dictd = path.join(MODELDIR, 'en-us/cmudict-en-us.dict')
    wavfile = path.join(DATADIR, 'goforward.raw')
    recognised = decodeSpeech(hmdir,lmd,dictd,wavfile)

  8. sairajrapuru commented on Aug 20, 2019

    @sairajrapuru
    from __future__ import print_function
    import os
    from pocketsphinx import Pocketsphinx, get_model_path, get_data_path
     
    model_path = '/Users/.../Pocket_Sphinx/pocketsphinx-5prealpha/model/en-in/' 
    data_path = '/Users/.../Downloads/Audio/..'
    
    config = {
     'hmm': os.path.join(model_path, 'en-in'),
     'lm': os.path.join(model_path, 'words.lm'),
     'dict': os.path.join(model_path, 'fa_in.dic')
     }
     
    ps = Pocketsphinx(**config)
    ps.decode(
     audio_file=os.path.join(data_path, '<File>.wav'),
     buffer_size=2048,
     no_search=False,
     full_utt=False
     )
    print(ps.segments())
    print(*ps.best(count=20), sep='\n')
    

    This results in :

    Traceback (most recent call last):
      File "fa2.py", line 14, in <module>
        ps = Pocketsphinx(**config)
      File "/usr/local/lib/python2.7/site-packages/pocketsphinx/__init__.py", line 90, in __init__
        super(Pocketsphinx, self).__init__(config)
      File "/usr/local/lib/python2.7/site-packages/pocketsphinx/pocketsphinx.py", line 273, in __init__
        this = _pocketsphinx.new_Decoder(*args)
    RuntimeError: new_Decoder returned -1
    

    Request @bambocher to re-open this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions