-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
run_personal_gmm.sh
executable file
·104 lines (86 loc) · 4.55 KB
/
run_personal_gmm.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
# Adapted from egs/rm/s5/run.sh
# Usage: run_personal_start.sh arpa_file openwebtext.arpa.gz --stage 0
# Required Inputs:
# conf/mfcc.conf
# data/train/{text,wav.scp,utt2spk}
# dict/{extra_questions.txt,lexiconp.txt,lexicon.txt,nonsilence_phones.txt,optional_silence.txt,silence_phones.txt}
# Writes To:
# data/local/dict/
# data/lang/
# exp/{make_mfcc,mono,mono_ali,tri1,tri1_ali,tri2b,tri2b_ali,tri3b}
set -ev
stage=0
endstage=99
nj=16
test_decoding=false
dataset=train
dict_dir=data/dict
arpa_file=
. utils/parse_options.sh # e.g. this parses the --stage option if supplied.
. ./path.sh
. ./cmd.sh
if [ $stage -le 0 ] && [ $endstage -ge 0 ]; then
# data preparation.
rm -f data/train/{spk2utt,feats.scp,cmvn.scp}
rm -rf data/local data/lang
utils/fix_data_dir.sh data/$dataset || exit 1;
# utils/utt2spk_to_spk2utt.pl data/$dataset/utt2spk > data/$dataset/spk2utt
featdir=mfcc
steps/make_mfcc.sh --nj $nj --cmd "$train_cmd" data/$dataset exp/make_mfcc/$dataset $featdir
# steps/make_mfcc.sh --nj $nj --cmd "$train_cmd" --allow-downsample true data/$dataset exp/make_mfcc/$dataset $featdir
steps/compute_cmvn_stats.sh data/$dataset exp/make_mfcc/$dataset $featdir
utils/validate_data_dir.sh data/$dataset
mkdir -p data/local/dict
cp $dict_dir/* data/local/dict/
utils/prepare_lang.sh data/local/dict "<unk>" data/local/lang data/lang
utils/validate_lang.pl data/lang
# if [ -z "$arpa_file" ]; then
# mkdir data/local/tmp
# ngram-count -order 3 -write-vocab data/local/tmp/vocab-full.txt -wbdiscount -text data/local/dict/corpus.txt -lm data/local/tmp/lm.arpa
# arpa2fst --disambig-symbol=#0 --read-symbol-table=data/lang/words.txt data/local/tmp/lm.arpa data/lang/G.fst
# # ../kenlm/lmplz --text dict/corpus.txt --arpa data/local/tmp/lm.arpa -S 50% -o 3
# else
# zcat -f "$arpa_file" | arpa2fst --disambig-symbol=#0 --read-symbol-table=data/lang/words.txt - data/lang/G.fst
# fi
fi
if [ $stage -le 1 ] && [ $endstage -ge 1 ]; then
# monophone
steps/train_mono.sh --nj $nj --cmd "$train_cmd" data/train data/lang exp/mono
# utils/mkgraph.sh data/lang exp/mono exp/mono/graph
fi
if [ $stage -le 2 ] && [ $endstage -ge 2 ]; then
# tri1 [first triphone pass]
steps/align_si.sh --nj $nj --cmd "$train_cmd" data/train data/lang exp/mono exp/mono_ali
steps/train_deltas.sh --cmd "$train_cmd" 1800 9000 data/train data/lang exp/mono_ali exp/tri1
# utils/mkgraph.sh data/lang exp/tri1 exp/tri1/graph
fi
if [ $stage -le 3 ] && [ $endstage -ge 3 ]; then
# tri2b [LDA+MLLT] aka "tri3"
steps/align_si.sh --nj $nj --cmd "$train_cmd" --use-graphs true data/train data/lang exp/tri1 exp/tri1_ali
steps/train_lda_mllt.sh --cmd "$train_cmd" --splice-opts "--left-context=3 --right-context=3" 1800 9000 data/train data/lang exp/tri1_ali exp/tri2b
# utils/mkgraph.sh data/lang exp/tri2b exp/tri2b/graph
fi
if [ $stage -le 4 ] && [ $endstage -ge 4 ]; then
# tri3b [LDA+MLLT+SAT] aka "tri4"?
steps/align_si.sh --nj $nj --cmd "$train_cmd" --use-graphs true data/train data/lang exp/tri2b exp/tri2b_ali
#????? steps/align_fmllr.sh --nj 8 --cmd "$train_cmd" --use-graphs true data/train data/lang exp/tri2b exp/tri2b_ali
steps/train_sat.sh 1800 9000 data/train data/lang exp/tri2b_ali exp/tri3b
# utils/mkgraph.sh data/lang exp/tri3b exp/tri3b/graph
# utils/mkgraph.sh data/lang_ug exp/tri3b exp/tri3b/graph_ug
# steps/decode_fmllr.sh --config conf/decode.config --nj 1 --num-threads 8 --cmd "$decode_cmd" exp/tri3b/graph_ug data/test exp/tri3b/decode_ug
# steps/cleanup/find_bad_utts.sh --nj 1 --cmd "$train_cmd" data/train data/lang exp/tri3b_ali exp/tri3b_cleanup
# head exp/tri3b_cleanup/all_info.sorted.txt
fi
# if [ $stage -le 5 ] && [ $endstage -ge 5 ]; then
# # tri3b_mmi [LDA+MLLT+SAT+MMI] aka "tri4_mmi"
# steps/align_fmllr.sh --nj $nj --cmd "$train_cmd" --use-graphs true data/train data/lang exp/tri3b exp/tri3b_ali
# steps/make_denlats.sh --config conf/decode.config --nj $nj --cmd "$train_cmd" --transform-dir exp/tri3b_ali data/train data/lang exp/tri3b exp/tri3b_denlats
# steps/train_mmi.sh data/train data/lang exp/tri3b_ali exp/tri3b_denlats exp/tri3b_mmi
# fi
# if [ $stage -le 8 ] && [ $endstage -ge 8 ]; then
# local/kaldi/run_personal_chain_tdnn_1h.sh --stage 0 --num-epochs 20
# fi
exit
# for x in exp/*/decode*; do [ -d $x ] && [[ $x =~ "$1" ]] && grep WER $x/wer_* | utils/best_wer.sh; done
# for x in exp/chain/*/decode*; do [ -d $x ] && [[ $x =~ "$1" ]] && grep WER $x/wer_* | utils/best_wer.sh; done