compare_wer.sh
1.97 KB
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
#!/bin/bash
# Copyright 2018 Emotech LTD (Author: Xuechen Liu)
# compare wer between diff. models in hkust nnet3 directory
# exemplar usage: local/nnet3/compare_wer_general.sh exp/nnet3/tdnn_sp exp/nnet3/tdnn_sp_pr43
# note: this script is made quite general since we kinda wanna give more flexibility to
# users on adding affix for their own use when training models.
set -e
. ./cmd.sh
. ./path.sh
if [ $# == 0 ]; then
echo "Usage: $0: [--online] <dir1> [<dir2> ... ]"
echo "e.g.: $0 exp/nnet3/tdnn_sp exp/nnet3/tdnn_sp_pr"
exit 1
fi
echo "# $0 $*"
include_online=false
if [ "$1" == "--online" ]; then
include_online=true
shift
fi
set_names() {
if [ $# != 1 ]; then
echo "compare_wer_general.sh: internal error"
exit 1 # exit the program
fi
dirname=$(echo $1 | cut -d: -f1)
}
# print model names
echo -n "# Model "
for x in $*; do
printf "% 10s" " $(basename $x)"
done
echo
# print decode WER results
echo -n "# WER(%) "
for x in $*; do
set_names $x
wer=$([ -d $x ] && grep WER $x/decode/cer_* | utils/best_wer.sh | awk '{print $2}')
printf "% 10s" $wer
done
echo
# so how about online WER?
if $include_online; then
echo -n "# WER(%)[online] "
for x in $*; do
set_names $x
wer=$(cat ${x}_online/decode/cer_* | utils/best_wer.sh | awk '{print $2}')
printf "% 10s" $wer
done
echo
echo -n "# WER(%)[per-utt] "
for x in $*; do
set_names $x
wer_per_utt=$(cat ${x}_online/decode_per_utt/cer_* | utils/best_wer.sh | awk '{print $2}')
printf "% 10s" $wer_per_utt
done
echo
fi
# print log for train & validation
echo -n "# Final train prob "
for x in $*; do
prob=$(grep Overall $x/log/compute_prob_train.combined.log | grep log-like | awk '{printf($8)}' | cut -c1-7)
printf "% 10s" $prob
done
echo
echo -n "# Final valid prob "
for x in $*; do
prob=$(grep Overall $x/log/compute_prob_valid.combined.log | grep log-like | awk '{printf($8)}' | cut -c1-7)
printf "% 10s" $prob
done
echo