run_mdm.sh 5.39 KB
Newer Older
1 2 3 4 5
#!/bin/bash -u

. ./cmd.sh
. ./path.sh

6 7
# MDM - Multiple Distant Microphones
# Assuming text preparation, dict, lang and LM were build as in run_ihm
8

9 10
nmics=8 #we use all 8 channels, possible other options are 2 and 4
mic=mdm$nmics #subdir name under data/
11 12
AMI_DIR=/disk/data2/amicorpus #root of AMI corpus
MDM_DIR=/disk/data1/s1136550/ami/mdm #directory for beamformed waves
13

14
#1) Download AMI (distant channels)
15

16
local/ami_download.sh mdm $AMI_DIR
17

18
#2) Beamform 
19

20
local/ami_beamform.sh --nj 16 $nmics $AMI_DIR $MDM_DIR
21

22
#3) Prepare mdm data directories
23

24 25 26
local/ami_mdm_data_prep.sh $MDM_DIR $mic || exit 1;
local/ami_mdm_scoring_data_prep.sh $MDM_DIR $mic dev || exit 1;
local/ami_mdm_scoring_data_prep.sh $MDM_DIR $mic eval || exit 1;
27

28 29 30
#use the final LM
final_lm=`cat data/local/lm/final_lm`
LM=$final_lm.pr1-7
31

32 33
DEV_SPK=`cut -d" " -f2 data/$mic/dev/utt2spk | sort | uniq -c | wc -l`
EVAL_SPK=`cut -d" " -f2 data/$mic/eval/utt2spk | sort | uniq -c | wc -l`
34
nj=16
35

36 37 38 39 40 41 42 43 44 45 46
#GENERATE FEATS
mfccdir=mfcc_$mic
(
steps/make_mfcc.sh --nj 5  --cmd "$train_cmd" data/$mic/eval exp/$mic/make_mfcc/eval $mfccdir || exit 1;
steps/compute_cmvn_stats.sh data/$mic/eval exp/$mic/make_mfcc/eval $mfccdir || exit 1
)&
(
steps/make_mfcc.sh --nj 5 --cmd "$train_cmd" data/$mic/dev exp/$mic/make_mfcc/dev $mfccdir || exit 1;
steps/compute_cmvn_stats.sh data/$mic/dev exp/$mic/make_mfcc/dev $mfccdir || exit 1
)&
(
47
steps/make_mfcc.sh --nj 16 --cmd "$train_cmd" data/$mic/train exp/$mic/make_mfcc/train $mfccdir || exit 1;
48 49 50 51
 steps/compute_cmvn_stats.sh data/$mic/train exp/$mic/make_mfcc/train $mfccdir || exit 1
)&

wait;
52
for dset in train eval dev; do utils/fix_data_dir.sh data/$mic/$dset; done
53

54 55 56
# Build the systems

# TRAIN THE MODELS
57
 mkdir -p exp/$mic/mono
58
 steps/train_mono.sh --nj $nj --cmd "$train_cmd" --feat-dim 39 \
59 60 61
   data/$mic/train data/lang exp/$mic/mono >& exp/$mic/mono/train_mono.log || exit 1;

 mkdir -p exp/$mic/mono_ali
62
 steps/align_si.sh --nj $nj --cmd "$train_cmd" data/$mic/train data/lang exp/$mic/mono \
63 64 65 66 67 68 69 70
   exp/$mic/mono_ali >& exp/$mic/mono_ali/align.log || exit 1;

 mkdir -p exp/$mic/tri1
 steps/train_deltas.sh --cmd "$train_cmd" \
   5000 80000 data/$mic/train data/lang exp/$mic/mono_ali exp/$mic/tri1 \
   >& exp/$mic/tri1/train.log || exit 1;

 mkdir -p exp/$mic/tri1_ali
71
 steps/align_si.sh --nj $nj --cmd "$train_cmd" \
72 73 74 75 76 77
   data/$mic/train data/lang exp/$mic/tri1 exp/$mic/tri1_ali || exit 1;

 mkdir -p exp/$mic/tri2a
 steps/train_deltas.sh --cmd "$train_cmd" \
  5000 80000 data/$mic/train data/lang exp/$mic/tri1_ali exp/$mic/tri2a \
  >& exp/$mic/tri2a/train.log || exit 1;
78

79
 for lm_suffix in $LM; do
80 81 82 83
  (
    graph_dir=exp/$mic/tri2a/graph_${lm_suffix}
    $highmem_cmd $graph_dir/mkgraph.log \
      utils/mkgraph.sh data/lang_${lm_suffix} exp/$mic/tri2a $graph_dir
84

85
    steps/decode.sh --nj $DEV_SPK --cmd "$decode_cmd" --config conf/decode.conf \
86
      $graph_dir data/$mic/dev exp/$mic/tri2a/decode_dev_${lm_suffix}
87

88
    steps/decode.sh --nj $EVAL_SPK --cmd "$decode_cmd" --config conf/decode.conf \
89 90
      $graph_dir data/$mic/eval exp/$mic/tri2a/decode_eval_${lm_suffix}
  )
91 92 93 94
 done

#THE TARGET LDA+MLLT+SAT+BMMI PART GOES HERE:
mkdir -p exp/$mic/tri2a_ali
95
steps/align_si.sh --nj $nj --cmd "$train_cmd" \
96 97
  data/$mic/train data/lang exp/$mic/tri2a exp/$mic/tri2_ali || exit 1;

98
# Train tri3a, which is LDA+MLLT
99 100 101 102 103 104
mkdir -p exp/$mic/tri3a
steps/train_lda_mllt.sh --cmd "$train_cmd" \
  --splice-opts "--left-context=3 --right-context=3" \
  5000 80000 data/$mic/train data/lang exp/$mic/tri2_ali exp/$mic/tri3a \
  >& exp/$mic/tri3a/train.log || exit 1;

105
for lm_suffix in $LM; do
106 107 108 109 110
  (
    graph_dir=exp/$mic/tri3a/graph_${lm_suffix}
    $highmem_cmd $graph_dir/mkgraph.log \
      utils/mkgraph.sh data/lang_${lm_suffix} exp/$mic/tri3a $graph_dir

111
    steps/decode.sh --nj $DEV_SPK --cmd "$decode_cmd" --config conf/decode.conf \
112
      $graph_dir data/$mic/dev exp/$mic/tri3a/decode_dev_${lm_suffix}
113

114
    steps/decode.sh --nj $EVAL_SPK --cmd "$decode_cmd" --config conf/decode.conf \
115 116
      $graph_dir data/$mic/eval exp/$mic/tri3a/decode_eval_${lm_suffix}
  )
117 118
done

119

120
# skip SAT, and build MMI models
121 122
steps/make_denlats.sh --nj $nj --cmd "$decode_cmd" --config conf/decode.config \
    data/$mic/train data/lang exp/$mic/tri3a exp/$mic/tri3a_denlats  || exit 1;
123

124 125 126 127

mkdir -p exp/$mic/tri3a_ali
steps/align_si.sh --nj $nj --cmd "$train_cmd" \
  data/$mic/train data/lang exp/$mic/tri3a exp/$mic/tri3a_ali || exit 1;
128 129 130 131

# 4 iterations of MMI seems to work well overall. The number of iterations is
# used as an explicit argument even though train_mmi.sh will use 4 iterations by
# default.
132
num_mmi_iters=4
133
steps/train_mmi.sh --cmd "$train_cmd" --boost 0.1 --num-iters $num_mmi_iters \
134 135
  data/$mic/train data/lang exp/$mic/tri3a_ali exp/$mic/tri3a_denlats \
  exp/$mic/tri3a_mmi_b0.1 || exit 1;
136

137
for lm_suffix in $LM; do
138 139
  (
    graph_dir=exp/$mic/tri3a/graph_${lm_suffix}
140

141 142
    for i in `seq 1 4`; do
      decode_dir=exp/$mic/tri3a_mmi_b0.1/decode_dev_${i}.mdl_${lm_suffix}
143
      steps/decode.sh --nj $DEV_SPK --cmd "$decode_cmd" --config conf/decode.conf \
144
        --iter $i $graph_dir data/$mic/dev $decode_dir
145 146 147 148
    done

    i=3 #simply assummed
    decode_dir=exp/$mic/tri3a_mmi_b0.1/decode_eval_${i}.mdl_${lm_suffix}
149
    steps/decode.sh --nj $EVAL_SPK --cmd "$decode_cmd" --config conf/decode.conf \
150
      --iter $i $graph_dir data/$mic/eval $decode_dir
151
  )
152 153
done

154 155
# here goes hybrid stuf
# in the ASRU paper we used different python nnet code, so someone needs to copy&adjust nnet or nnet2 switchboard commands
156