@@ -5,6 +5,8 @@ if [ $# != 3 ];then
5
5
exit -1
6
6
fi
7
7
8
+ stage=0
9
+ stop_stage=100
8
10
ngpu=$( echo $CUDA_VISIBLE_DEVICES | awk -F " ," ' {print NF}' )
9
11
echo " using $ngpu gpus..."
10
12
24
26
# fi
25
27
26
28
27
- for type in attention ctc_greedy_search; do
28
- echo " decoding ${type} "
29
- if [ ${chunk_mode} == true ]; then
30
- # stream decoding only support batchsize=1
29
+ if [ ${stage} -le 0 ] && [ ${stop_stage} -ge 0 ]; then
30
+ # format the reference test file
31
+ python utils/format_rsl.py \
32
+ --origin_ref data/manifest.test.raw \
33
+ --trans_ref data/manifest.test.text
34
+
35
+ for type in attention ctc_greedy_search; do
36
+ echo " decoding ${type} "
37
+ if [ ${chunk_mode} == true ]; then
38
+ # stream decoding only support batchsize=1
39
+ batch_size=1
40
+ else
41
+ batch_size=64
42
+ fi
43
+ output_dir=${ckpt_prefix}
44
+ mkdir -p ${output_dir}
45
+ python3 -u ${BIN_DIR} /test.py \
46
+ --ngpu ${ngpu} \
47
+ --config ${config_path} \
48
+ --decode_cfg ${decode_config_path} \
49
+ --result_file ${output_dir} /${type} .rsl \
50
+ --checkpoint_path ${ckpt_prefix} \
51
+ --opts decode.decoding_method ${type} \
52
+ --opts decode.decode_batch_size ${batch_size}
53
+
54
+ if [ $? -ne 0 ]; then
55
+ echo " Failed in evaluation!"
56
+ exit 1
57
+
58
+ fi
59
+ # format the hyp file
60
+ python utils/format_rsl.py \
61
+ --origin_hyp ${output_dir} /${type} .rsl \
62
+ --trans_hyp ${output_dir} /${type} .rsl.text
63
+ python utils/compute-wer.py --char=1 --v=1 \
64
+ data/manifest.test.text ${output_dir} /${type} .rsl.text > ${output_dir} /${type} .error
65
+
66
+ done
67
+
68
+ for type in ctc_prefix_beam_search attention_rescoring; do
69
+ echo " decoding ${type} "
31
70
batch_size=1
32
- else
33
- batch_size=64
34
- fi
35
- output_dir=${ckpt_prefix}
36
- mkdir -p ${output_dir}
37
- python3 -u ${BIN_DIR} /test.py \
38
- --ngpu ${ngpu} \
39
- --config ${config_path} \
40
- --decode_cfg ${decode_config_path} \
41
- --result_file ${output_dir} /${type} .rsl \
42
- --checkpoint_path ${ckpt_prefix} \
43
- --opts decode.decoding_method ${type} \
44
- --opts decode.decode_batch_size ${batch_size}
45
-
46
- if [ $? -ne 0 ]; then
47
- echo " Failed in evaluation!"
48
- exit 1
49
- fi
50
- done
51
-
52
- for type in ctc_prefix_beam_search attention_rescoring; do
53
- echo " decoding ${type} "
54
- batch_size=1
71
+ output_dir=${ckpt_prefix}
72
+ mkdir -p ${output_dir}
73
+ python3 -u ${BIN_DIR} /test.py \
74
+ --ngpu ${ngpu} \
75
+ --config ${config_path} \
76
+ --decode_cfg ${decode_config_path} \
77
+ --result_file ${output_dir} /${type} .rsl \
78
+ --checkpoint_path ${ckpt_prefix} \
79
+ --opts decode.decoding_method ${type} \
80
+ --opts decode.decode_batch_size ${batch_size}
81
+
82
+ if [ $? -ne 0 ]; then
83
+ echo " Failed in evaluation!"
84
+ exit 1
85
+ fi
86
+ python utils/format_rsl.py \
87
+ --origin_hyp ${output_dir} /${type} .rsl
88
+ --trans_hyp ${output_dir} /${type} .rsl.text
89
+ python utils/compute-wer.py --char=1 --v=1 \
90
+ data/manifest.test.text ${output_dir} /${type} .rsl.text > ${output_dir} /${type} .error
91
+ done
92
+ fi
93
+
94
+ if [ ${stage} -le 101 ] && [ ${stop_stage} -ge 101 ]; then
95
+ # format the reference test file for sclite
96
+ python utils/format_rsl.py \
97
+ --origin_ref data/manifest.test.raw \
98
+ --trans_ref_sclite data/manifest.test.text.sclite
99
+
55
100
output_dir=${ckpt_prefix}
56
- mkdir -p ${output_dir}
57
- python3 -u ${BIN_DIR} /test.py \
58
- --ngpu ${ngpu} \
59
- --config ${config_path} \
60
- --decode_cfg ${decode_config_path} \
61
- --result_file ${output_dir} /${type} .rsl \
62
- --checkpoint_path ${ckpt_prefix} \
63
- --opts decode.decoding_method ${type} \
64
- --opts decode.decode_batch_size ${batch_size}
65
-
66
- if [ $? -ne 0 ]; then
67
- echo " Failed in evaluation!"
68
- exit 1
69
- fi
70
- done
101
+ for type in attention ctc_greedy_search ctc_prefix_beam_search attention_rescoring; do
102
+ python utils/format_rsl.py \
103
+ --origin_hyp ${output_dir} /${type} .rsl
104
+ --trans_hyp_sclite ${output_dir} /${type} .rsl.text.sclite
105
+
106
+ mkdir -p ${output_dir} /${type} _sclite
107
+ sclite -i wsj -r data/manifest.test.text.sclite -h ${output_dir} /${type} .rsl.text.sclite -e utf-8 -o all -O ${output_dir} /${type} _sclite -c NOASCII
108
+ done
109
+ fi
71
110
72
111
exit 0
0 commit comments