Skip to content

Commit 4e431ae

Browse files
committed
resum librispeech
1 parent 7c3c1b4 commit 4e431ae

File tree

1 file changed

+43
-91
lines changed
  • examples/librispeech/asr1/local

1 file changed

+43
-91
lines changed

examples/librispeech/asr1/local/test.sh

Lines changed: 43 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ echo "chunk mode ${chunk_mode}"
4242

4343

4444
if [ ${stage} -le 0 ] && [ ${stop_stage} -ge 0 ]; then
45-
# format the reference test file
46-
python utils/format_rsl.py \
47-
--origin_ref data/manifest.test.raw \
48-
--trans_ref data/manifest.test.text
49-
5045
for type in attention; do
5146
echo "decoding ${type}"
5247
if [ ${chunk_mode} == true ];then
@@ -68,98 +63,55 @@ if [ ${stage} -le 0 ] && [ ${stop_stage} -ge 0 ]; then
6863
echo "Failed in evaluation!"
6964
exit 1
7065
fi
71-
# format the hyp file
72-
python utils/format_rsl.py \
73-
--origin_hyp ${ckpt_prefix}.${type}.rsl \
74-
--trans_hyp ${ckpt_prefix}.${type}.rsl.text
75-
76-
python utils/compute-wer.py --char=1 --v=1 \
77-
data/manifest.test.text ${ckpt_prefix}.${type}.rsl.text > ${ckpt_prefix}.${type}.error
78-
7966
echo "decoding ${type} done."
8067
done
8168
fi
8269

83-
if [ ${stage} -le 1 ] && [ ${stop_stage} -ge 1 ]; then
84-
for type in ctc_greedy_search; do
85-
echo "decoding ${type}"
86-
if [ ${chunk_mode} == true ];then
87-
# stream decoding only support batchsize=1
88-
batch_size=1
89-
else
90-
batch_size=64
91-
fi
92-
python3 -u ${BIN_DIR}/test.py \
93-
--ngpu ${ngpu} \
94-
--config ${config_path} \
95-
--decode_cfg ${decode_config_path} \
96-
--result_file ${ckpt_prefix}.${type}.rsl \
97-
--checkpoint_path ${ckpt_prefix} \
98-
--opts decode.decoding_method ${type} \
99-
--opts decode.decode_batch_size ${batch_size}
100-
101-
if [ $? -ne 0 ]; then
102-
echo "Failed in evaluation!"
103-
exit 1
104-
fi
105-
106-
# format the hyp file
107-
python utils/format_rsl.py \
108-
--origin_hyp ${ckpt_prefix}.${type}.rsl \
109-
--trans_hyp ${ckpt_prefix}.${type}.rsl.text
110-
111-
python utils/compute-wer.py --char=1 --v=1 \
112-
data/manifest.test.text ${ckpt_prefix}.${type}.rsl.text > ${ckpt_prefix}.${type}.error
113-
114-
echo "decoding ${type} done."
115-
done
116-
fi
117-
118-
if [ ${stage} -le 2 ] && [ ${stop_stage} -ge 2 ]; then
119-
for type in ctc_prefix_beam_search attention_rescoring; do
120-
echo "decoding ${type}"
70+
for type in ctc_greedy_search; do
71+
echo "decoding ${type}"
72+
if [ ${chunk_mode} == true ];then
73+
# stream decoding only support batchsize=1
12174
batch_size=1
122-
python3 -u ${BIN_DIR}/test.py \
123-
--ngpu ${ngpu} \
124-
--config ${config_path} \
125-
--decode_cfg ${decode_config_path} \
126-
--result_file ${ckpt_prefix}.${type}.rsl \
127-
--checkpoint_path ${ckpt_prefix} \
128-
--opts decode.decoding_method ${type} \
129-
--opts decode.decode_batch_size ${batch_size}
130-
131-
if [ $? -ne 0 ]; then
132-
echo "Failed in evaluation!"
133-
exit 1
134-
fi
135-
# format the hyp file
136-
python utils/format_rsl.py \
137-
--origin_hyp ${ckpt_prefix}.${type}.rsl \
138-
--trans_hyp ${ckpt_prefix}.${type}.rsl.text
75+
else
76+
batch_size=64
77+
fi
78+
python3 -u ${BIN_DIR}/test.py \
79+
--ngpu ${ngpu} \
80+
--config ${config_path} \
81+
--decode_cfg ${decode_config_path} \
82+
--result_file ${ckpt_prefix}.${type}.rsl \
83+
--checkpoint_path ${ckpt_prefix} \
84+
--opts decode.decoding_method ${type} \
85+
--opts decode.decode_batch_size ${batch_size}
86+
87+
if [ $? -ne 0 ]; then
88+
echo "Failed in evaluation!"
89+
exit 1
90+
fi
91+
echo "decoding ${type} done."
92+
done
93+
94+
95+
96+
for type in ctc_prefix_beam_search attention_rescoring; do
97+
echo "decoding ${type}"
98+
batch_size=1
99+
python3 -u ${BIN_DIR}/test.py \
100+
--ngpu ${ngpu} \
101+
--config ${config_path} \
102+
--decode_cfg ${decode_config_path} \
103+
--result_file ${ckpt_prefix}.${type}.rsl \
104+
--checkpoint_path ${ckpt_prefix} \
105+
--opts decode.decoding_method ${type} \
106+
--opts decode.decode_batch_size ${batch_size}
107+
108+
if [ $? -ne 0 ]; then
109+
echo "Failed in evaluation!"
110+
exit 1
111+
fi
112+
echo "decoding ${type} done."
113+
done
139114

140-
python utils/compute-wer.py --char=1 --v=1 \
141-
data/manifest.test.text ${ckpt_prefix}.${type}.rsl.text > ${ckpt_prefix}.${type}.error
142-
143-
echo "decoding ${type} done."
144-
done
145-
fi
146115
echo "Finished"
147116

148-
149-
if [ ${stage} -le 101 ] && [ ${stop_stage} -ge 101 ]; then
150-
# format the reference test file for sclite
151-
python utils/format_rsl.py \
152-
--origin_ref data/manifest.test.raw \
153-
--trans_ref_sclite data/manifest.test.raw.text.sclite
154-
155-
for type in attention ctc_greedy_search ctc_prefix_beam_search attention_rescoring; do
156-
python utils/format_rsl.py \
157-
--origin_hyp ${ckpt_prefix}.${type}.rsl
158-
--trans_hyp_sclite ${ckpt_prefix}.${type}.rsl.text.sclite
159-
160-
mkdir -p ${ckpt_prefix}.${type}_sclite
161-
sclite -i wsj -r data/manifest.test.raw.text.sclite -h ${ckpt_prefix}.${type}.rsl.text.sclite -e utf-8 -o all -O ${ckpt_prefix}.${type}_sclite
162-
done
163-
fi
164-
165117
exit 0

0 commit comments

Comments
 (0)