run.sh 1.8 KB
Newer Older
1 2
#!/bin/bash
source path.sh
3
set -e
4

H
Hui Zhang 已提交
5
gpus=0,1,2,3
6 7 8 9 10 11 12 13 14 15 16
stage=0
stop_stage=100
conf_path=conf/conformer.yaml
avg_num=20

source ${MAIN_ROOT}/utils/parse_options.sh || exit 1;

avg_ckpt=avg_${avg_num}
ckpt=$(basename ${conf_path} | awk -F'.' '{print $1}')
echo "checkpoint name ${ckpt}"

17 18
audio_file="data/tmp.wav"

19 20 21 22 23 24 25
if [ ${stage} -le 0 ] && [ ${stop_stage} -ge 0 ]; then
    # prepare data
    bash ./local/data.sh || exit -1
fi

if [ ${stage} -le 1 ] && [ ${stop_stage} -ge 1 ]; then
    # train model, all `ckpt` under `exp` dir
H
Hui Zhang 已提交
26
    CUDA_VISIBLE_DEVICES=${gpus} ./local/train.sh ${conf_path}  ${ckpt}
27 28 29 30
fi

if [ ${stage} -le 2 ] && [ ${stop_stage} -ge 2 ]; then
    # avg n best model
H
Hui Zhang 已提交
31
    avg.sh best exp/${ckpt}/checkpoints ${avg_num}
32 33 34 35
fi

if [ ${stage} -le 3 ] && [ ${stop_stage} -ge 3 ]; then
    # test ckpt avg_n
H
Hui Zhang 已提交
36
    CUDA_VISIBLE_DEVICES=0 ./local/test.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} || exit -1
37 38 39
fi

if [ ${stage} -le 4 ] && [ ${stop_stage} -ge 4 ]; then
H
Hui Zhang 已提交
40 41 42 43
    # ctc alignment of test data
    CUDA_VISIBLE_DEVICES=0 ./local/align.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} || exit -1
fi

H
Hui Zhang 已提交
44 45 46 47
# if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
#     # export ckpt avg_n
#     CUDA_VISIBLE_DEVICES=0 ./local/export.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} exp/${ckpt}/checkpoints/${avg_ckpt}.jit
# fi
H
Hui Zhang 已提交
48

H
Hui Zhang 已提交
49 50 51 52 53
# 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
54 55

if [ ${stage} -le 7 ] && [ ${stop_stage} -ge 7 ]; then
H
Hui Zhang 已提交
56 57 58
    echo "warning: deps on kaldi and srilm, please make sure installed."
    # train lm and build TLG
    ./local/tlg.sh --corpus aishell --lmtype srilm
59
fi