基于V3S的语音助手(三)移植pocketsphnix关键词唤醒

1.需要准备的资源:

  1. pocketsphnix源文件
  2. sphinxbase源文件
  3. 若要编译python版本需要自己安装python

2.编译sphinxbase:

1.新建一个work文件夹来放生成的文件夹 prefix为work路径
2.配置
如果要编译python库 则需要将在下面的配置后增加 (两个路径为编译好的python库和头文件路径) --enable-shared CFLAGS=-I/home/book/lichee/model/python/Python-3.6.8/work/include/python3.6m LDFLAGS=-L/home/book/lichee/model/python/Python-3.6.8/work/lib
不用则在末尾添加--without-python

./configure CC=arm-linux-gnueabihf-gcc CXX=CC=arm-linux-gnueabihf-g++ --host=arm-linux-gnueabihf --prefix=/home/book/lichee/model/voice_pr/sphinxbase-master/work --build=x86_64-linux-gnu --target=arm-linux-gnueabihf 
3.编译
make
4.安装
make install

2.编译pocketsphnix:

1.新建一个work文件夹来放生成的文件夹 prefix为work路径
2.配置
如果要编译python库 和上面一样 但是这次需要在上面的方法上增加一个sphinxbase头文件和库路径(就是上面的那个work的路径),以下是配置好python的配置:

./configure CC=arm-linux-gnueabihf-gcc CXX=CC=arm-linux-gnueabihf-g++ --host=arm-linux-gnueabihf --prefix=/home/book/lichee/model/voice_pr/pocketsphinx-master/work --build=x86_64-linux-gnu --target=arm-linux-gnueabihf --enable-shared CFLAGS=-I/home/book/lichee/model/voice_pr/sphinxbase-master/work/include -I/home/book/lichee/model/python/Python-3.6.8/work/include/python3.6m LDFLAGS=-L/home/book/lichee/model/voice_pr/sphinxbase-master/work/lib -L/home/book/lichee/model/python/Python-3.6.8/work/lib
3.编译
make
4.安装
make install

3.去生成关键词模型:

  1. 先建立一个lucky.txt:
  2. 里面写入:
    lucky
    ok
    konw
  3. 上传文件到:http://www.speech.cs.cmu.edu/tools/lmtool.html 生成模型(其中lm,dit为所需文件)
    4.下载解压 把文件放入板子

4.烧录:

  1. 将两个编译生成的bin文件都放到usr/bin 和usr/lib中
  2. 启动板子看看输入pocketsphinx_continuous是否有反应若有说明成功了
  3. 如果没有则再把生成的work文件夹都放入板子(行不行都要把生成的work全部放入板子里面有模型)
  4. 再进入pocketsphinx的work/bin的使用 ./pocketsphinx_continuous看是否有反应

5.使用pocketsphinx:

1.打开声卡 参考之前mplayer(tinyalsa)的文章,我是写了个bin ./audio_init.sh就可以启动
2.使用以下命令进行测试:
lm后是你生成的lm文件 dict后是生成的dict文件 -hmm是你生成的文件的work/share/pocketsphinx/model/en-us/en-us

./pocketsphinx_continuous -lm /root/project/wakevoice/lucky.lm -dict /root/project/wakevoice/lucky.dic  -hmm /root/pocketsphinx/share/pocketsphinx/model/en-us/en-us -inmic yes

就可以使用了如果要用文件可把-inmic yes 用-infile /文件路径
出现:

INFO: continuous.c(252): Ready....
INFO: continuous.c(261): Listening...
INFO: cmn_live.c(120): Update from < 41.00 -5.29 -0.12  5.09  2.48 -4.07 -1.37 -1.78 -5.08 -2.05 -6.45 -1.42  1.17 >
INFO: cmn_live.c(138): Update to   < 39.28  0.17 -4.00  9.79 -8.77 -6.09  1.04 -14.10 -5.12 -12.24 12.37 -9.29 -2.45 >
INFO: ngram_search_fwdtree.c(1550):      410 words recognized (4/fr)
INFO: ngram_search_fwdtree.c(1552):     8402 senones evaluated (76/fr)
INFO: ngram_search_fwdtree.c(1556):     4244 channels searched (38/fr), 308 1st, 3653 last
INFO: ngram_search_fwdtree.c(1559):      554 words for which last channels evaluated (4/fr)
INFO: ngram_search_fwdtree.c(1561):       54 candidate words for entering last phone (0/fr)
INFO: ngram_search_fwdtree.c(1564): fwdtree 0.80 CPU 0.718 xRT
INFO: ngram_search_fwdtree.c(1567): fwdtree 3.28 wall 2.954 xRT
INFO: ngram_search_fwdflat.c(302): Utterance vocabulary contains 5 words
INFO: ngram_search_fwdflat.c(948):      410 words recognized (4/fr)
INFO: ngram_search_fwdflat.c(950):    10437 senones evaluated (94/fr)
INFO: ngram_search_fwdflat.c(952):     6048 channels searched (54/fr)
INFO: ngram_search_fwdflat.c(954):      748 words searched (6/fr)
INFO: ngram_search_fwdflat.c(957):      180 word transitions (1/fr)
INFO: ngram_search_fwdflat.c(960): fwdflat 0.31 CPU 0.282 xRT
INFO: ngram_search_fwdflat.c(963): fwdflat 0.31 wall 0.283 xRT
INFO: ngram_search.c(1250): lattice start node <s>.0 end node </s>.88
INFO: ngram_search.c(1276): Eliminated 2 nodes before end node
INFO: ngram_search.c(1381): Lattice has 141 nodes, 86 links
INFO: ps_lattice.c(1376): Bestpath score: -1868
INFO: ps_lattice.c(1380): Normalizer P(O) = alpha(</s>:88:109) = -103717
INFO: ps_lattice.c(1437): Joint P(O,S) = -111824 P(S|O) = -8107
INFO: ngram_search.c(872): bestpath 0.00 CPU 0.001 xRT
INFO: ngram_search.c(875): bestpath 0.00 wall 0.001 xRT
LUCKY

则识别到了这个上面还会有配置的值的显示 因为太长就不显示了

6.预告下一篇为利用python 进行语音唤醒

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐