kaldi源码中run.sh脚本分析

xiaoxiao2021-02-28  7

以egs/yesno/s5中的运行脚本为例,进行分析

1. run.sh脚本

内容如下

#!/bin/bash train_cmd="utils/run.pl" decode_cmd="utils/run.pl" if [ ! -d waves_yesno ]; then wget http://www.openslr.org/resources/1/waves_yesno.tar.gz || exit 1; # was: # wget http://sourceforge.net/projects/kaldi/files/waves_yesno.tar.gz || exit 1; tar -xvzf waves_yesno.tar.gz || exit 1; fi train_yesno=train_yesno test_base_name=test_yesno rm -rf data exp mfcc # Data preparation local/prepare_data.sh waves_yesno local/prepare_dict.sh utils/prepare_lang.sh --position-dependent-phones false data/local/dict "<SIL>" data/local/lang data/lang local/prepare_lm.sh # Feature extraction for x in train_yesno test_yesno; do steps/make_mfcc.sh --nj 1 data/$x exp/make_mfcc/$x mfcc steps/compute_cmvn_stats.sh data/$x exp/make_mfcc/$x mfcc utils/fix_data_dir.sh data/$x done # Mono training steps/train_mono.sh --nj 1 --cmd "$train_cmd" \ --totgauss 400 \ data/train_yesno data/lang exp/mono0a # Graph compilation utils/mkgraph.sh data/lang_test_tg exp/mono0a exp/mono0a/graph_tgpr # Decoding steps/decode.sh --nj 1 --cmd "$decode_cmd" \ exp/mono0a/graph_tgpr data/test_yesno exp/mono0a/decode_test_yesno for x in exp/*/decode*; do [ -d $x ] && grep WER $x/wer_* | utils/best_wer.sh; done 若waves_yesno文件不存在,则通过wget先下载waves_yesno.tar.gz,并解压。

然后定义两个变量

train_yesno=train_yesno test_base_name=test_yesno

删除data,exp,mfcc

进行数据预处理

local/prepare_data.sh waves_yesno local/prepare_dict.sh utils/prepare_lang.sh --position-dependent-phones false data/local/dict "<SIL>" data/local/lang data/lang local/prepare_lm.sh

提取特征

for x in train_yesno test_yesno; do steps/make_mfcc.sh --nj 1 data/$x exp/make_mfcc/$x mfcc steps/compute_cmvn_stats.sh data/$x exp/make_mfcc/$x mfcc utils/fix_data_dir.sh data/$x done 模型训练

steps/train_mono.sh --nj 1 --cmd "$train_cmd" \ --totgauss 400 \ data/train_yesno data/lang exp/mono0a

解码

steps/decode.sh --nj 1 --cmd "$decode_cmd" \ exp/mono0a/graph_tgpr data/test_yesno exp/mono0a/decode_test_yesno

转载请注明原文地址: https://www.6miu.com/read-1100206.html

最新回复(0)