`

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

分享到:
评论

相关推荐

    Android平台使用PocketSphinx做离线语音识别,小范围语音99%识别率.rar

    在Android平台上实现离线语音识别是一项技术挑战,但PocketSphinx提供了一种高效且实用的解决方案。PocketSphinx是一款开源的、轻量级的语音识别引擎,特别适合于移动设备和资源有限的环境。它是由Carnegie Mellon ...

    PocketSphinxDemo

    PocketSphinx是一款开源的、轻量级的语音识别引擎,主要由Carnegie Mellon University的CSL(计算机科学实验室)开发。它主要用于离线语音识别,尤其适合在资源有限的设备上,比如嵌入式系统或者移动应用。这个...

    Android 语音识别研究

    本文将详细介绍这两种方式,并结合Google Voice和PocketSphinx等工具和技术,深入探讨Android语音识别的实现方法。 二、语音识别技术基础 1.语音识别技术含义 语音识别技术是一种模式识别的过程,主要包含两个...

    安卓Andriod源码——平台使用PocketSphinx做离线语音识别,小范围语音99%识别率.zip

    PocketSphinx是CMU Sphinx语音识别引擎的一个轻量级版本,特别适合于移动设备。它不需要网络连接,可以在本地处理音频数据,从而快速响应用户的语音输入。它的主要优点包括低功耗、快速响应以及对特定词汇集的高识别...

    PocketSphinxAndroidDemo.rar

    1. **源代码**:解压后的文件通常包含Java源代码,这些代码展示了如何在Android应用中集成PocketSphinx库,包括初始化语音识别器、设置监听器以及处理识别结果。 2. **资源文件**:项目可能包含语言模型(.lm)、...

Global site tag (gtag.js) - Google Analytics