`

【转】Android本地语音识别引擎PocketSphinx-语言建模

 
阅读更多
Java代码  收藏代码
  1. text2wfreq < weather.txt | wfreq2vocab > weather.tmp.vocab  
 

最近研究Android上的语音识别,在此记录下遇到的问题。

先引用一篇博文,http://leiwuluan.iteye.com/blog/1287305。根据这篇博文的内容,要是没遇到问题的话,应该可以生成一个apk,在手机上可以运行,能进行识别,但是效率很低,识别率也不咋地。现在我们需要自己来构建识别的库。

根据代码

Java代码  收藏代码
  1. c.setString("-dict",  
  2.                 "/sdcard/Android/data/edu/edu.cmu.pocketsphinx/lm/zh_CN/mandarin_notone.dic");  
  3.         c.setString("-lm",  
  4.                 "/sdcard/Android/data/edu/edu.cmu.pocketsphinx/lm/zh_CN/gigatdt.5000.DMP");  

 程序会引用到两个文件,第一个是字典文件,第二个是声音模型文件,程序先将输入的声音和声音模型文件对比,生成音节编码,再将音节编码在字典中查找,返回最后的字符结果。Sphinx是个很完善的引擎,除了开源之外,官方还提供了各种工具供开发者构建自己的声音对比模型,字典,记忆语言模型。本文参考http://cmusphinx.sourceforge.net/wiki/tutoriallm,用CMUCLMTK构建自己的语言模型。

1.首先,假设你已经根据本文开头的那篇博文成功编译了PocketSphinx并且成功在手机上运行。

2.下载CMUCLMTK,http://sourceforge.net/projects/cmusphinx/files/cmuclmtk/0.7/cmuclmtk-0.7.tar.gz/download

3.将下载的文件解压到Sphinx根目录,参见开篇引用博文。

4.命令行下进入到CMUCLMTK目录,我的为

Java代码  收藏代码
  1. /workspace/VoiceRecognition/cmuclmtk-0.7#   

我的电脑系统是linux,如果是windows需要用cgwin

5. ./configure

6.make install

7.cd src

8.make install

9.在4的目录下,新建weather.txt,输入

Java代码  收藏代码
  1. <s> generally cloudy today with scattered outbreaks of rain and drizzle persistent and heavy at times </s>  
  2. <s> some dry intervals also with hazy sunshine especially in eastern parts in the morning </s>  
  3. <s> highest temperatures nine to thirteen Celsius in a light or moderate mainly east south east breeze </s>  
  4. <s> cloudy damp and misty today with spells of rain and drizzle in most places much of this rain will be   
  5. light and patchy but heavier rain may develop in the west later </s>  

 10.命令行下输入,

Java代码  收藏代码
  1. text2wfreq < weather.txt | wfreq2vocab > weather.tmp.vocab  

  这时报错,如下

Java代码  收藏代码
  1. text2wfreq: error while loading shared libraries: libcmuclmtk.so.0: cannot open shared object file: No such file or directory  

 参考error while loading shared libraries解决。

11.输入

Java代码  收藏代码
  1. text2idngram -vocab weather.tmp.vocab -idngram weather.idngram < weather.txt  
 

12.输入

Java代码  收藏代码
  1. idngram2lm -vocab_type 0 -idngram weather.idngram -vocab weather.tmp.vocab -arpa weather.arpa  

 如果无误,在目录下会生成weather.tmp.DMP文件。

官网说在http://www.speech.cs.cmu.edu/tools/lmtool.html也可以在线提交txt文件,在服务器生成DMP文件,但是我在试的时候,发现访问不了,可能是太多人用了,CMU把这个服务给关了?

 

哈哈,在查资料的时候,又发现有这方面的博文,再引用一下,http://www.cnblogs.com/huanghuang/archive/2011/07/14/2106579.html,http://archive.cnblogs.com/a/2111834/,http://www.cnblogs.com/huanghuang/archive/2011/07/18/2109101.html,这三篇应该讲的很全面了。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics