Linux 使用 pocketsphinx 做中文语音识别

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/kongxx/article/details/85595517

前一篇博客说了一下怎么在 Windows 平台使用 pocketsphinx 做中文语音识别,今天看看在 Linux 上怎办实现。

由于 pocketsphinx 没有提供 Linux 的二进制包,因此我们需要自己根据源码编译。

下载

从下面地址下载源代码

https://sourceforge.net/projects/cmusphinx/files/

这里,我使用的是 sphinxbase-5prealpha.tar.gz 和 pocketsphinx-5prealpha.tar.gz。

编译

  • 编译 sphinxbase
    tar zxvf sphinxbase-5prealpha.tar.gz
    mv sphinxbase-5prealpha sphinxbase
    cd sphinxbase
    ./configure
    make
    sudo make install
    
  • 编译 pocketsphinx
    tar zxvf pocketsphinx-5prealpha.tar.gz
    cd pocketsphinx-5prealpha
    ./configure
    make clean all
    sudo make install
    

下载模型文件

模型文件下载地址

https://sourceforge.net/projects/cmusphinx/files/Acoustic and Language Models/
其中 Mandarin 为中文普通话,下载之后我们可以看到

  • 声学模型:zh_broadcastnews_16k_ptm256_8000.tar.bz2 (需要解压)
  • 语言模型:zh_broadcastnews_64000_utf8.DMP
  • 拼音字典:zh_broadcastnews_utf8.dic

测试中文语音识别

  • 首先准备一个中文音频文件(要求:.wav 格式,采样频率 16000HZ,单声道)
  • 将下载的中文模型文件和解压后的 pocketsphinx 目录放到同一个目录下,这里假定就叫 “test”。
  • 进入“test”目录,然后运行下面的命令
pocketsphinx\bin\Release\x64\pocketsphinx_continuous.exe -hmm zh_broadcastnews_ptm256_8000 -lm zh_broadcastnews_64000_utf8.DMP -dict zh_broadcastnews_utf8.dic -infile myfile-16000.wav > myfile.txt
  • 运行完毕后,查看 myfile.txt 文件,内容即是程序识别出来的中文。

猜你喜欢

转载自blog.csdn.net/kongxx/article/details/85595517