From 81598e6ff0dd6459b217c1885b0628ccf3538ead Mon Sep 17 00:00:00 2001 From: Hui Zhang Date: Wed, 10 Nov 2021 06:40:03 +0000 Subject: [PATCH 1/2] default gpu 0 for scripts --- examples/aishell/s1/run.sh | 18 ++++++++++-------- examples/callcenter/s1/run.sh | 5 +++-- examples/librispeech/s0/run.sh | 7 ++++--- examples/librispeech/s1/run.sh | 5 +++-- examples/librispeech/s2/run.sh | 7 ++++--- examples/ted_en_zh/t0/run.sh | 3 ++- examples/timit/s1/run.sh | 5 +++-- examples/tiny/s1/run.sh | 7 ++++--- 8 files changed, 33 insertions(+), 24 deletions(-) diff --git a/examples/aishell/s1/run.sh b/examples/aishell/s1/run.sh index 126c8e4e2..f28779452 100644 --- a/examples/aishell/s1/run.sh +++ b/examples/aishell/s1/run.sh @@ -2,6 +2,7 @@ source path.sh set -e +gpus=0,1,2,3 stage=0 stop_stage=100 conf_path=conf/conformer.yaml @@ -22,7 +23,7 @@ fi if [ ${stage} -le 1 ] && [ ${stop_stage} -ge 1 ]; then # train model, all `ckpt` under `exp` dir - CUDA_VISIBLE_DEVICES=0,1,2,3 ./local/train.sh ${conf_path} ${ckpt} + CUDA_VISIBLE_DEVICES=${gpus} ./local/train.sh ${conf_path} ${ckpt} fi if [ ${stage} -le 2 ] && [ ${stop_stage} -ge 2 ]; then @@ -45,13 +46,14 @@ if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then CUDA_VISIBLE_DEVICES=0 ./local/export.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} exp/${ckpt}/checkpoints/${avg_ckpt}.jit fi - # Optionally, you can add LM and test it with runtime. - if [ ${stage} -le 6 ] && [ ${stop_stage} -ge 6 ]; then - # train lm and build TLG - ./local/tlg.sh --corpus aishell --lmtype srilm - fi +# Optionally, you can add LM and test it with runtime. +if [ ${stage} -le 6 ] && [ ${stop_stage} -ge 6 ]; then + # test a single .wav file + CUDA_VISIBLE_DEVICES=0 ./local/test_hub.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} ${audio_file} || exit -1 +fi if [ ${stage} -le 7 ] && [ ${stop_stage} -ge 7 ]; then - # test a single .wav file - CUDA_VISIBLE_DEVICES=3 ./local/test_hub.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} ${audio_file} || exit -1 + echo "warning: deps on kaldi and srilm, please make sure installed." + # train lm and build TLG + ./local/tlg.sh --corpus aishell --lmtype srilm fi diff --git a/examples/callcenter/s1/run.sh b/examples/callcenter/s1/run.sh index 305021f19..e9be3d03c 100644 --- a/examples/callcenter/s1/run.sh +++ b/examples/callcenter/s1/run.sh @@ -2,6 +2,7 @@ set -e source path.sh +gpus=0,1,2,3 stage=0 stop_stage=100 conf_path=conf/conformer.yaml @@ -20,7 +21,7 @@ fi if [ ${stage} -le 1 ] && [ ${stop_stage} -ge 1 ]; then # train model, all `ckpt` under `exp` dir - CUDA_VISIBLE_DEVICES=0,1,2,3 ./local/train.sh ${conf_path} ${ckpt} + CUDA_VISIBLE_DEVICES=${gpus} ./local/train.sh ${conf_path} ${ckpt} fi if [ ${stage} -le 2 ] && [ ${stop_stage} -ge 2 ]; then @@ -30,7 +31,7 @@ fi if [ ${stage} -le 3 ] && [ ${stop_stage} -ge 3 ]; then # test ckpt avg_n - CUDA_VISIBLE_DEVICES=4 ./local/test.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} || exit -1 + CUDA_VISIBLE_DEVICES=0 ./local/test.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} || exit -1 fi if [ ${stage} -le 4 ] && [ ${stop_stage} -ge 4 ]; then diff --git a/examples/librispeech/s0/run.sh b/examples/librispeech/s0/run.sh index 385a24a44..6c4fc4116 100755 --- a/examples/librispeech/s0/run.sh +++ b/examples/librispeech/s0/run.sh @@ -2,6 +2,7 @@ set -e source path.sh +gpus=0,1,2,3,4,5,6,7 stage=0 stop_stage=100 conf_path=conf/deepspeech2.yaml @@ -21,7 +22,7 @@ fi if [ ${stage} -le 1 ] && [ ${stop_stage} -ge 1 ]; then # train model, all `ckpt` under `exp` dir - CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 ./local/train.sh ${conf_path} ${ckpt} ${model_type} + CUDA_VISIBLE_DEVICES=${gpus} ./local/train.sh ${conf_path} ${ckpt} ${model_type} fi if [ ${stage} -le 2 ] && [ ${stop_stage} -ge 2 ]; then @@ -31,7 +32,7 @@ fi if [ ${stage} -le 3 ] && [ ${stop_stage} -ge 3 ]; then # test ckpt avg_n - CUDA_VISIBLE_DEVICES=7 ./local/test.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} ${model_type} || exit -1 + CUDA_VISIBLE_DEVICES=0 ./local/test.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} ${model_type} || exit -1 fi if [ ${stage} -le 4 ] && [ ${stop_stage} -ge 4 ]; then @@ -41,5 +42,5 @@ fi if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then # test a single .wav file - CUDA_VISIBLE_DEVICES=3 ./local/test_hub.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} ${model_type} ${audio_file} || exit -1 + CUDA_VISIBLE_DEVICES=0 ./local/test_hub.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} ${model_type} ${audio_file} || exit -1 fi diff --git a/examples/librispeech/s1/run.sh b/examples/librispeech/s1/run.sh index 9ea934301..4396597f6 100755 --- a/examples/librispeech/s1/run.sh +++ b/examples/librispeech/s1/run.sh @@ -4,6 +4,7 @@ set -e . ./path.sh || exit 1; . ./cmd.sh || exit 1; +gpus=0,1,2,3 stage=0 stop_stage=100 conf_path=conf/transformer.yaml @@ -24,7 +25,7 @@ fi if [ ${stage} -le 1 ] && [ ${stop_stage} -ge 1 ]; then # train model, all `ckpt` under `exp` dir - CUDA_VISIBLE_DEVICES=0,1,2,3 ./local/train.sh ${conf_path} ${ckpt} + CUDA_VISIBLE_DEVICES=${gpus} ./local/train.sh ${conf_path} ${ckpt} fi if [ ${stage} -le 2 ] && [ ${stop_stage} -ge 2 ]; then @@ -49,5 +50,5 @@ fi if [ ${stage} -le 6 ] && [ ${stop_stage} -ge 6 ]; then # test a single .wav file - CUDA_VISIBLE_DEVICES=3 ./local/test_hub.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} ${audio_file} || exit -1 + CUDA_VISIBLE_DEVICES=0 ./local/test_hub.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} ${audio_file} || exit -1 fi diff --git a/examples/librispeech/s2/run.sh b/examples/librispeech/s2/run.sh index e014c2a93..0c5b585b8 100755 --- a/examples/librispeech/s2/run.sh +++ b/examples/librispeech/s2/run.sh @@ -5,6 +5,7 @@ set -e . ./path.sh || exit 1; . ./cmd.sh || exit 1; +gpus=0,1,2,3,4,5,6,7 stage=0 stop_stage=100 conf_path=conf/transformer.yaml @@ -24,7 +25,7 @@ fi if [ ${stage} -le 1 ] && [ ${stop_stage} -ge 1 ]; then # train model, all `ckpt` under `exp` dir - CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 ./local/train.sh ${conf_path} ${ckpt} + CUDA_VISIBLE_DEVICES=${gpus} ./local/train.sh ${conf_path} ${ckpt} fi if [ ${stage} -le 2 ] && [ ${stop_stage} -ge 2 ]; then @@ -49,9 +50,9 @@ fi if [ ${stage} -le 6 ] && [ ${stop_stage} -ge 6 ]; then # export ckpt avg_n - CUDA_VISIBLE_DEVICES= ./local/export.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} exp/${ckpt}/checkpoints/${avg_ckpt}.jit + ./local/export.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} exp/${ckpt}/checkpoints/${avg_ckpt}.jit fi if [ ${stage} -le 7 ] && [ ${stop_stage} -ge 7 ]; then - CUDA_VISIBLE_DEVICES= ./local/cacu_perplexity.sh || exit -1 + ./local/cacu_perplexity.sh || exit -1 fi diff --git a/examples/ted_en_zh/t0/run.sh b/examples/ted_en_zh/t0/run.sh index e9f4a058b..2e2bc37d6 100755 --- a/examples/ted_en_zh/t0/run.sh +++ b/examples/ted_en_zh/t0/run.sh @@ -2,6 +2,7 @@ set -e source path.sh +gpus=0,1,2,3 stage=0 stop_stage=100 conf_path=conf/transformer_joint_noam.yaml @@ -21,7 +22,7 @@ fi if [ ${stage} -le 1 ] && [ ${stop_stage} -ge 1 ]; then # train model, all `ckpt` under `exp` dir - CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 ./local/train.sh ${conf_path} ${ckpt} + CUDA_VISIBLE_DEVICES=${gpus} ./local/train.sh ${conf_path} ${ckpt} fi if [ ${stage} -le 2 ] && [ ${stop_stage} -ge 2 ]; then diff --git a/examples/timit/s1/run.sh b/examples/timit/s1/run.sh index 4c0a5cdce..74226c53f 100755 --- a/examples/timit/s1/run.sh +++ b/examples/timit/s1/run.sh @@ -3,6 +3,7 @@ set -e . path.sh || exit 1; +gpus=0,1,2,3 stage=0 stop_stage=50 conf_path=conf/transformer.yaml @@ -23,7 +24,7 @@ fi if [ ${stage} -le 1 ] && [ ${stop_stage} -ge 1 ]; then # train model, all `ckpt` under `exp` dir - CUDA_VISIBLE_DEVICES=0,1,2,3 ./local/train.sh ${conf_path} ${ckpt} + CUDA_VISIBLE_DEVICES=${gpus} ./local/train.sh ${conf_path} ${ckpt} fi if [ ${stage} -le 2 ] && [ ${stop_stage} -ge 2 ]; then @@ -33,7 +34,7 @@ fi if [ ${stage} -le 3 ] && [ ${stop_stage} -ge 3 ]; then # test ckpt avg_n - CUDA_VISIBLE_DEVICES=7 ./local/test.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} || exit -1 + CUDA_VISIBLE_DEVICES=0 ./local/test.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} || exit -1 fi if [ ${stage} -le 4 ] && [ ${stop_stage} -ge 4 ]; then diff --git a/examples/tiny/s1/run.sh b/examples/tiny/s1/run.sh index 6580afed9..23b2206cf 100755 --- a/examples/tiny/s1/run.sh +++ b/examples/tiny/s1/run.sh @@ -2,6 +2,7 @@ set -e source path.sh +gpus=0 stage=0 stop_stage=100 conf_path=conf/transformer.yaml @@ -20,7 +21,7 @@ fi if [ ${stage} -le 1 ] && [ ${stop_stage} -ge 1 ]; then # train model, all `ckpt` under `exp` dir - ./local/train.sh ${conf_path} ${ckpt} + CUDA_VISIBLE_DEVICES=${gpus} ./local/train.sh ${conf_path} ${ckpt} fi if [ ${stage} -le 2 ] && [ ${stop_stage} -ge 2 ]; then @@ -30,12 +31,12 @@ fi if [ ${stage} -le 3 ] && [ ${stop_stage} -ge 3 ]; then # test ckpt avg_n - CUDA_VISIBLE_DEVICES= ./local/test.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} || exit -1 + CUDA_VISIBLE_DEVICES=${gpus} ./local/test.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} || exit -1 fi if [ ${stage} -le 4 ] && [ ${stop_stage} -ge 4 ]; then # ctc alignment of test data - CUDA_VISIBLE_DEVICES= ./local/align.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} || exit -1 + CUDA_VISIBLE_DEVICES=${gpus} ./local/align.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} || exit -1 fi if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then From 080b0431f462d3639e552745e5cca4841556ab1c Mon Sep 17 00:00:00 2001 From: Hui Zhang Date: Wed, 10 Nov 2021 06:40:18 +0000 Subject: [PATCH 2/2] format code --- README.md | 7 +++---- paddlespeech/s2t/exps/u2_st/model.py | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f7a5df06a..f9901ccd6 100644 --- a/README.md +++ b/README.md @@ -187,7 +187,7 @@ The current hyperlinks redirect to [Previous Parakeet](https://github.com/Paddle Aishell DeepSpeech2 RNN + Conv based Models - deepspeech2-aishell + deepspeech2-aishell @@ -200,7 +200,7 @@ The current hyperlinks redirect to [Previous Parakeet](https://github.com/Paddle Librispeech Transformer based Attention Models - deepspeech2-librispeech / transformer.conformer.u2-librispeech / transformer.conformer.u2-kaldi-librispeech + deepspeech2-librispeech / transformer.conformer.u2-librispeech / transformer.conformer.u2-kaldi-librispeech @@ -223,7 +223,7 @@ The current hyperlinks redirect to [Previous Parakeet](https://github.com/Paddle TIMIT Unified Streaming & Non-streaming Two-pass - u2-timit + u2-timit @@ -351,4 +351,3 @@ howpublished = {\url{https://github.com/PaddlePaddle/PaddleSpeech}}, year={2021} } ``` - diff --git a/paddlespeech/s2t/exps/u2_st/model.py b/paddlespeech/s2t/exps/u2_st/model.py index 20bb31f53..52d3c3b7d 100644 --- a/paddlespeech/s2t/exps/u2_st/model.py +++ b/paddlespeech/s2t/exps/u2_st/model.py @@ -441,7 +441,7 @@ class U2STTester(U2STTrainer): "".join(chr(t) for t in text[:text_len]) for text, text_len in zip(texts, texts_len) ] - + hyps = self.model.decode( audio, audio_len,