paraformer_large_infer.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/env bash
  2. set -e
  3. set -u
  4. set -o pipefail
  5. ori_data=
  6. data_dir=
  7. exp_dir=
  8. model_name=speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch
  9. model_revision="v1.0.4" # please do not modify the model revision
  10. inference_nj=32
  11. gpuid_list="0" # set gpus, e.g., gpuid_list="0,1"
  12. ngpu=$(echo $gpuid_list | awk -F "," '{print NF}')
  13. njob=1 # the number of jobs for each gpu
  14. gpu_inference=true # Whether to perform gpu decoding, set false for cpu decoding
  15. if ${gpu_inference}; then
  16. inference_nj=$[${ngpu}*${njob}]
  17. else
  18. inference_nj=$njob
  19. fi
  20. # LM configs
  21. use_lm=false
  22. beam_size=1
  23. lm_weight=0.0
  24. test_sets="dev test_meeting test_net"
  25. . utils/parse_options.sh
  26. for tset_name in ${test_sets}; do
  27. test_dir=${data_dir}/wenetspeech/${tset_name}
  28. mkdir -p ${test_dir}
  29. find ${ori_data}/${tset_name} -iname "*.wav" > ${test_dir}/wav.flist
  30. sed -e 's/\.wav//' ${test_dir}/wav.flist | awk -F '/' '{print $NF}' > ${test_dir}/utt.list
  31. paste -d' ' ${test_dir}/utt.list ${test_dir}/wav.flist > ${test_dir}/wav.scp
  32. cp ${ori_data}/${tset_name}/trans.txt ${test_dir}/text
  33. sed -i "s/\t/ /g" ${test_dir}/text
  34. done
  35. mkdir -p ${exp_dir}/wenetspeech
  36. modelscope_utils/modelscope_infer.sh \
  37. --data_dir ${data_dir}/wenetspeech \
  38. --exp_dir ${exp_dir}/wenetspeech \
  39. --test_sets "${test_sets}" \
  40. --model_name ${model_name} \
  41. --model_revision ${model_revision} \
  42. --inference_nj ${inference_nj} \
  43. --gpuid_list ${gpuid_list} \
  44. --njob ${njob} \
  45. --gpu_inference ${gpu_inference} \
  46. --use_lm ${use_lm} \
  47. --beam_size ${beam_size} \
  48. --lm_weight ${lm_weight}