I recently installed pocketsphinx modules on my mac running Lion and Python 2.7.3(Not Apple’s built in python, but brewed). I tried to run the following code:
import pocketsphinx as p
decoder = p.Decoder(jsgf='/path_to_jsgf_file/grammar.jsgf',samprate='8000')
fh = open('myrecording.wav', 'rb')
nsamp = decoder.decode_raw(fh)
print 'You said,', hyp
print 'Your score was', score
But here’s the error I get on running import pocketsphinx as p :
Traceback (most recent call last):
File "speech_reco.py", line 4, in <module>
import pocketsphinx as p
File "sphinxbase.pxd", line 150, in init pocketsphinx (pocketsphinx.c:7935)
ValueError: PyCapsule_GetPointer called with invalid PyCapsule object
However, it runs correctly when the import command is run the second time. Therefore, presently, I’m running a try-catch there and getting past the error. But I don’t know whether this still works.
This issue seems to have come up before,as discussed on this link: http://sourceforge.net/p/cmusphinx/bugs/284/
Has anyone fixed this issue yet? If not, would try- catch be the right way to get around this error?
This Cython issue is fixed in later Cython
The right way to get around this error is to recreate glue code with Cython. The last message in the bug report says that:
http://sourceforge.net/p/cmusphinx/bugs/284/