关于CMUSphinx的这两篇文章,我早在18年就写好了保存在草稿箱,当时想做好一个系列多沉淀下再发,可惜后面工作计划有变,没能在项目中继续学习,私下也没在研究。今天整理博客后决定发出来吧,说不定有人正好需要。
一、下载地址
https://cmusphinx.github.io/wiki/download/
二、下载内容
Pocketsphinx — 用C语言编写的轻量级识别库
Sphinxbase — Pocketsphinx所需要的支持库
Sphinx4 — 为语音识别研究用C语言编写的解码器
Sphinxtrain — 声学模型训练工具
以上对应官网最新版本:
We recommend you to use the latest available releases:
下载后的压缩包为以下:
-
sphinxbase-5prealpha.tar
-
pocketsphinx-5prealpha.tar
- sphinxtrain-5prealpha.tar
- sphinx4-5prealpha-src
将上述压缩包复制到linux中,或者直接从linux中下载
至此,下载工作完成!
三、编译环境
Linux操作系统
四、安装配置
1.安装Sphinxbase
- tar xzf sphinxbase-5prealpha.tar.gz
- cd sphinxbase-5prealpha
- ./configure
- make
- make install
此步骤可能出现的错误:
1.checking for bison... no ;configure: error: You need to install bison
解决:sudo apt-get install bison
2.configure: error:
Could not link test program to Python. Maybe the main Python library has been
installed in some non-standard library path. If so, pass it to configure,
via the LDFLAGS environment variable.
Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib"
============================================================================
ERROR!
You probably have to install the development version of the Python package
for your distribution. The exact name of this package varies among them.
============================================================================
解决:sudo apt-get install python-dev
3.checking for swig2.0... no;configure: error: swig not found
解决: sudo apt-get install swig
最后再执行 ./configure,如果没有其他错误,则会出现大概下面的样子:
然后 make -- sudo make install,这两步执行完没有error就是成功了。
最后再usr/local/bin 下面,会看到安装目录
2.安装pocketsphinx
./configure
make clean all
make check
sudo make install
没有error就是成功了,之后再打开usr/local/bin 会看到新生成了几个文件
就是下面三个:
pocketsphinx_batch
pocketsphinx_continuous
pocketsphinx_mdef_convert
3.设置环境变量
export LD_LIBRARY_PATH=/usr/local/lib //存放着动态库
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig // 不知道
4.验证是否成功
在任意目录下输入下面的命令检测是否配置
pocketsphinx_continuous
如果出现下图,则说明配置成功: