- 浏览: 198087 次
- 性别:
- 来自: 武汉
-
最新评论
-
haha220688:
我已经解决了lm和dic文件不能识别的问题,使用notepad ...
Android平台使用PocketSphinx做离线语音识别,小范围语音99%识别率 -
740051022:
lyt1993 写道pi_jom 写道楼主,你好,请问APK闪 ...
Android平台使用PocketSphinx做离线语音识别,小范围语音99%识别率 -
lyt1993:
pi_jom 写道楼主,你好,请问APK闪退怎么回事请问你解决 ...
Android平台使用PocketSphinx做离线语音识别,小范围语音99%识别率 -
Camain:
楼主你好,我想请教一下PocketSphinx的demo在我不 ...
Android平台使用PocketSphinx做离线语音识别,小范围语音99%识别率 -
pi_jom:
楼主,你好,请问APK闪退怎么回事
Android平台使用PocketSphinx做离线语音识别,小范围语音99%识别率
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,这三篇应该讲的很全面了。
评论
当在cygwin中输入text2wfreq < weather.txt | wfreq2vocab > weather.tmp.vocab后
出现
-bash: weather.txt: No such file or directory
wfreq2vocab : Will generate a vocabulary containing the most
frequent 20000 words. Reading wfreq stream from stdin...
Warning : Vocab size = 0.
wfreq2vocab : Done.是怎么回事啊

自己解决了,Demo也跑起来了,谢谢!

log:
INFO: cmd_ln.c(691): Parsing command line:
Current configuration:
[NAME] [DEFLT] [VALUE]
-agc none none
-agcthresh 2.0 2.000000e+00
-alpha 0.97 9.700000e-01
-ascale 20.0 2.000000e+01
-aw 1 1
-backtrace no no
-beam 1e-48 1.000000e-48
-bestpath yes yes
-bestpathlw 9.5 9.500000e+00
-bghist no no
-ceplen 13 13
-cmn current current
-cmninit 8.0 8.0
-compallsen no no
-debug 0
-dict
-dictcase no no
-dither no no
-doublebw no no
-ds 1 1
-fdict
-feat 1s_c_d_dd 1s_c_d_dd
-featparams
-fillprob 1e-8 1.000000e-08
-frate 100 100
-fsg
-fsgusealtpron yes yes
-fsgusefiller yes yes
-fwdflat yes yes
-fwdflatbeam 1e-64 1.000000e-64
-fwdflatefwid 4 4
-fwdflatlw 8.5 8.500000e+00
-fwdflatsfwin 25 25
-fwdflatwbeam 7e-29 7.000000e-29
-fwdtree yes yes
-hmm
-input_endian little little
-jsgf
-kdmaxbbi -1 -1
-kdmaxdepth 0 0
-kdtree
-latsize 5000 5000
-lda
-ldadim 0 0
-lextreedump 0 0
-lifter 0 0
-lm
-lmctl
-lmname default default
-logbase 1.0001 1.000100e+00
-logfn
-logspec no no
-lowerf 133.33334 1.333333e+02
-lpbeam 1e-40 1.000000e-40
-lponlybeam 7e-29 7.000000e-29
-lw 6.5 6.500000e+00
-maxhmmpf -1 -1
-maxnewoov 20 20
-maxwpf -1 -1
-mdef
-mean
-mfclogdir
-min_endfr 0 0
-mixw
-mixwfloor 0.0000001 1.000000e-07
-mllr
-mmap yes yes
-ncep 13 13
-nfft 512 512
-nfilt 40 40
-nwpen 1.0 1.000000e+00
-pbeam 1e-48 1.000000e-48
-pip 1.0 1.000000e+00
-pl_beam 1e-10 1.000000e-10
-pl_pbeam 1e-5 1.000000e-05
-pl_window 0 0
-rawlogdir
-remove_dc no no
-round_filters yes yes
-samprate 16000 1.600000e+04
-seed -1 -1
-sendump
-senlogdir
-senmgau
-silprob 0.005 5.000000e-03
-smoothspec no no
-svspec
-tmat
-tmatfloor 0.0001 1.000000e-04
-topn 4 4
-topn_beam 0 0
-toprule
-transform legacy legacy
-unit_area yes yes
-upperf 6855.4976 6.855498e+03
-usewdphones no no
-uw 1.0 1.000000e+00
-var
-varfloor 0.0001 1.000000e-04
-varnorm no no
-verbose no no
-warp_params
-warp_type inverse_linear inverse_linear
-wbeam 7e-29 7.000000e-29
-wip 0.65 6.500000e-01
-wlen 0.025625 2.562500e-02
INFO: cmd_ln.c(691): Parsing command line:
\
-nfilt 20 \
-lowerf 1 \
-upperf 4000 \
-wlen 0.025 \
-transform dct \
-round_filters no \
-remove_dc yes \
-feat 1s_c_d_dd \
-svspec 0-12/13-25/26-38 \
-agc none \
-cmn current \
-cmninit 54,-1,2 \
-varnorm no
Current configuration:
[NAME] [DEFLT] [VALUE]
-agc none none
-agcthresh 2.0 2.000000e+00
-alpha 0.97 9.700000e-01
-ceplen 13 13
-cmn current current
-cmninit 8.0 54,-1,2
-dither no no
-doublebw no no
-feat 1s_c_d_dd 1s_c_d_dd
-frate 100 100
-input_endian little little
-lda
-ldadim 0 0
-lifter 0 0
-logspec no no
-lowerf 133.33334 1.000000e+00
-ncep 13 13
-nfft 512 512
-nfilt 40 20
-remove_dc no yes
-round_filters yes no
-samprate 16000 8.000000e+03
-seed -1 -1
-smoothspec no no
-svspec 0-12/13-25/26-38
-transform legacy dct
-unit_area yes yes
-upperf 6855.4976 4.000000e+03
-varnorm no no
-verbose no no
-warp_params
-warp_type inverse_linear inverse_linear
-wlen 0.025625 2.500000e-02
INFO: acmod.c(242): Parsed model-specific feature parameters from /sdcard/Android/data/test/hmm/tdt_sc_8k/feat.params
INFO: feat.c(684): Initializing feature stream to type: '1s_c_d_dd', ceplen=13, CMN='current', VARNORM='no', AGC='none'
INFO: cmn.c(142): mean[0]= 12.00, mean[1..12]= 0.0
INFO: acmod.c(163): Using subvector specification 0-12/13-25/26-38
INFO: mdef.c(520): Reading model definition: /sdcard/Android/data/test/hmm/tdt_sc_8k/mdef
INFO: mdef.c(531): Found byte-order mark BMDF, assuming this is a binary mdef file
INFO: bin_mdef.c(330): Reading binary model definition: /sdcard/Android/data/test/hmm/tdt_sc_8k/mdef
INFO: bin_mdef.c(507): 70 CI-phone, 65021 CD-phone, 3 emitstate/phone, 210 CI-sen, 5210 Sen, 11271 Sen-Seq
INFO: tmat.c(205): Reading HMM transition probability matrices: /sdcard/Android/data/test/hmm/tdt_sc_8k/transition_matrices
INFO: acmod.c(117): Attempting to use SCHMM computation module
INFO: ms_gauden.c(198): Reading mixture gaussian parameter: /sdcard/Android/data/test/hmm/tdt_sc_8k/means
INFO: ms_gauden.c(292): 1 codebook, 3 feature, size:
INFO: ms_gauden.c(294): 256x13
INFO: ms_gauden.c(294): 256x13
INFO: ms_gauden.c(294): 256x13
INFO: ms_gauden.c(198): Reading mixture gaussian parameter: /sdcard/Android/data/test/hmm/tdt_sc_8k/variances
INFO: ms_gauden.c(292): 1 codebook, 3 feature, size:
INFO: ms_gauden.c(294): 256x13
INFO: ms_gauden.c(294): 256x13
INFO: ms_gauden.c(294): 256x13
INFO: ms_gauden.c(354): 0 variance values floored
INFO: s2_semi_mgau.c(908): Loading senones from dump file /sdcard/Android/data/test/hmm/tdt_sc_8k/sendump
INFO: s2_semi_mgau.c(932): BEGIN FILE FORMAT DESCRIPTION
INFO: s2_semi_mgau.c(1027): Using memory-mapped I/O for senones
INFO: s2_semi_mgau.c(1304): Maximum top-N: 4 Top-N beams: 0 0 0
INFO: phone_loop_search.c(105): State beam -230231 Phone exit beam -115115 Insertion penalty 0
INFO: dict.c(306): Allocating 4107 * 20 bytes (80 KiB) for word entries
INFO: dict.c(321): Reading main dictionary: /sdcard/Android/data/test/lm/test.dic
ERROR: "dict.c", line 194: Line 1: Phone 'EH' is mising in the acoustic model; word '<S>不好</S>' ignored
ERROR: "dict.c", line 194: Line 2: Phone 'EH' is mising in the acoustic model; word '<S>好</S>' ignored
ERROR: "dict.c", line 194: Line 3: Phone 'EH' is mising in the acoustic model; word '<S>小赖</S>' ignored
ERROR: "dict.c", line 194: Line 4: Phone 'EH' is mising in the acoustic model; word '<S>祝东芝</S>' ignored
INFO: dict.c(212): Allocated 0 KiB for strings, 0 KiB for phones
INFO: dict.c(324): 0 words read
INFO: dict.c(330): Reading filler dictionary: /sdcard/Android/data/test/hmm/tdt_sc_8k/noisedict
INFO: dict.c(212): Allocated 0 KiB for strings, 0 KiB for phones
INFO: dict.c(333): 7 words read
INFO: dict2pid.c(396): Building PID tables for dictionary
INFO: dict2pid.c(404): Allocating 70^3 * 2 bytes (669 KiB) for word-initial triphones
INFO: dict2pid.c(131): Allocated 59080 bytes (57 KiB) for word-final triphones
INFO: dict2pid.c(195): Allocated 59080 bytes (57 KiB) for single-phone word triphones
INFO: ngram_model_arpa.c(477): ngrams 1=6, 2=8, 3=4
INFO: ngram_model_arpa.c(135): Reading unigrams
INFO: ngram_model_arpa.c(516): 6 = #unigrams created
INFO: ngram_model_arpa.c(195): Reading bigrams
INFO: ngram_model_arpa.c(533): 8 = #bigrams created
INFO: ngram_model_arpa.c(534): 3 = #prob2 entries
INFO: ngram_model_arpa.c(542): 3 = #bo_wt2 entries
INFO: ngram_model_arpa.c(292): Reading trigrams
INFO: ngram_model_arpa.c(555): 4 = #trigrams created
INFO: ngram_model_arpa.c(556): 2 = #prob3 entries
INFO: ngram_search_fwdtree.c(99): 0 unique initial diphones
INFO: ngram_search_fwdtree.c(147): 0 root, 0 non-root channels, 8 single-phone words
INFO: ngram_search_fwdtree.c(186): Creating search tree
INFO: ngram_search_fwdtree.c(191): before: 0 root, 0 non-root channels, 8 single-phone words
INFO: ngram_search_fwdtree.c(326): after: max nonroot chan increased to 128
ERROR: "ngram_search_fwdtree.c", line 336: No word from the language model has pronunciation in the dictionary
INFO: ngram_search_fwdtree.c(338): after: 0 root, 0 non-root channels, 7 single-phone words
INFO: ngram_search_fwdflat.c(156): fwdflat: min_ef_width = 4, max_sf_win = 25
INFO: pocketsphinx.c(299): zslog use ngs
发表评论
-
Android调用webservice代码生成工具
2013-12-09 15:22 1406基于ksoap2 http://www.wsdl2code ... -
科大讯飞开发包进行代码混淆后不可用
2013-06-17 12:05 4108使用科大讯飞android开发sdk SpeechApi.j ... -
调用Google手机版语音识别服务
2013-04-12 16:16 4348转载请注明出处 项目代码https://github.c ... -
Andriod逆向学习笔记
2013-03-26 11:37 5034转载请注明出处 前段时间玩《吃货大食堂》,不知从哪个应用 ... -
java aes cfb 256加密
2013-03-04 16:20 8913调过一个加密程序,后台用c++ openssl aes c ... -
android跨进程事件注入(程序模拟用户输入)
2013-01-25 11:42 43875转载请注明出处 早想写这篇,一直没空,现在总结下。需求: ... -
android监听软键盘+吐槽!
2013-01-24 17:33 8332要实现个需求,有个edi ... -
google streaming voice recognition分析
2012-12-20 20:38 3306chrome用到了google的语音识别webs ... -
android+mina 开发环境搭建
2012-06-19 00:59 4209最近研究mina开发,项目架构c/s模式,c是android, ... -
Android平台使用PocketSphinx做离线语音识别,小范围语音99%识别率
2012-03-26 11:17 61055最近语音识别很火,但是都是用的在线语音识别,研究了一下离 ... -
Android 源码开发调试方法
2011-12-29 17:47 7727最近忙修改Launcher,不知道大家都是怎么做开发和调试的, ...
相关推荐
在Android平台上实现离线语音识别是一项技术挑战,但PocketSphinx提供了一种高效且实用的解决方案。PocketSphinx是一款开源的、轻量级的语音识别引擎,特别适合于移动设备和资源有限的环境。它是由Carnegie Mellon ...
PocketSphinx是一款开源的、轻量级的语音识别引擎,主要由Carnegie Mellon University的CSL(计算机科学实验室)开发。它主要用于离线语音识别,尤其适合在资源有限的设备上,比如嵌入式系统或者移动应用。这个...
本文将详细介绍这两种方式,并结合Google Voice和PocketSphinx等工具和技术,深入探讨Android语音识别的实现方法。 二、语音识别技术基础 1.语音识别技术含义 语音识别技术是一种模式识别的过程,主要包含两个...
PocketSphinx是CMU Sphinx语音识别引擎的一个轻量级版本,特别适合于移动设备。它不需要网络连接,可以在本地处理音频数据,从而快速响应用户的语音输入。它的主要优点包括低功耗、快速响应以及对特定词汇集的高识别...
1. **源代码**:解压后的文件通常包含Java源代码,这些代码展示了如何在Android应用中集成PocketSphinx库,包括初始化语音识别器、设置监听器以及处理识别结果。 2. **资源文件**:项目可能包含语言模型(.lm)、...