kaldi timit实例运行全过程

来源:互联网 发布:电脑数据恢复好用吗? 编辑:程序博客网 时间:2024/06/05 06:49

第一步:准备timit的数据包
1.下载timit数据包,我已经上传到百度云盘—链接http://pan.baidu.com/s/1qYkDora
2.将timit数据包TIMIT.zip从Windows加载到linux服务器上(我用的服务器,当然你们可以用虚拟机)

  1. 打开SecureCRT,点击链接SFTP会话,(你需要提前将TIMIT.zip放在 文档所在的文件夹中)
    这里写图片描述

  2. 输入lls进入本机文档文件夹,看一下在不在里面,然后输入put TIMIT.zip将压缩包加载到远程服务器上面。
    这里写图片描述

  3. 然后把压缩包解压到对应的文件夹~/kaldi/egs/timit/s5/data

  4. 首先我们需要修改数据集的目录:

#timit=/export/corpora5/LDC/LDC93S1/timit/TIMIT # @JHU#timit=/mnt/matylda2/data/TIMIT/timit # @BUT# 上面两行是代码中原有的数据集位置,我们需要执行定制为下面的路径:timit=/home/yangqing/kaldi/egs/timit/s5/data/TIMIT

接下来 运行sudo ./run.sh

我出现了错误如下:

local/timit_prepare_dict.sh: Error: the IRSTLM is not available or compiledlocal/timit_prepare_dict.sh: Error: We used to install it by default, but.local/timit_prepare_dict.sh: Error: this is no longer the case.local/timit_prepare_dict.sh: Error: To install it, go to /home/yangqing/kaldi/egs/timit/s5/../../../toolslocal/timit_prepare_dict.sh: Error: and run extras/install_irstlm.sh

于是在网上找到三个解决方法针对不同的问题
1)“awk:line12:function gensub never defined”
解决: sudo apt-get install gawk

2)“Error: and run extras/install_irstlm.sh”
解决:因为这个例程建立语言模型是用irstlm工具建立的,但是在最新版本的kaldi里面,irstlm不是默认编译的。首先进入kaldi目录下的tools/extras目录,执行install_irstlm.sh脚本。安装完成以后,目录下出现irstlim目录。由于timit例程里面的引用irstlm工具的路径是tools目录,所以把这个目录拷贝到tools/目录下。回到egs/timit/s5目录,执行./run.sh脚本,于是timit例程就跑起来了。

3)“Error: the IRSTLM is not available or compiled”
解决:cd kaldi-master/tools/extras
./install_irstlm.sh
将生成的env.sh复制到tools文件夹下即可。

我用的是第三种方法,搞定

但是又出现也第二个错误:

error: qsub not found.

这是因为 TIMIT 的这个例子部署在多机器上,我们想要在本地运行所有的任务,需要修改 cmd.sh 中的内容:

# no GridEngineexport train_cmd=run.plexport decode_cmd=run.plexport cuda_cmd=run.plexport mkgraph_cmd=run.pl# 下面的内容均为多机器任务的命令,依赖 Sun GridEngine,我们注释掉所有的内容并使用上面的四行。# export train_cmd="queue.pl --mem 4G"# export decode_cmd="queue.pl --mem 4G"# export mkgraph_cmd="queue.pl --mem 8G"# the use of cuda_cmd is deprecated but it's still sometimes used in nnet1# example scripts.# export cuda_cmd="queue.pl --gpu 1"# if [ "$(hostname)" == "fit.vutbr.cz" ]; then#   #b) BUT cluster options#   queue="all.q@@blade,all.q@@speech"#   gpu_queue="long.q@@gpu"#   storage="matylda5"#   export train_cmd="queue.pl -q $queue -l ram_free=1.5G,mem_free=1.5G,${storage}=0.5"#   export decode_cmd="queue.pl -q $queue -l ram_free=2.5G,mem_free=2.5G,${storage}=0.1"#   export cuda_cmd="queue.pl -q $gpu_queue -l gpu=1"# fi

高人说上面前四行也可以改成

export train_cmd="run.pl --max-jobs-run 10"export decode_cmd="run.pl --max-jobs-run 10"export cuda_cmd="run.pl --max-jobs-run 2"export mkgraph_cmd="run.pl --max-jobs-run 10"

其中 max-jobs-run 限定了最大的运行线程数,如果你的机器CPU不是特别多,请一定加上这个条件,防止内存被耗尽。
至此,我们再重新运行./run.sh

使用Kaldi运行了timit的S5实例,只运行到了“tri3 : LDA + MLLT + SAT Training & Decoding”这一步,后面的”SGMM2”,”MMI+SGMM2”,”DNN + SGMM2”都没有运行成功,原因是在跑SGMM2的时候可能是由于机器配置不够,导致资源消耗完,就卡住了,此时内存占用率达到90%,我的主机是4G内存,分配给虚拟机是2G,以后想办法在更好的机器上跑一下。下面贴出tr3及其前面的tr2,tr1,单音素等的识别错误率,效果貌似还不错。
输入以下代码来看一下部分结果:

#!/bin/bashfor x in exp/{mono,tri,sgmm,dnn,combine}*/decode*; do [ -d $x ] && echo $x | grep "${1:-.*}" >/dev/null && grep WER $x/wer_* 2>/dev/null | utils/best_wer.sh; donefor x in exp/{mono,tri,sgmm,dnn,combine}*/decode*; do [ -d $x ] && echo $x | grep "${1:-.*}" >/dev/null && grep Sum $x/score_*/*.sys 2>/dev/null | utils/best_wer.sh; done

得到结果如下(真的很容易挂掉,这个贴的@零落_World的,在此致谢)

%WER 33.10 [ 4984 / 15057, 398 ins, 1673 del, 2913 sub ] exp/mono/decode_dev/wer_3  %WER 34.05 [ 2457 / 7215, 186 ins, 839 del, 1432 sub ] exp/mono/decode_test/wer_3 %WER 28.98 [ 4363 / 15057, 547 ins, 1244 del, 2572 sub ] exp/tri1/decode_dev/wer_6  %WER 30.71 [ 2216 / 7215, 328 ins, 588 del, 1300 sub ] exp/tri1/decode_test/wer_5 %WER 26.41 [ 3977 / 15057, 487 ins, 1150 del, 2340 sub ] exp/tri2/decode_dev/wer_6  %WER 27.36 [ 1974 / 7215, 178 ins, 685 del, 1111 sub ] exp/tri2/decode_test/wer_8  %WER 23.32 [ 3511 / 15057, 480 ins, 1002 del, 2029 sub ] exp/tri3/decode_dev/wer_4  %WER 26.98 [ 4062 / 15057, 552 ins, 1092 del, 2418 sub ] exp/tri3/decode_dev.si/wer_5 好啦,最后终于跑起来了,接下来就是读脚本啦
原创粉丝点击