我已经成功安装pocketsphinx-0.8
,Ubuntu 12.04
因为我能够识别语音pocketsphinx_continuous
。
设置后如何import pocketsphinx
在我现在得到python
pocketsphinx-0.8
ImportError: No module named pocketsphinx
我已经成功安装pocketsphinx-0.8
,Ubuntu 12.04
因为我能够识别语音pocketsphinx_continuous
。
设置后如何import pocketsphinx
在我现在得到python
pocketsphinx-0.8
ImportError: No module named pocketsphinx
我敢打赌它是区分大小写的,比如 PocketSphinx 之类的。
help()
我会使用 python 交互式 shell 的函数来搜索它。
matthew@speedy:~/openstack/nova$ python
Python 2.7.3 (default, Sep 26 2012, 21:51:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> help()
Welcome to Python 2.7! This is the online help utility.
If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://docs.python.org/2.7/tutorial/.
Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules. To quit this help utility and
return to the interpreter, just type "quit".
To get a list of available modules, keywords, or topics, type "modules",
"keywords", or "topics". Each module also comes with a one-line summary
of what it does; to list the modules whose summaries contain a given word
such as "spam", type "modules spam".
help> modules phinx
Here is a list of matching modules. Enter any module name to get more help.
matplotlib.sphinxext
matplotlib.sphinxext.ipython_console_highlighting - reST directive for syntax-highlighting ipython interactive sessions.
matplotlib.sphinxext.mathmpl
matplotlib.sphinxext.only_directives
matplotlib.sphinxext.plot_directive - A directive for including a matplotlib plot in a Sphinx document.
所以这对我来说只是一个简单的导入:
matthew@speedy:~/Downloads/pocketsphinx-0.8$ sudo apt-get install python-pocketsphinx
...
>>> import pocketsphinx
>>> dir(pocketsphinx)
['Decoder', 'LatLink', 'LatLinkIterator', 'LatNode', 'LatNodeIterator', 'Lattice', '__builtins__', '__doc__', '__file__', '__name__', '__package__']
从源代码安装很难(我放弃了),但安装 ubuntu 库很容易。
该站点看起来对于从源安装它可能很有用:http ://www.cs.columbia.edu/~ecooper/CS4706/ps-mac.html
如果你已经正确安装了 pocketsphinx,那么这个命令应该可以工作。
import pocketsphinx
如果您仍然遇到问题,请将其放入 try/except 块中:
try:
import pocketsphinx
except:
pass
import pocketsphinx
要在 Ubuntu 中安装 pocketsphinx,可以使用以下命令:
sudo apt-get install python-pocketsphinx