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

text2wfreq < weather.txt | wfreq2vocab > weather.tmp.vocab
 

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

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

根据代码

c.setString("-dict",
				"/sdcard/Android/data/edu/edu.cmu.pocketsphinx/lm/zh_CN/mandarin_notone.dic");
		c.setString("-lm",
				"/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目录,我的为

/workspace/VoiceRecognition/cmuclmtk-0.7# 

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

5. ./configure

6.make install

7.cd src

8.make install

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

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

 10.命令行下输入,

text2wfreq < weather.txt | wfreq2vocab > weather.tmp.vocab

  这时报错,如下

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.输入

text2idngram -vocab weather.tmp.vocab -idngram weather.idngram < weather.txt
 

12.输入

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,这三篇应该讲的很全面了。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值