我最近在我的运行Lion和Python 2.7.3的mac上安装了pocketsphinx模块(不是苹果内置的python,而是brewed)。我尝试运行以下代码:
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但下面是我在运行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但是,当第二次运行import命令时,它将正确运行。因此,目前,我正在运行try-catch,以克服错误。但我不知道这是否还有效。
这个问题似乎以前就出现过,在这个链接上讨论过:http://sourceforge.net/p/cmusphinx/bugs/284/
有没有人解决了这个问题?如果不是,try- catch是绕过这个错误的正确方法吗?
发布于 2013-02-17 06:10:51
有没有人解决这个问题?如果不是,try- catch是绕过这个错误的正确方法吗?
此Cython问题已在以后的Cython中修复
如果不是,try- catch是避免这个错误的正确方法吗?
避免这个错误的正确方法是用Cython重新创建粘合代码。bug报告中的最后一条消息说:
http://sourceforge.net/p/cmusphinx/bugs/284/
https://stackoverflow.com/questions/14914063
复制相似问题