yesorno案例

s5/run.sh為完整腳本,下面分別解析每個步驟

1. 指定訓(xùn)練/解碼腳本

-d 判斷是否為目錄 更多命令
命令之間使用 || 連接,實現(xiàn)邏輯或的功能。 linux中的分號&&和&,|和||說明與用法

只有在 || 左邊的命令返回假(命令返回值$? == 1),|| 右邊的命令才會被執(zhí)行。這和 c 語言中的邏輯或語法功能相同,即實現(xiàn)短路邏輯或操作。
只要有一個命令返回真(命令返回值 $? == 0),后面的命令就不會被執(zhí)行。 –直到返回真的地方停止執(zhí)行。

如果沒有數(shù)據(jù),下載+解壓

#!/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

2. 數(shù)據(jù)準備

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

2.1 prepare_data.sh

create_yesno_waves_test_train.pl 輸出路徑 ./kaldi/egs/yesno/s5/data/local

../../local/create_yesno_waves_test_train.pl waves_all.list waves.test waves.train

三個參數(shù):第一個全路徑,第二個test,第三個train
功能:讀取全部文件,一半訓(xùn)練一半測試

chomp($l); #  perl函數(shù),去掉換行符

create_yesno_wav_scp.pl / create_yesno_txt.pl 處理各種文件路徑

2.2 prepare_dict.sh

準備詞匯表,不發(fā)聲的SIL

2.3 prepare_lang.sh

準備語言模型

3. 特征提取

# 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 # Compute cepstral mean and variance statistics per speaker.
 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

4. 訓(xùn)練

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

5. 生成HCLG圖

utils/mkgraph.sh data/lang_test_tg exp/mono0a exp/mono0a/graph_tgpr

6. 解碼

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

7.評估

for x in exp/*/decode*; do [ -d $x ] && grep WER $x/wer_* | utils/best_wer.sh; done

結(jié)果可視化

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容