Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CHiME4 recipe #746

Merged
merged 9 commits into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update decoding recipe in run,sh
  • Loading branch information
funcwj committed Oct 28, 2021
commit 098ca052ef936855b5e4e86fbd19f3aa0643523f
13 changes: 7 additions & 6 deletions examples/chime4/s0/conf/train_conformer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ encoder_conf:
decoder: transformer
decoder_conf:
attention_heads: 8
linear_units: 1024
linear_units: 2048
num_blocks: 6
dropout_rate: 0.1
positional_dropout_rate: 0.1
Expand All @@ -30,11 +30,12 @@ decoder_conf:

# hybrid CTC/attention
model_conf:
ctc_weight: 0.3
ctc_weight: 0.2
lsm_weight: 0.1 # label smoothing option
length_normalized_loss: false

dataset_conf:
char: true
filter_conf:
max_length: 40960
min_length: 0
Expand Down Expand Up @@ -64,14 +65,14 @@ dataset_conf:
batch_type: 'static' # static or dynamic
batch_size: 8

grad_clip: 5
grad_clip: 10
accum_grad: 4
max_epoch: 60
log_interval: 100
max_epoch: 80
log_interval: 200

optim: adam
optim_conf:
lr: 0.001
lr: 0.0002
scheduler: warmuplr # pytorch v1.1.0+ required
scheduler_conf:
warmup_steps: 20000
29 changes: 21 additions & 8 deletions examples/chime4/s0/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ dict=$data_dir/dict_char.txt
train_config=conf/train_conformer.yaml
exp_dir=exp/1a
decode_modes="ctc_prefix_beam_search attention"
average_checkpoint=true
average_num=10

. ./path.sh
. ./tools/parse_options.sh || exit 1
Expand All @@ -38,12 +40,12 @@ fi


if [ $end -ge 2 ] && [ $beg -le 2 ]; then
echo "<NOISE>" > $data_dir/train/non_lang.txt
echo -e "<NOISE>\n<*IN*>\n<*MR.*>" > $data_dir/train/non_lang.txt
for name in dev train; do
python tools/text2token.py $data_dir/$name/text -n 1 -s 1 \
-l $data_dir/train/non_lang.txt > $data_dir/$name/char
done
mkdir -p $(dirname $dict) && echo -e "<blank> 0\n<unk> 1" >> ${dict}
mkdir -p $(dirname $dict) && echo -e "<blank> 0\n<unk> 1" > ${dict}
cat $data_dir/train/char | cut -f 2- -d" " | tr " " "\n" | sort | uniq | awk '{print $0 " " NR+1}' >> ${dict}
num_token=$(cat $dict | wc -l)
echo "<sos/eos> $num_token" >> $dict
Expand All @@ -59,13 +61,13 @@ if [ $end -ge 3 ] && [ $beg -le 3 ]; then
--out_cmvn $data_dir/train/global_cmvn
echo "Prepare data, prepare requried format"
for x in train dev; do
tools/make_raw_list.py $data_dir/$x/wav.scp $data_dir/$x/text \
tools/make_raw_list.py $data_dir/$x/wav.scp $data_dir/$x/char \
$data_dir/$x/data.list
done
fi

if [ $end -ge 4 ] && [ $beg -le 4 ]; then
mkdir -p $exp_dir && cp feat/train/global_cmvn $exp_dir
mkdir -p $exp_dir && cp $data_dir/train/global_cmvn $exp_dir
python wenet/bin/train.py \
--gpu 0 \
--config $train_config \
Expand All @@ -80,36 +82,47 @@ fi

suffix="isolated_1ch_track"
if [ $end -ge 5 ] && [ $beg -le 5 ]; then
if [ ${average_checkpoint} == true ]; then
decode_checkpoint=$exp_dir/avg_${average_num}.pt
echo "do model average and final checkpoint is $decode_checkpoint"
python wenet/bin/average_model.py \
--dst_model $decode_checkpoint \
--src_path $exp_dir \
--num ${average_num} \
--val_best
fi
nj=4
ctc_weight=0.5
ctc_weight=0.2
for x in dt05_{simu,real} et05_{simu,real}; do
subdir=${x}_${suffix}
tools/make_raw_list.py $data_dir/$subdir/wav.scp $data_dir/$subdir/text \
$data_dir/$subdir/data.list
done
for mode in ${decode_modes}; do
for x in dt05_{simu,real} et05_{simu,real}; do
subdir=${x}_${suffix}
dec_dir=$exp_dir/${subdir}_${mode} && mkdir -p $dec_dir
python wenet/bin/recognize.py \
--gpu 0 \
--mode $mode \
--config $exp_dir/train.yaml \
--test_data $data_dir/$subdir/data.list \
--checkpoint $exp_dir/70.pt \
--checkpoint $exp_dir/avg_${average_num}.pt \
--beam_size 8 \
--batch_size 1 \
--dict $dict \
--ctc_weight $ctc_weight \
--ctc_weight $ctc_weight \
--result_file $dec_dir/text &
done
wait
done
for mode in ${decode_modes}; do
for x in dt05_{simu,real} et05_{simu,real}; do
subdir=${x}_${suffix}
dec_dir=$exp_dir/${subdir}_${mode}
sed 's:<space>: :g' $dec_dir/text > $dec_dir/text.norm
python tools/compute-wer.py --char=1 --v=1 \
feat/$subdir/text $dec_dir/text.norm > $dec_dir/wer
$data_dir/$subdir/text $dec_dir/text.norm > $dec_dir/wer
done
done
fi
Expand Down