简体   繁体   English

导入Pocketsphinx无法在python 3.2(Windows)中运行。 “ ImportError:没有名为pocketsphinx的模块”

[英]Importing pocketsphinx not working python 3.2 (Windows). “ImportError: No module named pocketsphinx”

I'm trying to use pocketsphinx on python 3.2 but I'm very confused. 我试图在python 3.2上使用pocketsphinx,但是我很困惑。 I've placed the builded packages in the site-packages directory, made sure I'm using the right audio file format .According to the documentation python is supported because there are python bindings. 我将构建的软件包放置在site-packages目录中,确保使用正确的音频文件格式。根据文档python的支持,因为存在python绑定。 I've looked around the forum and it seems that an _init_.py file is needed which is not included so that may be an issue? 我在论坛上四处张望,似乎需要一个_init_.py文件,该文件不包含在内,所以可能是个问题? Any suggestions on how to fix this problem? 关于如何解决此问题的任何建议?

I am currently using pocketsphinx and sphinxbase v 0.8 downloaded link and link. 我目前正在使用Pocketsphinx和sphinxbase v 0.8下载链接和链接。 The files I put into site packages are all files contained in the Debug folder of the pocketsphinx directory. 我放入站点包中的文件是Pocketsphinx目录的Debug文件夹中包含的所有文件。 namely: 即:

  • sphinxbase.dll sphinxbase.dll
  • pocketsphinx(.dll, .exp,.ilk,.lib,.pdb) pocketsphinx(.dll,.exp,.ilk,.lib,.pdb)
  • pocketsphinx_batch(.exe,.ilk,.pdb) pocketsphinx_batch(.exe,.ilk,.pdb)
  • pocketsphinx_continuous(.exe,.ilk,.pdb) pocketsphinx_continuous(.exe,.ilk,.pdb)
  • pocketsphinx_mdef_convert(.exe,.ilk,.pdb) pocketsphinx_mdef_convert(.exe,.ilk,.pdb)

I am using the following Python code: 我正在使用以下Python代码:

import pocketsphinx as ps
from pocketsphinx import sphinxbase

hmmd = 'C:\Python32\Lib\site-packages\pocketsphinx\model\hmm\en_US\hub4wsj_sc_8k'
lmd = 'C:\Python32\Lib\site-packages\pocketsphinx\model\lm\en_US\hub4.5000.DMP'
dictd = 'C:\Python32\Lib\site-packages\pocketsphinx\model\lm\en_US\hub4.5000.dic'
fraw1 = file(r'C:\Users\Stefan\Documents\2012\40I6\test1.wav', 'rb')
fraw1.seek(44)
speechRec = ps.Decoder(hmm = hmmd, lm = lmd, dict = dictd) speechRec.decode_raw(fRaw1)
result = speechRec.get_hyp()
print (result[0])

To compile python module do the following: 要编译python模块,请执行以下操作:

  1. Build sphinxbase and pocketsphinx with Visual Studio as needed 根据需要使用Visual Studio构建sphinxbase和Pocketsphinx
  2. copy sphinxbase.lib and sphinxbase.dll from sphinxbase/bin/Release to sphinxbase/python and to pocketsphinx/python 将sphinxbase.lib和sphinxbase.dll从sphinxbase / bin / Release复制到sphinxbase / python和Pocketsphinx / python
  3. copy pocketsphinx.lib and pocketsphinx.dll from pocketsphinx/bin/Release to sphinxbase/python and to pocketsphinx/python 从pocketsphinx / bin / Release复制pocketsphinx.lib和pocketsphinx.dll到sphinxbase / python和Pocketsphinx / python
  4. Open terminal 打开终端
  5. Change directory to sphixnbase/python 将目录更改为sphixnbase / python
  6. Run the command 运行命令

    python setup_win32.py install python setup_win32.py安装

  7. Change directory to pocketsphinx/python 将目录更改为Pocketsphinx / python

  8. Run the command 运行命令

    python setup_win32.py install python setup_win32.py安装

  9. Run the command to test python 运行命令以测试python

    python ps_test.py python ps_test.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM