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

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

chunk_mode=false
H
Hui Zhang 已提交
15
if [[ ${config_path} =~ ^.*chunk_.*yaml$ ]];then
J
Junkun 已提交
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
    chunk_mode=true
fi


# download language model
#bash local/download_lm_en.sh
#if [ $? -ne 0 ]; then
#    exit 1
#fi

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 已提交
35
    --nproc ${ngpu} \
J
Junkun 已提交
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
    --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

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 已提交
51
    --nproc ${ngpu}  \
J
Junkun 已提交
52 53 54 55 56 57 58 59 60 61 62 63 64
    --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