test.sh 1.4 KB
Newer Older
1
#!/bin/bash
2 3 4 5 6 7 8 9 10 11 12 13

if [ $# != 2 ];then
    echo "usage: ${0} config_path ckpt_path_prefix"
    exit -1
fi

ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}')
echo "using $ngpu gpus..."

config_path=$1
ckpt_prefix=$2

14
chunk_mode=false
H
Hui Zhang 已提交
15
if [[ ${config_path} =~ ^.*chunk_.*yaml$ ]];then
16 17 18
    chunk_mode=true
fi

19 20 21 22 23 24
# download language model
#bash local/download_lm_en.sh
#if [ $? -ne 0 ]; then
#    exit 1
#fi

25 26 27 28 29 30 31 32 33
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 \
H
Hui Zhang 已提交
34
    --nproc ${ngpu} \
35 36 37 38
    --config ${config_path} \
    --result_file ${ckpt_prefix}.${type}.rsl \
    --checkpoint_path ${ckpt_prefix} \
    --opts decoding.decoding_method ${type} decoding.batch_size ${batch_size}
39

40 41 42 43 44 45 46 47 48 49
    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 \
H
Hui Zhang 已提交
50
    --nproc ${ngpu} \
51 52 53 54
    --config ${config_path} \
    --result_file ${ckpt_prefix}.${type}.rsl \
    --checkpoint_path ${ckpt_prefix} \
    --opts decoding.decoding_method ${type} decoding.batch_size ${batch_size}
55

56 57 58 59 60
    if [ $? -ne 0 ]; then
        echo "Failed in evaluation!"
        exit 1
    fi
done
61 62

exit 0