diff --git a/examples/aishell/s0/local/client.sh b/examples/aishell/s0/local/client.sh index d626ecc756c70b966b6099a41168a65c701e644e..3b59ad3dff202a11cdae438661fbb43348502ec6 100755 --- a/examples/aishell/s0/local/client.sh +++ b/examples/aishell/s0/local/client.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash source path.sh diff --git a/examples/aishell/s0/local/data.sh b/examples/aishell/s0/local/data.sh index 2f09b14ad8d57e65ba7f3c1e5f337c6df540414f..b106f3f28322ced93cd0462f33056bd0d5876df4 100755 --- a/examples/aishell/s0/local/data.sh +++ b/examples/aishell/s0/local/data.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash stage=-1 stop_stage=100 diff --git a/examples/aishell/s0/local/download_lm_ch.sh b/examples/aishell/s0/local/download_lm_ch.sh index f9e2261fdd42fcab6e5d5643c32d48d4abe43c90..ac27a9076d9f7f3d1556c7dac10e31ea788ff622 100755 --- a/examples/aishell/s0/local/download_lm_ch.sh +++ b/examples/aishell/s0/local/download_lm_ch.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash . ${MAIN_ROOT}/utils/utility.sh diff --git a/examples/aishell/s0/local/export.sh b/examples/aishell/s0/local/export.sh index 1b19d5720b731bed8006d1faed03176dd4ba0c56..f99a15bade1c89f968e84a6c10d500466f884d5b 100755 --- a/examples/aishell/s0/local/export.sh +++ b/examples/aishell/s0/local/export.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash if [ $# != 3 ];then echo "usage: $0 config_path ckpt_prefix jit_model_path" @@ -13,7 +13,7 @@ ckpt_path_prefix=$2 jit_model_export_path=$3 device=gpu -if [ ngpu == 0 ];then +if [ ${ngpu} == 0 ];then device=cpu fi diff --git a/examples/aishell/s0/local/server.sh b/examples/aishell/s0/local/server.sh index 1cf069ebd531c8ea62827e89c741964500108745..184a143dafa3ed7edb9ffee5c2f3a986d41c4c03 100755 --- a/examples/aishell/s0/local/server.sh +++ b/examples/aishell/s0/local/server.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash # TODO: replace the model with a mandarin model if [[ $# != 1 ]];then diff --git a/examples/aishell/s0/local/test.sh b/examples/aishell/s0/local/test.sh index 6fd298202ea3dd8a111c47e4ed5047bc8ce27c0f..fd9cb5661fad7b05356a98635080ab0d2e3327c3 100755 --- a/examples/aishell/s0/local/test.sh +++ b/examples/aishell/s0/local/test.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash if [ $# != 2 ];then echo "usage: ${0} config_path ckpt_path_prefix" @@ -9,7 +9,7 @@ ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." device=gpu -if [ ngpu == 0 ];then +if [ ${ngpu} == 0 ];then device=cpu fi config_path=$1 diff --git a/examples/aishell/s0/local/train.sh b/examples/aishell/s0/local/train.sh index f8c9dbc0b5a708457294c6460b6d33ba27f6e9b9..f6bd2c98359b67292f9654c69ed11fc1a6720046 100755 --- a/examples/aishell/s0/local/train.sh +++ b/examples/aishell/s0/local/train.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash if [ $# != 2 ];then echo "usage: CUDA_VISIBLE_DEVICES=0 ${0} config_path ckpt_name" @@ -12,7 +12,7 @@ config_path=$1 ckpt_name=$2 device=gpu -if [ ngpu == 0 ];then +if [ ${ngpu} == 0 ];then device=cpu fi diff --git a/examples/aishell/s0/local/tune.sh b/examples/aishell/s0/local/tune.sh index 9ff5e8b99860ccfbcab67ab17206a7980c0d04b0..59406cd5b3b28f17a3a0d4cbb1e01c97f6cb3703 100755 --- a/examples/aishell/s0/local/tune.sh +++ b/examples/aishell/s0/local/tune.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash # grid-search for hyper-parameters in language model python3 -u ${BIN_DIR}/tune.py \ diff --git a/examples/aishell/s1/README.md b/examples/aishell/s1/README.md index 78e759c8f9cb93211dc1192aff779289111d3ec1..07cc569ed9262949741d1e183ca051bfb4de87dd 100644 --- a/examples/aishell/s1/README.md +++ b/examples/aishell/s1/README.md @@ -12,12 +12,12 @@ ## Chunk Conformer -| Model | Params | Config | Augmentation| Test set | Decode method | Chunk | Loss | WER | +| Model | Params | Config | Augmentation| Test set | Decode method | Chunk Size & Left Chunks | Loss | WER | | --- | --- | --- | --- | --- | --- | --- | --- | --- | -| conformer | 47.06M | conf/chunk_conformer.yaml | spec_aug + shift | test | attention | 16 | - | 0.061939 | -| conformer | 47.06M | conf/chunk_conformer.yaml | spec_aug + shift | test | ctc_greedy_search | 16 | - | 0.070806 | -| conformer | 47.06M | conf/chunk_conformer.yaml | spec_aug + shift | test | ctc_prefix_beam_search | 16 | - | 0.070739 | -| conformer | 47.06M | conf/chunk_conformer.yaml | spec_aug + shift | test | attention_rescoring | 16 | - | 0.059400 | +| conformer | 47.06M | conf/chunk_conformer.yaml | spec_aug + shift | test | attention | 16, -1 | - | 0.061939 | +| conformer | 47.06M | conf/chunk_conformer.yaml | spec_aug + shift | test | ctc_greedy_search | 16, -1 | - | 0.070806 | +| conformer | 47.06M | conf/chunk_conformer.yaml | spec_aug + shift | test | ctc_prefix_beam_search | 16, -1 | - | 0.070739 | +| conformer | 47.06M | conf/chunk_conformer.yaml | spec_aug + shift | test | attention_rescoring | 16, -1 | - | 0.059400 | ## Transformer diff --git a/examples/aishell/s1/local/align.sh b/examples/aishell/s1/local/align.sh index 926cb9397d422ba2b91fb8ca3cb28985f6936bc3..ad6c84bc8cf398cddecfadbbb47b7ef9c60e9158 100755 --- a/examples/aishell/s1/local/align.sh +++ b/examples/aishell/s1/local/align.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash if [ $# != 2 ];then echo "usage: ${0} config_path ckpt_path_prefix" @@ -9,18 +9,12 @@ ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." device=gpu -if [ ngpu == 0 ];then +if [ ${ngpu} == 0 ];then device=cpu fi config_path=$1 ckpt_prefix=$2 -ckpt_name=$(basename ${ckpt_prefxi}) - -mkdir -p exp - - - batch_size=1 output_dir=${ckpt_prefix} mkdir -p ${output_dir} diff --git a/examples/aishell/s1/local/data.sh b/examples/aishell/s1/local/data.sh index c6abce3b4cfbf1a2f7534c15908151ac1e728e19..8d5ac4d5939e108697d01d5e6624a83f50e34b16 100755 --- a/examples/aishell/s1/local/data.sh +++ b/examples/aishell/s1/local/data.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash stage=-1 stop_stage=100 diff --git a/examples/aishell/s1/local/export.sh b/examples/aishell/s1/local/export.sh index 1b19d5720b731bed8006d1faed03176dd4ba0c56..f99a15bade1c89f968e84a6c10d500466f884d5b 100755 --- a/examples/aishell/s1/local/export.sh +++ b/examples/aishell/s1/local/export.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash if [ $# != 3 ];then echo "usage: $0 config_path ckpt_prefix jit_model_path" @@ -13,7 +13,7 @@ ckpt_path_prefix=$2 jit_model_export_path=$3 device=gpu -if [ ngpu == 0 ];then +if [ ${ngpu} == 0 ];then device=cpu fi diff --git a/examples/aishell/s1/local/test.sh b/examples/aishell/s1/local/test.sh index 073aaffd4ddfe1a982280c7c0891a05b10f2ad12..1886590ff72ec7d04f9c2f1f798b108df14610ea 100755 --- a/examples/aishell/s1/local/test.sh +++ b/examples/aishell/s1/local/test.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash if [ $# != 2 ];then echo "usage: ${0} config_path ckpt_path_prefix" @@ -9,15 +9,17 @@ ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." device=gpu -if [ ngpu == 0 ];then +if [ ${ngpu} == 0 ];then device=cpu fi + config_path=$1 ckpt_prefix=$2 -ckpt_name=$(basename ${ckpt_prefxi}) - -mkdir -p exp +chunk_mode=false +if [[ ${config_path} =~ ^chunk_ ]];then + chunk_mode=true +fi # download language model #bash local/download_lm_ch.sh @@ -28,7 +30,12 @@ mkdir -p exp for type in attention ctc_greedy_search; do echo "decoding ${type}" - batch_size=64 + if [ ${chunk_mode} == true ];then + # stream decoding only support batchsize=1 + batch_size=1 + else + batch_size=64 + fi output_dir=${ckpt_prefix} mkdir -p ${output_dir} python3 -u ${BIN_DIR}/test.py \ diff --git a/examples/aishell/s1/local/train.sh b/examples/aishell/s1/local/train.sh index a4218aa861431c048256f22661b232a67a04f479..f3eb98daf6da6c818de1cd2fc2f56e96ff6a926c 100755 --- a/examples/aishell/s1/local/train.sh +++ b/examples/aishell/s1/local/train.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash if [ $# != 2 ];then echo "usage: CUDA_VISIBLE_DEVICES=0 ${0} config_path ckpt_name" @@ -12,7 +12,7 @@ config_path=$1 ckpt_name=$2 device=gpu -if [ ngpu == 0 ];then +if [ ${ngpu} == 0 ];then device=cpu fi echo "using ${device}..." diff --git a/examples/librispeech/s0/local/data.sh b/examples/librispeech/s0/local/data.sh index 921f1f49a264340d7f6d31f333fcfd96084b5b5d..b71809869d431a716d0f5bc0ca1ffd845b943f08 100755 --- a/examples/librispeech/s0/local/data.sh +++ b/examples/librispeech/s0/local/data.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash stage=-1 stop_stage=100 diff --git a/examples/librispeech/s0/local/download_lm_en.sh b/examples/librispeech/s0/local/download_lm_en.sh index 05ea793fb0edb711ab63804f12f0de1faf22fd3b..dc1bdf665ac7783bc1e7344fbcbddc0b9744f44b 100755 --- a/examples/librispeech/s0/local/download_lm_en.sh +++ b/examples/librispeech/s0/local/download_lm_en.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash . ${MAIN_ROOT}/utils/utility.sh diff --git a/examples/librispeech/s0/local/export.sh b/examples/librispeech/s0/local/export.sh index 1b19d5720b731bed8006d1faed03176dd4ba0c56..f99a15bade1c89f968e84a6c10d500466f884d5b 100755 --- a/examples/librispeech/s0/local/export.sh +++ b/examples/librispeech/s0/local/export.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash if [ $# != 3 ];then echo "usage: $0 config_path ckpt_prefix jit_model_path" @@ -13,7 +13,7 @@ ckpt_path_prefix=$2 jit_model_export_path=$3 device=gpu -if [ ngpu == 0 ];then +if [ ${ngpu} == 0 ];then device=cpu fi diff --git a/examples/librispeech/s0/local/test.sh b/examples/librispeech/s0/local/test.sh index 79e05838ccb3d3b6575c19e58ec93c324d8f8060..16a5e9ef0d2045f48d4acafe18dec3cfef992e52 100755 --- a/examples/librispeech/s0/local/test.sh +++ b/examples/librispeech/s0/local/test.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash if [ $# != 2 ];then echo "usage: ${0} config_path ckpt_path_prefix" @@ -9,7 +9,7 @@ ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." device=gpu -if [ ngpu == 0 ];then +if [ ${ngpu} == 0 ];then device=cpu fi config_path=$1 diff --git a/examples/librispeech/s0/local/train.sh b/examples/librispeech/s0/local/train.sh index a4218aa861431c048256f22661b232a67a04f479..f3eb98daf6da6c818de1cd2fc2f56e96ff6a926c 100755 --- a/examples/librispeech/s0/local/train.sh +++ b/examples/librispeech/s0/local/train.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash if [ $# != 2 ];then echo "usage: CUDA_VISIBLE_DEVICES=0 ${0} config_path ckpt_name" @@ -12,7 +12,7 @@ config_path=$1 ckpt_name=$2 device=gpu -if [ ngpu == 0 ];then +if [ ${ngpu} == 0 ];then device=cpu fi echo "using ${device}..." diff --git a/examples/librispeech/s0/local/tune.sh b/examples/librispeech/s0/local/tune.sh index 4bb81d29bb8c22b10a80ab1d6138ed4e63127078..c344e77e58a52c803bd69e1bd27804c8d0072415 100755 --- a/examples/librispeech/s0/local/tune.sh +++ b/examples/librispeech/s0/local/tune.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash if [ $# != 1 ];then echo "usage: tune ckpt_path" diff --git a/examples/librispeech/s1/README.md b/examples/librispeech/s1/README.md index 5e23c0ab5f582d35cdb4dd41a9c3066d82f65b91..5b4130bb2550901548f1d064f7384da351fc80ce 100644 --- a/examples/librispeech/s1/README.md +++ b/examples/librispeech/s1/README.md @@ -10,6 +10,18 @@ | conformer | 47.63 M | conf/conformer.yaml | spec_aug + shift | test-clean | ctc_prefix_beam_search | 6.35 | 0.037761 | | conformer | 47.63 M | conf/conformer.yaml | spec_aug + shift | test-clean | attention_rescoring | 6.35 | 0.032115 | + +## Chunk Conformer + +| Model | Params | Config | Augmentation| Test set | Decode method | Chunk Size & Left Chunks | Loss | WER | +| --- | --- | --- | --- | --- | --- | --- | --- | --- | +| conformer | 47.63 M | conf/chunk_conformer.yaml | spec_aug + shift | test-clean | attention | 16, -1 | 7.01250648 | | +| conformer | 47.63 M | conf/chunk_conformer.yaml | spec_aug + shift | test-clean | ctc_greedy_search | 16, -1 | 7.01250648 | | +| conformer | 47.63 M | conf/chunk_conformer.yaml | spec_aug + shift | test-clean | ctc_prefix_beam_search | 16, -1 | 7.01250648 | | +| conformer | 47.63 M | conf/chunk_conformer.yaml | spec_aug + shift | test-clean | attention_rescoring | 16, -1 | 7.01250648 | | + + + ## Transformer | Model | Params | Config | Augmentation| Test set | Decode method | Loss | WER | diff --git a/examples/librispeech/s1/conf/chunk_confermer.yaml b/examples/librispeech/s1/conf/chunk_confermer.yaml index 5af6895949bb1afa7f9bb0ee8b09667a631f1ce0..d78ce74015e8a704ca7b1937a3ce63975b807803 100644 --- a/examples/librispeech/s1/conf/chunk_confermer.yaml +++ b/examples/librispeech/s1/conf/chunk_confermer.yaml @@ -110,7 +110,7 @@ decoding: cutoff_top_n: 0 num_proc_bsearch: 8 ctc_weight: 0.5 # ctc weight for attention rescoring decode mode. - decoding_chunk_size: -1 # decoding chunk size. Defaults to -1. + decoding_chunk_size: 16 # decoding chunk size. Defaults to -1. # <0: for decoding, use full chunk. # >0: for decoding, use fixed chunk size as set. # 0: used for training, it's prohibited here. diff --git a/examples/librispeech/s1/local/align.sh b/examples/librispeech/s1/local/align.sh index 926cb9397d422ba2b91fb8ca3cb28985f6936bc3..ad6c84bc8cf398cddecfadbbb47b7ef9c60e9158 100755 --- a/examples/librispeech/s1/local/align.sh +++ b/examples/librispeech/s1/local/align.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash if [ $# != 2 ];then echo "usage: ${0} config_path ckpt_path_prefix" @@ -9,18 +9,12 @@ ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." device=gpu -if [ ngpu == 0 ];then +if [ ${ngpu} == 0 ];then device=cpu fi config_path=$1 ckpt_prefix=$2 -ckpt_name=$(basename ${ckpt_prefxi}) - -mkdir -p exp - - - batch_size=1 output_dir=${ckpt_prefix} mkdir -p ${output_dir} diff --git a/examples/librispeech/s1/local/data.sh b/examples/librispeech/s1/local/data.sh index fbdd17d58fb9f36d1a5902e155d13eb132576f8d..4ad476d3785ba8b9515d3e9eea37f3a568dc8256 100755 --- a/examples/librispeech/s1/local/data.sh +++ b/examples/librispeech/s1/local/data.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash stage=-1 stop_stage=100 diff --git a/examples/librispeech/s1/local/download_lm_en.sh b/examples/librispeech/s1/local/download_lm_en.sh index 05ea793fb0edb711ab63804f12f0de1faf22fd3b..dc1bdf665ac7783bc1e7344fbcbddc0b9744f44b 100755 --- a/examples/librispeech/s1/local/download_lm_en.sh +++ b/examples/librispeech/s1/local/download_lm_en.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash . ${MAIN_ROOT}/utils/utility.sh diff --git a/examples/librispeech/s1/local/export.sh b/examples/librispeech/s1/local/export.sh index 1b19d5720b731bed8006d1faed03176dd4ba0c56..f99a15bade1c89f968e84a6c10d500466f884d5b 100755 --- a/examples/librispeech/s1/local/export.sh +++ b/examples/librispeech/s1/local/export.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash if [ $# != 3 ];then echo "usage: $0 config_path ckpt_prefix jit_model_path" @@ -13,7 +13,7 @@ ckpt_path_prefix=$2 jit_model_export_path=$3 device=gpu -if [ ngpu == 0 ];then +if [ ${ngpu} == 0 ];then device=cpu fi diff --git a/examples/librispeech/s1/local/test.sh b/examples/librispeech/s1/local/test.sh index 8c323e0027b0cc06c1a01ce938340ff146a108be..fe01d70043d23d5ee699d136c906c2630292cc6d 100755 --- a/examples/librispeech/s1/local/test.sh +++ b/examples/librispeech/s1/local/test.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash if [ $# != 2 ];then echo "usage: ${0} config_path ckpt_path_prefix" @@ -9,12 +9,19 @@ ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." device=gpu -if [ ngpu == 0 ];then +if [ ${ngpu} == 0 ];then device=cpu fi + config_path=$1 ckpt_prefix=$2 +chunk_mode=false +if [[ ${config_path} =~ ^chunk_ ]];then + chunk_mode=true +fi + + # download language model #bash local/download_lm_en.sh #if [ $? -ne 0 ]; then @@ -23,7 +30,12 @@ ckpt_prefix=$2 for type in attention ctc_greedy_search; do echo "decoding ${type}" - batch_size=64 + if [ ${chunk_mode} == true ];then + # stream decoding only support batchsize=1 + batch_size=1 + else + batch_size=64 + fi python3 -u ${BIN_DIR}/test.py \ --device ${device} \ --nproc 1 \ diff --git a/examples/librispeech/s1/local/train.sh b/examples/librispeech/s1/local/train.sh index a4218aa861431c048256f22661b232a67a04f479..f3eb98daf6da6c818de1cd2fc2f56e96ff6a926c 100755 --- a/examples/librispeech/s1/local/train.sh +++ b/examples/librispeech/s1/local/train.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash if [ $# != 2 ];then echo "usage: CUDA_VISIBLE_DEVICES=0 ${0} config_path ckpt_name" @@ -12,7 +12,7 @@ config_path=$1 ckpt_name=$2 device=gpu -if [ ngpu == 0 ];then +if [ ${ngpu} == 0 ];then device=cpu fi echo "using ${device}..." diff --git a/examples/tiny/s0/local/data.sh b/examples/tiny/s0/local/data.sh index 727a3da9500496ccaaa1497590ceb3bdc4aadf63..02fdb70673e639c47ccc79c550e6507fe016cb45 100755 --- a/examples/tiny/s0/local/data.sh +++ b/examples/tiny/s0/local/data.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash stage=-1 stop_stage=100 diff --git a/examples/tiny/s0/local/download_lm_en.sh b/examples/tiny/s0/local/download_lm_en.sh index 05ea793fb0edb711ab63804f12f0de1faf22fd3b..dc1bdf665ac7783bc1e7344fbcbddc0b9744f44b 100755 --- a/examples/tiny/s0/local/download_lm_en.sh +++ b/examples/tiny/s0/local/download_lm_en.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash . ${MAIN_ROOT}/utils/utility.sh diff --git a/examples/tiny/s0/local/export.sh b/examples/tiny/s0/local/export.sh index 1b19d5720b731bed8006d1faed03176dd4ba0c56..f99a15bade1c89f968e84a6c10d500466f884d5b 100755 --- a/examples/tiny/s0/local/export.sh +++ b/examples/tiny/s0/local/export.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash if [ $# != 3 ];then echo "usage: $0 config_path ckpt_prefix jit_model_path" @@ -13,7 +13,7 @@ ckpt_path_prefix=$2 jit_model_export_path=$3 device=gpu -if [ ngpu == 0 ];then +if [ ${ngpu} == 0 ];then device=cpu fi diff --git a/examples/tiny/s0/local/test.sh b/examples/tiny/s0/local/test.sh index 79e05838ccb3d3b6575c19e58ec93c324d8f8060..16a5e9ef0d2045f48d4acafe18dec3cfef992e52 100755 --- a/examples/tiny/s0/local/test.sh +++ b/examples/tiny/s0/local/test.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash if [ $# != 2 ];then echo "usage: ${0} config_path ckpt_path_prefix" @@ -9,7 +9,7 @@ ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." device=gpu -if [ ngpu == 0 ];then +if [ ${ngpu} == 0 ];then device=cpu fi config_path=$1 diff --git a/examples/tiny/s0/local/train.sh b/examples/tiny/s0/local/train.sh index f8c9dbc0b5a708457294c6460b6d33ba27f6e9b9..f6bd2c98359b67292f9654c69ed11fc1a6720046 100755 --- a/examples/tiny/s0/local/train.sh +++ b/examples/tiny/s0/local/train.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash if [ $# != 2 ];then echo "usage: CUDA_VISIBLE_DEVICES=0 ${0} config_path ckpt_name" @@ -12,7 +12,7 @@ config_path=$1 ckpt_name=$2 device=gpu -if [ ngpu == 0 ];then +if [ ${ngpu} == 0 ];then device=cpu fi diff --git a/examples/tiny/s0/local/tune.sh b/examples/tiny/s0/local/tune.sh index 4bb81d29bb8c22b10a80ab1d6138ed4e63127078..c344e77e58a52c803bd69e1bd27804c8d0072415 100755 --- a/examples/tiny/s0/local/tune.sh +++ b/examples/tiny/s0/local/tune.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash if [ $# != 1 ];then echo "usage: tune ckpt_path" diff --git a/examples/tiny/s1/local/align.sh b/examples/tiny/s1/local/align.sh index 926cb9397d422ba2b91fb8ca3cb28985f6936bc3..ad6c84bc8cf398cddecfadbbb47b7ef9c60e9158 100755 --- a/examples/tiny/s1/local/align.sh +++ b/examples/tiny/s1/local/align.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash if [ $# != 2 ];then echo "usage: ${0} config_path ckpt_path_prefix" @@ -9,18 +9,12 @@ ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." device=gpu -if [ ngpu == 0 ];then +if [ ${ngpu} == 0 ];then device=cpu fi config_path=$1 ckpt_prefix=$2 -ckpt_name=$(basename ${ckpt_prefxi}) - -mkdir -p exp - - - batch_size=1 output_dir=${ckpt_prefix} mkdir -p ${output_dir} diff --git a/examples/tiny/s1/local/data.sh b/examples/tiny/s1/local/data.sh index deff91e03f4002d82b845344fdf66070eb37bc4b..2aea250b5decf5ecfffa92c7330d34d6e3e6cf81 100755 --- a/examples/tiny/s1/local/data.sh +++ b/examples/tiny/s1/local/data.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash stage=-1 stop_stage=100 diff --git a/examples/tiny/s1/local/export.sh b/examples/tiny/s1/local/export.sh index 1b19d5720b731bed8006d1faed03176dd4ba0c56..f99a15bade1c89f968e84a6c10d500466f884d5b 100755 --- a/examples/tiny/s1/local/export.sh +++ b/examples/tiny/s1/local/export.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash if [ $# != 3 ];then echo "usage: $0 config_path ckpt_prefix jit_model_path" @@ -13,7 +13,7 @@ ckpt_path_prefix=$2 jit_model_export_path=$3 device=gpu -if [ ngpu == 0 ];then +if [ ${ngpu} == 0 ];then device=cpu fi diff --git a/examples/tiny/s1/local/test.sh b/examples/tiny/s1/local/test.sh index 240a63b06afab0b24ba3c1ff5421d1034c8fe1de..eb5e995dfb9347f792b8d54f37c2f6cb7cd986d9 100755 --- a/examples/tiny/s1/local/test.sh +++ b/examples/tiny/s1/local/test.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash if [ $# != 2 ];then echo "usage: ${0} config_path ckpt_path_prefix" @@ -9,29 +9,60 @@ ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." device=gpu -if [ ngpu == 0 ];then +if [ ${ngpu} == 0 ];then device=cpu fi config_path=$1 ckpt_prefix=$2 +chunk_mode=false +if [[ ${config_path} =~ ^chunk_ ]];then + chunk_mode=true +fi + # download language model #bash local/download_lm_en.sh #if [ $? -ne 0 ]; then # exit 1 #fi -python3 -u ${BIN_DIR}/test.py \ ---device ${device} \ ---nproc 1 \ ---config ${config_path} \ ---result_file ${ckpt_prefix}.rsl \ ---checkpoint_path ${ckpt_prefix} +for type in attention ctc_greedy_search; do + echo "decoding ${type}" + if [ ${chunk_mode} == true ];then + # stream decoding only support batchsize=1 + batch_size=1 + else + batch_size=64 + fi + python3 -u ${BIN_DIR}/test.py \ + --device ${device} \ + --nproc 1 \ + --config ${config_path} \ + --result_file ${ckpt_prefix}.${type}.rsl \ + --checkpoint_path ${ckpt_prefix} \ + --opts decoding.decoding_method ${type} decoding.batch_size ${batch_size} -if [ $? -ne 0 ]; then - echo "Failed in evaluation!" - exit 1 -fi + if [ $? -ne 0 ]; then + echo "Failed in evaluation!" + exit 1 + fi +done + +for type in ctc_prefix_beam_search attention_rescoring; do + echo "decoding ${type}" + batch_size=1 + python3 -u ${BIN_DIR}/test.py \ + --device ${device} \ + --nproc 1 \ + --config ${config_path} \ + --result_file ${ckpt_prefix}.${type}.rsl \ + --checkpoint_path ${ckpt_prefix} \ + --opts decoding.decoding_method ${type} decoding.batch_size ${batch_size} + if [ $? -ne 0 ]; then + echo "Failed in evaluation!" + exit 1 + fi +done exit 0 diff --git a/examples/tiny/s1/local/train.sh b/examples/tiny/s1/local/train.sh index f8c9dbc0b5a708457294c6460b6d33ba27f6e9b9..f6bd2c98359b67292f9654c69ed11fc1a6720046 100755 --- a/examples/tiny/s1/local/train.sh +++ b/examples/tiny/s1/local/train.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#!/bin/bash if [ $# != 2 ];then echo "usage: CUDA_VISIBLE_DEVICES=0 ${0} config_path ckpt_name" @@ -12,7 +12,7 @@ config_path=$1 ckpt_name=$2 device=gpu -if [ ngpu == 0 ];then +if [ ${ngpu} == 0 ];then device=cpu fi