diff --git a/examples/aishell/asr0/local/test.sh b/examples/aishell/asr0/local/test.sh index 778c7142e..df628af86 100755 --- a/examples/aishell/asr0/local/test.sh +++ b/examples/aishell/asr0/local/test.sh @@ -22,7 +22,7 @@ fi if [ ${stage} -le 0 ] && [ ${stop_stage} -ge 0 ]; then # format the reference test file - python3 utils/format_rsl.py \ + python3 ${MAIN_ROOT}/utils/format_rsl.py \ --origin_ref data/manifest.test.raw \ --trans_ref data/manifest.test.text @@ -39,20 +39,20 @@ if [ ${stage} -le 0 ] && [ ${stop_stage} -ge 0 ]; then fi # format the hyp file - python3 utils/format_rsl.py \ + python3 ${MAIN_ROOT}/utils/format_rsl.py \ --origin_hyp ${ckpt_prefix}.rsl \ --trans_hyp ${ckpt_prefix}.rsl.text - python3 utils/compute-wer.py --char=1 --v=1 \ + python3 ${MAIN_ROOT}/${MAIN_ROOT}/${MAIN_ROOT}/${MAIN_ROOT}/utils/compute-wer.py --char=1 --v=1 \ data/manifest.test.text ${ckpt_prefix}.rsl.text > ${ckpt_prefix}.error fi if [ ${stage} -le 101 ] && [ ${stop_stage} -ge 101 ]; then - python3 utils/format_rsl.py \ + python3 ${MAIN_ROOT}/utils/format_rsl.py \ --origin_ref data/manifest.test.raw \ --trans_ref_sclite data/manifest.test.text.sclite - python3 utils/format_rsl.py \ + python3 ${MAIN_ROOT}/utils/format_rsl.py \ --origin_hyp ${ckpt_prefix}.rsl \ --trans_hyp_sclite ${ckpt_prefix}.rsl.text.sclite diff --git a/examples/aishell/asr1/local/test.sh b/examples/aishell/asr1/local/test.sh index 8487e9904..2f55f48a8 100755 --- a/examples/aishell/asr1/local/test.sh +++ b/examples/aishell/asr1/local/test.sh @@ -34,7 +34,7 @@ fi if [ ${stage} -le 0 ] && [ ${stop_stage} -ge 0 ]; then # format the reference test file - python utils/format_rsl.py \ + python ${MAIN_ROOT}/utils/format_rsl.py \ --origin_ref data/manifest.test.raw \ --trans_ref data/manifest.test.text @@ -63,10 +63,10 @@ if [ ${stage} -le 0 ] && [ ${stop_stage} -ge 0 ]; then fi # format the hyp file - python utils/format_rsl.py \ + python ${MAIN_ROOT}/utils/format_rsl.py \ --origin_hyp ${output_dir}/${type}.rsl \ --trans_hyp ${output_dir}/${type}.rsl.text - python utils/compute-wer.py --char=1 --v=1 \ + python ${MAIN_ROOT}/utils/compute-wer.py --char=1 --v=1 \ data/manifest.test.text ${output_dir}/${type}.rsl.text > ${output_dir}/${type}.error done @@ -89,10 +89,10 @@ if [ ${stage} -le 0 ] && [ ${stop_stage} -ge 0 ]; then echo "Failed in evaluation!" exit 1 fi - python utils/format_rsl.py \ + python ${MAIN_ROOT}/utils/format_rsl.py \ --origin_hyp ${output_dir}/${type}.rsl \ --trans_hyp ${output_dir}/${type}.rsl.text - python utils/compute-wer.py --char=1 --v=1 \ + python ${MAIN_ROOT}/utils/compute-wer.py --char=1 --v=1 \ data/manifest.test.text ${output_dir}/${type}.rsl.text > ${output_dir}/${type}.error done fi @@ -100,13 +100,13 @@ fi if [ ${stage} -le 101 ] && [ ${stop_stage} -ge 101 ]; then echo "using sclite to compute cer..." # format the reference test file for sclite - python utils/format_rsl.py \ + python ${MAIN_ROOT}/utils/format_rsl.py \ --origin_ref data/manifest.test.raw \ --trans_ref_sclite data/manifest.test.text.sclite output_dir=${ckpt_prefix} for type in attention ctc_greedy_search ctc_prefix_beam_search attention_rescoring; do - python utils/format_rsl.py \ + python ${MAIN_ROOT}/utils/format_rsl.py \ --origin_hyp ${output_dir}/${type}.rsl \ --trans_hyp_sclite ${output_dir}/${type}.rsl.text.sclite diff --git a/examples/aishell/asr3/local/test.sh b/examples/aishell/asr3/local/test.sh index 91e1c5457..b3a4cf5d2 100755 --- a/examples/aishell/asr3/local/test.sh +++ b/examples/aishell/asr3/local/test.sh @@ -22,7 +22,7 @@ source ${MAIN_ROOT}/utils/parse_options.sh || exit 1; # exit 1 #fi -python3 utils/format_rsl.py \ +python3 ${MAIN_ROOT}/utils/format_rsl.py \ --origin_ref data/manifest.test.raw \ --trans_ref data/manifest.test.text @@ -43,11 +43,11 @@ for type in ctc_greedy_search; do echo "Failed in evaluation!" exit 1 fi - python3 utils/format_rsl.py \ + python3 ${MAIN_ROOT}/utils/format_rsl.py \ --origin_hyp ${ckpt_prefix}.${type}.rsl \ --trans_hyp ${ckpt_prefix}.${type}.rsl.text - python3 utils/compute-wer.py --char=1 --v=1 \ + python3 ${MAIN_ROOT}/utils/compute-wer.py --char=1 --v=1 \ data/manifest.test.text ${ckpt_prefix}.${type}.rsl.text > ${ckpt_prefix}.${type}.error echo "decoding ${type} done." done @@ -68,11 +68,11 @@ for type in ctc_prefix_beam_search; do echo "Failed in evaluation!" exit 1 fi - python3 utils/format_rsl.py \ + python3 ${MAIN_ROOT}/utils/format_rsl.py \ --origin_hyp ${ckpt_prefix}.${type}.rsl \ --trans_hyp ${ckpt_prefix}.${type}.rsl.text - python3 utils/compute-wer.py --char=1 --v=1 \ + python3 ${MAIN_ROOT}/utils/compute-wer.py --char=1 --v=1 \ data/manifest.test.text ${ckpt_prefix}.${type}.rsl.text > ${ckpt_prefix}.${type}.error echo "decoding ${type} done." done diff --git a/examples/librispeech/asr0/local/test.sh b/examples/librispeech/asr0/local/test.sh index 728569d1f..d6258f5c8 100755 --- a/examples/librispeech/asr0/local/test.sh +++ b/examples/librispeech/asr0/local/test.sh @@ -22,7 +22,7 @@ fi if [ ${stage} -le 0 ] && [ ${stop_stage} -ge 0 ]; then # format the reference test file - python3 utils/format_rsl.py \ + python3 ${MAIN_ROOT}/utils/format_rsl.py \ --origin_ref data/manifest.test-clean.raw \ --trans_ref data/manifest.test-clean.text @@ -38,20 +38,20 @@ if [ ${stage} -le 0 ] && [ ${stop_stage} -ge 0 ]; then exit 1 fi - python3 utils/format_rsl.py \ + python3 ${MAIN_ROOT}/utils/format_rsl.py \ --origin_hyp ${ckpt_prefix}.rsl \ --trans_hyp ${ckpt_prefix}.rsl.text - python3 utils/compute-wer.py --char=1 --v=1 \ + python3 ${MAIN_ROOT}/utils/compute-wer.py --char=1 --v=1 \ data/manifest.test-clean.text ${ckpt_prefix}.rsl.text > ${ckpt_prefix}.error fi if [ ${stage} -le 101 ] && [ ${stop_stage} -ge 101 ]; then - python3 utils/format_rsl.py \ + python3 ${MAIN_ROOT}/utils/format_rsl.py \ --origin_ref data/manifest.test-clean.raw \ --trans_ref_sclite data/manifest.test.text-clean.sclite - python3 utils/format_rsl.py \ + python3 ${MAIN_ROOT}/utils/format_rsl.py \ --origin_hyp ${ckpt_prefix}.rsl \ --trans_hyp_sclite ${ckpt_prefix}.rsl.text.sclite diff --git a/examples/librispeech/asr1/local/test.sh b/examples/librispeech/asr1/local/test.sh index 03cef9a62..491c8ae77 100755 --- a/examples/librispeech/asr1/local/test.sh +++ b/examples/librispeech/asr1/local/test.sh @@ -43,7 +43,7 @@ echo "chunk mode ${chunk_mode}" if [ ${stage} -le 0 ] && [ ${stop_stage} -ge 0 ]; then # format the reference test file - python3 utils/format_rsl.py \ + python3 ${MAIN_ROOT}/utils/format_rsl.py \ --origin_ref data/manifest.test-clean.raw \ --trans_ref data/manifest.test-clean.text @@ -68,11 +68,11 @@ if [ ${stage} -le 0 ] && [ ${stop_stage} -ge 0 ]; then echo "Failed in evaluation!" exit 1 fi - python3 utils/format_rsl.py \ + python3 ${MAIN_ROOT}/utils/format_rsl.py \ --origin_hyp ${ckpt_prefix}.${type}.rsl \ --trans_hyp ${ckpt_prefix}.${type}.rsl.text - python3 utils/compute-wer.py --char=1 --v=1 \ + python3 ${MAIN_ROOT}/utils/compute-wer.py --char=1 --v=1 \ data/manifest.test-clean.text ${ckpt_prefix}.${type}.rsl.text > ${ckpt_prefix}.${type}.error echo "decoding ${type} done." done @@ -98,7 +98,7 @@ if [ ${stage} -le 0 ] && [ ${stop_stage} -ge 0 ]; then echo "Failed in evaluation!" exit 1 fi - python3 utils/format_rsl.py \ + python3 ${MAIN_ROOT}/utils/format_rsl.py \ --origin_hyp ${ckpt_prefix}.${type}.rsl \ --trans_hyp ${ckpt_prefix}.${type}.rsl.text @@ -125,25 +125,25 @@ if [ ${stage} -le 0 ] && [ ${stop_stage} -ge 0 ]; then echo "Failed in evaluation!" exit 1 fi - python3 utils/format_rsl.py \ + python3 ${MAIN_ROOT}/utils/format_rsl.py \ --origin_hyp ${ckpt_prefix}.${type}.rsl \ --trans_hyp ${ckpt_prefix}.${type}.rsl.text - python3 utils/compute-wer.py --char=1 --v=1 \ + python3 ${MAIN_ROOT}/utils/compute-wer.py --char=1 --v=1 \ data/manifest.test-clean.text ${ckpt_prefix}.${type}.rsl.text > ${ckpt_prefix}.${type}.error echo "decoding ${type} done." done fi if [ ${stage} -le 101 ] && [ ${stop_stage} -ge 101 ]; then - python3 utils/format_rsl.py \ + python3 ${MAIN_ROOT}/utils/format_rsl.py \ --origin_ref data/manifest.test-clean.raw \ --trans_ref_sclite data/manifest.test.text-clean.sclite output_dir=${ckpt_prefix} for type in attention ctc_greedy_search ctc_prefix_beam_search attention_rescoring; do - python utils/format_rsl.py \ + python ${MAIN_ROOT}/utils/format_rsl.py \ --origin_hyp ${output_dir}/${type}.rsl \ --trans_hyp_sclite ${output_dir}/${type}.rsl.text.sclite diff --git a/examples/librispeech/asr3/local/test.sh b/examples/librispeech/asr3/local/test.sh index ccc0d84de..c59376771 100755 --- a/examples/librispeech/asr3/local/test.sh +++ b/examples/librispeech/asr3/local/test.sh @@ -24,7 +24,7 @@ source ${MAIN_ROOT}/utils/parse_options.sh || exit 1; # exit 1 #fi -python3 utils/format_rsl.py \ +python3 ${MAIN_ROOT}/utils/format_rsl.py \ --origin_ref data/manifest.test-clean.raw \ --trans_ref data/manifest.test-clean.text @@ -45,11 +45,11 @@ for type in ctc_greedy_search; do echo "Failed in evaluation!" exit 1 fi - python3 utils/format_rsl.py \ + python3 ${MAIN_ROOT}/utils/format_rsl.py \ --origin_hyp ${ckpt_prefix}.${type}.rsl \ --trans_hyp ${ckpt_prefix}.${type}.rsl.text - python3 utils/compute-wer.py --char=1 --v=1 \ + python3 ${MAIN_ROOT}/utils/compute-wer.py --char=1 --v=1 \ data/manifest.test-clean.text ${ckpt_prefix}.${type}.rsl.text > ${ckpt_prefix}.${type}.error echo "decoding ${type} done." done @@ -70,11 +70,11 @@ for type in ctc_prefix_beam_search; do echo "Failed in evaluation!" exit 1 fi - python3 utils/format_rsl.py \ + python3 ${MAIN_ROOT}/utils/format_rsl.py \ --origin_hyp ${ckpt_prefix}.${type}.rsl \ --trans_hyp ${ckpt_prefix}.${type}.rsl.text - python3 utils/compute-wer.py --char=1 --v=1 \ + python3 ${MAIN_ROOT}/utils/compute-wer.py --char=1 --v=1 \ data/manifest.test-clean.text ${ckpt_prefix}.${type}.rsl.text > ${ckpt_prefix}.${type}.error echo "decoding ${type} done." done diff --git a/examples/librispeech/asr4/local/test.sh b/examples/librispeech/asr4/local/test.sh index dfbd56ac2..8c17bd350 100755 --- a/examples/librispeech/asr4/local/test.sh +++ b/examples/librispeech/asr4/local/test.sh @@ -23,7 +23,7 @@ source ${MAIN_ROOT}/utils/parse_options.sh || exit 1; # exit 1 #fi -python3 utils/format_rsl.py \ +python3 ${MAIN_ROOT}/utils/format_rsl.py \ --origin_ref data/manifest.test-clean.raw \ --trans_ref data/manifest.test-clean.text @@ -44,11 +44,11 @@ for type in ctc_greedy_search; do echo "Failed in evaluation!" exit 1 fi - python3 utils/format_rsl.py \ + python3 ${MAIN_ROOT}/utils/format_rsl.py \ --origin_hyp ${ckpt_prefix}.${type}.rsl \ --trans_hyp ${ckpt_prefix}.${type}.rsl.text - python3 utils/compute-wer.py --char=1 --v=1 \ + python3 ${MAIN_ROOT}/utils/compute-wer.py --char=1 --v=1 \ data/manifest.test-clean.text ${ckpt_prefix}.${type}.rsl.text > ${ckpt_prefix}.${type}.error echo "decoding ${type} done." done @@ -69,11 +69,11 @@ for type in ctc_prefix_beam_search; do echo "Failed in evaluation!" exit 1 fi - python3 utils/format_rsl.py \ + python3 ${MAIN_ROOT}/utils/format_rsl.py \ --origin_hyp ${ckpt_prefix}.${type}.rsl \ --trans_hyp ${ckpt_prefix}.${type}.rsl.text - python3 utils/compute-wer.py --char=1 --v=1 \ + python3 ${MAIN_ROOT}/utils/compute-wer.py --char=1 --v=1 \ data/manifest.test-clean.text ${ckpt_prefix}.${type}.rsl.text > ${ckpt_prefix}.${type}.error echo "decoding ${type} done." done diff --git a/paddlespeech/s2t/exps/deepspeech2/model.py b/paddlespeech/s2t/exps/deepspeech2/model.py index 710757115..7660e5fbc 100644 --- a/paddlespeech/s2t/exps/deepspeech2/model.py +++ b/paddlespeech/s2t/exps/deepspeech2/model.py @@ -421,7 +421,6 @@ class DeepSpeech2ExportTester(DeepSpeech2Tester): else: raise Exception("wrong model type") - self.predictor.clear_intermediate_tensor() self.predictor.try_shrink_memory() #replace the with ' ' diff --git a/paddlespeech/s2t/models/ds2/deepspeech2.py b/paddlespeech/s2t/models/ds2/deepspeech2.py index b7ee80a7d..050a79185 100644 --- a/paddlespeech/s2t/models/ds2/deepspeech2.py +++ b/paddlespeech/s2t/models/ds2/deepspeech2.py @@ -398,14 +398,15 @@ class DeepSpeech2InferModel(DeepSpeech2Model): paddle.static.InputSpec( shape=[None, None, self.encoder.feat_size ], #[B, chunk_size, feat_dim] - dtype='float32'), + dtype='float32', ), paddle.static.InputSpec(shape=[None], dtype='int64'), # audio_length, [B] paddle.static.InputSpec( shape=[None, None, None], dtype='float32'), paddle.static.InputSpec( shape=[None, None, None], dtype='float32') - ]) + ], + full_graph=True) elif self.encoder.rnn_direction == "bidirect": static_model = paddle.jit.to_static( self, @@ -415,7 +416,8 @@ class DeepSpeech2InferModel(DeepSpeech2Model): dtype='float32'), # audio, [B,T,D] paddle.static.InputSpec(shape=[None], dtype='int64'), # audio_length, [B] - ]) + ], + full_graph=True) else: raise Exception("wrong model type") return static_model