mirror of
https://github.com/modelscope/FunASR
synced 2025-09-15 14:48:36 +08:00
bugfix
This commit is contained in:
parent
36204b3990
commit
cab0af88d8
12
examples/aishell/branchformer/infer.sh
Normal file
12
examples/aishell/branchformer/infer.sh
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
|
||||||
|
python -m funasr.bin.inference \
|
||||||
|
--config-path="/mnt/workspace/FunASR/examples/aishell/paraformer/exp/baseline_paraformer_conformer_12e_6d_2048_256_zh_char_exp3" \
|
||||||
|
--config-name="config.yaml" \
|
||||||
|
++init_param="/mnt/workspace/FunASR/examples/aishell/paraformer/exp/baseline_paraformer_conformer_12e_6d_2048_256_zh_char_exp3/model.pt.ep38" \
|
||||||
|
++tokenizer_conf.token_list="/mnt/nfs/zhifu.gzf/data/AISHELL-1-feats/DATA/data/zh_token_list/char/tokens.txt" \
|
||||||
|
++frontend_conf.cmvn_file="/mnt/nfs/zhifu.gzf/data/AISHELL-1-feats/DATA/data/train/am.mvn" \
|
||||||
|
++input="/mnt/nfs/zhifu.gzf/data/AISHELL-1/data_aishell/wav/train/S0002/BAC009S0002W0122.wav" \
|
||||||
|
++output_dir="./outputs/debug" \
|
||||||
|
++device="cuda:0" \
|
||||||
|
|
||||||
@ -43,6 +43,7 @@ config=branchformer_12e_6d_2048_256.yaml
|
|||||||
model_dir="baseline_$(basename "${config}" .yaml)_${lang}_${token_type}_${tag}"
|
model_dir="baseline_$(basename "${config}" .yaml)_${lang}_${token_type}_${tag}"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if [ ${stage} -le -1 ] && [ ${stop_stage} -ge -1 ]; then
|
if [ ${stage} -le -1 ] && [ ${stop_stage} -ge -1 ]; then
|
||||||
echo "stage -1: Data Download"
|
echo "stage -1: Data Download"
|
||||||
mkdir -p ${raw_data}
|
mkdir -p ${raw_data}
|
||||||
@ -130,7 +131,7 @@ fi
|
|||||||
if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
|
if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
|
||||||
echo "stage 5: Inference"
|
echo "stage 5: Inference"
|
||||||
|
|
||||||
if ${inference_device} == "cuda"; then
|
if [ ${inference_device} == "cuda" ]; then
|
||||||
nj=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}')
|
nj=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}')
|
||||||
else
|
else
|
||||||
inference_batch_size=1
|
inference_batch_size=1
|
||||||
@ -142,7 +143,7 @@ if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
|
|||||||
|
|
||||||
for dset in ${test_sets}; do
|
for dset in ${test_sets}; do
|
||||||
|
|
||||||
inference_dir="${exp_dir}/exp/${model_dir}/${inference_checkpoint}/${dset}"
|
inference_dir="${exp_dir}/exp/${model_dir}/inference-${inference_checkpoint}/${dset}"
|
||||||
_logdir="${inference_dir}/logdir"
|
_logdir="${inference_dir}/logdir"
|
||||||
|
|
||||||
mkdir -p "${_logdir}"
|
mkdir -p "${_logdir}"
|
||||||
@ -155,7 +156,7 @@ if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
|
|||||||
done
|
done
|
||||||
utils/split_scp.pl "${key_file}" ${split_scps}
|
utils/split_scp.pl "${key_file}" ${split_scps}
|
||||||
|
|
||||||
gpuid_list_array=(${gpuid_list//,/ })
|
gpuid_list_array=(${CUDA_VISIBLE_DEVICES//,/ })
|
||||||
for JOB in $(seq ${nj}); do
|
for JOB in $(seq ${nj}); do
|
||||||
{
|
{
|
||||||
id=$((JOB-1))
|
id=$((JOB-1))
|
||||||
@ -171,7 +172,7 @@ if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
|
|||||||
++input="${_logdir}/keys.${JOB}.scp" \
|
++input="${_logdir}/keys.${JOB}.scp" \
|
||||||
++output_dir="${inference_dir}/${JOB}" \
|
++output_dir="${inference_dir}/${JOB}" \
|
||||||
++device="${inference_device}" \
|
++device="${inference_device}" \
|
||||||
++batch_size="${inference_batch_size}"
|
++batch_size="${inference_batch_size}" &> ${_logdir}/log.${JOB}.txt
|
||||||
}&
|
}&
|
||||||
|
|
||||||
done
|
done
|
||||||
@ -187,8 +188,8 @@ if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
|
|||||||
done
|
done
|
||||||
|
|
||||||
echo "Computing WER ..."
|
echo "Computing WER ..."
|
||||||
cp ${inference_dir}/1best_recog/text ${inference_dir}/1best_recog/text.proc
|
python utils/postprocess_text_zh.py ${inference_dir}/1best_recog/text ${inference_dir}/1best_recog/text.proc
|
||||||
cp ${data_dir}/text ${inference_dir}/1best_recog/text.ref
|
python utils/postprocess_text_zh.py ${data_dir}/text ${inference_dir}/1best_recog/text.ref
|
||||||
python utils/compute_wer.py ${inference_dir}/1best_recog/text.ref ${inference_dir}/1best_recog/text.proc ${inference_dir}/1best_recog/text.cer
|
python utils/compute_wer.py ${inference_dir}/1best_recog/text.ref ${inference_dir}/1best_recog/text.proc ${inference_dir}/1best_recog/text.cer
|
||||||
tail -n 3 ${inference_dir}/1best_recog/text.cer
|
tail -n 3 ${inference_dir}/1best_recog/text.cer
|
||||||
done
|
done
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
python funasr/bin/inference.py \
|
python -m funasr.bin.inference \
|
||||||
--config-path="/mnt/workspace/FunASR/examples/aishell/paraformer/exp/baseline_paraformer_conformer_12e_6d_2048_256_zh_char_exp3" \
|
--config-path="/mnt/workspace/FunASR/examples/aishell/paraformer/exp/baseline_paraformer_conformer_12e_6d_2048_256_zh_char_exp3" \
|
||||||
--config-name="config.yaml" \
|
--config-name="config.yaml" \
|
||||||
++init_param="/mnt/workspace/FunASR/examples/aishell/paraformer/exp/baseline_paraformer_conformer_12e_6d_2048_256_zh_char_exp3/model.pt.ep38" \
|
++init_param="/mnt/workspace/FunASR/examples/aishell/paraformer/exp/baseline_paraformer_conformer_12e_6d_2048_256_zh_char_exp3/model.pt.ep38" \
|
||||||
@ -8,5 +8,5 @@ python funasr/bin/inference.py \
|
|||||||
++frontend_conf.cmvn_file="/mnt/nfs/zhifu.gzf/data/AISHELL-1-feats/DATA/data/train/am.mvn" \
|
++frontend_conf.cmvn_file="/mnt/nfs/zhifu.gzf/data/AISHELL-1-feats/DATA/data/train/am.mvn" \
|
||||||
++input="/mnt/nfs/zhifu.gzf/data/AISHELL-1/data_aishell/wav/train/S0002/BAC009S0002W0122.wav" \
|
++input="/mnt/nfs/zhifu.gzf/data/AISHELL-1/data_aishell/wav/train/S0002/BAC009S0002W0122.wav" \
|
||||||
++output_dir="./outputs/debug" \
|
++output_dir="./outputs/debug" \
|
||||||
++device="cpu" \
|
++device="cuda:0" \
|
||||||
|
|
||||||
|
|||||||
@ -14,10 +14,10 @@ stop_stage=5
|
|||||||
# feature configuration
|
# feature configuration
|
||||||
nj=32
|
nj=32
|
||||||
|
|
||||||
inference_device="cuda" #"cpu"
|
inference_device="cuda" #"cpu", "cuda:0", "cuda:1"
|
||||||
inference_checkpoint="model.pt"
|
inference_checkpoint="model.pt"
|
||||||
inference_scp="wav.scp"
|
inference_scp="wav.scp"
|
||||||
inference_batch_size=32
|
inference_batch_size=1
|
||||||
|
|
||||||
# data
|
# data
|
||||||
raw_data=../raw_data
|
raw_data=../raw_data
|
||||||
@ -142,7 +142,7 @@ if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
|
|||||||
|
|
||||||
for dset in ${test_sets}; do
|
for dset in ${test_sets}; do
|
||||||
|
|
||||||
inference_dir="${exp_dir}/exp/${model_dir}/${inference_checkpoint}/${dset}"
|
inference_dir="${exp_dir}/exp/${model_dir}/inference-${inference_checkpoint}/${dset}"
|
||||||
_logdir="${inference_dir}/logdir"
|
_logdir="${inference_dir}/logdir"
|
||||||
|
|
||||||
mkdir -p "${_logdir}"
|
mkdir -p "${_logdir}"
|
||||||
@ -155,7 +155,7 @@ if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
|
|||||||
done
|
done
|
||||||
utils/split_scp.pl "${key_file}" ${split_scps}
|
utils/split_scp.pl "${key_file}" ${split_scps}
|
||||||
|
|
||||||
gpuid_list_array=(${gpuid_list//,/ })
|
gpuid_list_array=(${CUDA_VISIBLE_DEVICES//,/ })
|
||||||
for JOB in $(seq ${nj}); do
|
for JOB in $(seq ${nj}); do
|
||||||
{
|
{
|
||||||
id=$((JOB-1))
|
id=$((JOB-1))
|
||||||
@ -187,8 +187,8 @@ if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
|
|||||||
done
|
done
|
||||||
|
|
||||||
echo "Computing WER ..."
|
echo "Computing WER ..."
|
||||||
cp ${inference_dir}/1best_recog/text ${inference_dir}/1best_recog/text.proc
|
python utils/postprocess_text_zh.py ${inference_dir}/1best_recog/text ${inference_dir}/1best_recog/text.proc
|
||||||
cp ${data_dir}/text ${inference_dir}/1best_recog/text.ref
|
python utils/postprocess_text_zh.py ${data_dir}/text ${inference_dir}/1best_recog/text.ref
|
||||||
python utils/compute_wer.py ${inference_dir}/1best_recog/text.ref ${inference_dir}/1best_recog/text.proc ${inference_dir}/1best_recog/text.cer
|
python utils/compute_wer.py ${inference_dir}/1best_recog/text.ref ${inference_dir}/1best_recog/text.proc ${inference_dir}/1best_recog/text.cer
|
||||||
tail -n 3 ${inference_dir}/1best_recog/text.cer
|
tail -n 3 ${inference_dir}/1best_recog/text.cer
|
||||||
done
|
done
|
||||||
|
|||||||
12
examples/aishell/e_branchformer/infer.sh
Normal file
12
examples/aishell/e_branchformer/infer.sh
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
|
||||||
|
python -m funasr.bin.inference \
|
||||||
|
--config-path="/mnt/workspace/FunASR/examples/aishell/paraformer/exp/baseline_paraformer_conformer_12e_6d_2048_256_zh_char_exp3" \
|
||||||
|
--config-name="config.yaml" \
|
||||||
|
++init_param="/mnt/workspace/FunASR/examples/aishell/paraformer/exp/baseline_paraformer_conformer_12e_6d_2048_256_zh_char_exp3/model.pt.ep38" \
|
||||||
|
++tokenizer_conf.token_list="/mnt/nfs/zhifu.gzf/data/AISHELL-1-feats/DATA/data/zh_token_list/char/tokens.txt" \
|
||||||
|
++frontend_conf.cmvn_file="/mnt/nfs/zhifu.gzf/data/AISHELL-1-feats/DATA/data/train/am.mvn" \
|
||||||
|
++input="/mnt/nfs/zhifu.gzf/data/AISHELL-1/data_aishell/wav/train/S0002/BAC009S0002W0122.wav" \
|
||||||
|
++output_dir="./outputs/debug" \
|
||||||
|
++device="cuda:0" \
|
||||||
|
|
||||||
@ -43,6 +43,7 @@ config=e_branchformer_12e_6d_2048_256.yaml
|
|||||||
model_dir="baseline_$(basename "${config}" .yaml)_${lang}_${token_type}_${tag}"
|
model_dir="baseline_$(basename "${config}" .yaml)_${lang}_${token_type}_${tag}"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if [ ${stage} -le -1 ] && [ ${stop_stage} -ge -1 ]; then
|
if [ ${stage} -le -1 ] && [ ${stop_stage} -ge -1 ]; then
|
||||||
echo "stage -1: Data Download"
|
echo "stage -1: Data Download"
|
||||||
mkdir -p ${raw_data}
|
mkdir -p ${raw_data}
|
||||||
@ -130,7 +131,7 @@ fi
|
|||||||
if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
|
if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
|
||||||
echo "stage 5: Inference"
|
echo "stage 5: Inference"
|
||||||
|
|
||||||
if ${inference_device} == "cuda"; then
|
if [ ${inference_device} == "cuda" ]; then
|
||||||
nj=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}')
|
nj=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}')
|
||||||
else
|
else
|
||||||
inference_batch_size=1
|
inference_batch_size=1
|
||||||
@ -142,7 +143,7 @@ if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
|
|||||||
|
|
||||||
for dset in ${test_sets}; do
|
for dset in ${test_sets}; do
|
||||||
|
|
||||||
inference_dir="${exp_dir}/exp/${model_dir}/${inference_checkpoint}/${dset}"
|
inference_dir="${exp_dir}/exp/${model_dir}/inference-${inference_checkpoint}/${dset}"
|
||||||
_logdir="${inference_dir}/logdir"
|
_logdir="${inference_dir}/logdir"
|
||||||
|
|
||||||
mkdir -p "${_logdir}"
|
mkdir -p "${_logdir}"
|
||||||
@ -155,7 +156,7 @@ if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
|
|||||||
done
|
done
|
||||||
utils/split_scp.pl "${key_file}" ${split_scps}
|
utils/split_scp.pl "${key_file}" ${split_scps}
|
||||||
|
|
||||||
gpuid_list_array=(${gpuid_list//,/ })
|
gpuid_list_array=(${CUDA_VISIBLE_DEVICES//,/ })
|
||||||
for JOB in $(seq ${nj}); do
|
for JOB in $(seq ${nj}); do
|
||||||
{
|
{
|
||||||
id=$((JOB-1))
|
id=$((JOB-1))
|
||||||
@ -171,7 +172,7 @@ if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
|
|||||||
++input="${_logdir}/keys.${JOB}.scp" \
|
++input="${_logdir}/keys.${JOB}.scp" \
|
||||||
++output_dir="${inference_dir}/${JOB}" \
|
++output_dir="${inference_dir}/${JOB}" \
|
||||||
++device="${inference_device}" \
|
++device="${inference_device}" \
|
||||||
++batch_size="${inference_batch_size}"
|
++batch_size="${inference_batch_size}" &> ${_logdir}/log.${JOB}.txt
|
||||||
}&
|
}&
|
||||||
|
|
||||||
done
|
done
|
||||||
@ -187,8 +188,8 @@ if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
|
|||||||
done
|
done
|
||||||
|
|
||||||
echo "Computing WER ..."
|
echo "Computing WER ..."
|
||||||
cp ${inference_dir}/1best_recog/text ${inference_dir}/1best_recog/text.proc
|
python utils/postprocess_text_zh.py ${inference_dir}/1best_recog/text ${inference_dir}/1best_recog/text.proc
|
||||||
cp ${data_dir}/text ${inference_dir}/1best_recog/text.ref
|
python utils/postprocess_text_zh.py ${data_dir}/text ${inference_dir}/1best_recog/text.ref
|
||||||
python utils/compute_wer.py ${inference_dir}/1best_recog/text.ref ${inference_dir}/1best_recog/text.proc ${inference_dir}/1best_recog/text.cer
|
python utils/compute_wer.py ${inference_dir}/1best_recog/text.ref ${inference_dir}/1best_recog/text.proc ${inference_dir}/1best_recog/text.cer
|
||||||
tail -n 3 ${inference_dir}/1best_recog/text.cer
|
tail -n 3 ${inference_dir}/1best_recog/text.cer
|
||||||
done
|
done
|
||||||
|
|||||||
12
examples/aishell/paraformer/infer.sh
Normal file
12
examples/aishell/paraformer/infer.sh
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
|
||||||
|
python -m funasr.bin.inference \
|
||||||
|
--config-path="/mnt/workspace/FunASR/examples/aishell/paraformer/exp/baseline_paraformer_conformer_12e_6d_2048_256_zh_char_exp3" \
|
||||||
|
--config-name="config.yaml" \
|
||||||
|
++init_param="/mnt/workspace/FunASR/examples/aishell/paraformer/exp/baseline_paraformer_conformer_12e_6d_2048_256_zh_char_exp3/model.pt.ep38" \
|
||||||
|
++tokenizer_conf.token_list="/mnt/nfs/zhifu.gzf/data/AISHELL-1-feats/DATA/data/zh_token_list/char/tokens.txt" \
|
||||||
|
++frontend_conf.cmvn_file="/mnt/nfs/zhifu.gzf/data/AISHELL-1-feats/DATA/data/train/am.mvn" \
|
||||||
|
++input="/mnt/nfs/zhifu.gzf/data/AISHELL-1/data_aishell/wav/train/S0002/BAC009S0002W0122.wav" \
|
||||||
|
++output_dir="./outputs/debug" \
|
||||||
|
++device="cuda:0" \
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ fi
|
|||||||
if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
|
if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
|
||||||
echo "stage 5: Inference"
|
echo "stage 5: Inference"
|
||||||
|
|
||||||
if ${inference_device} == "cuda"; then
|
if [ ${inference_device} == "cuda" ]; then
|
||||||
nj=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}')
|
nj=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}')
|
||||||
else
|
else
|
||||||
inference_batch_size=1
|
inference_batch_size=1
|
||||||
@ -142,7 +142,7 @@ if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
|
|||||||
|
|
||||||
for dset in ${test_sets}; do
|
for dset in ${test_sets}; do
|
||||||
|
|
||||||
inference_dir="${exp_dir}/exp/${model_dir}/${inference_checkpoint}/${dset}"
|
inference_dir="${exp_dir}/exp/${model_dir}/inference-${inference_checkpoint}/${dset}"
|
||||||
_logdir="${inference_dir}/logdir"
|
_logdir="${inference_dir}/logdir"
|
||||||
|
|
||||||
mkdir -p "${_logdir}"
|
mkdir -p "${_logdir}"
|
||||||
@ -155,7 +155,7 @@ if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
|
|||||||
done
|
done
|
||||||
utils/split_scp.pl "${key_file}" ${split_scps}
|
utils/split_scp.pl "${key_file}" ${split_scps}
|
||||||
|
|
||||||
gpuid_list_array=(${gpuid_list//,/ })
|
gpuid_list_array=(${CUDA_VISIBLE_DEVICES//,/ })
|
||||||
for JOB in $(seq ${nj}); do
|
for JOB in $(seq ${nj}); do
|
||||||
{
|
{
|
||||||
id=$((JOB-1))
|
id=$((JOB-1))
|
||||||
@ -171,7 +171,7 @@ if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
|
|||||||
++input="${_logdir}/keys.${JOB}.scp" \
|
++input="${_logdir}/keys.${JOB}.scp" \
|
||||||
++output_dir="${inference_dir}/${JOB}" \
|
++output_dir="${inference_dir}/${JOB}" \
|
||||||
++device="${inference_device}" \
|
++device="${inference_device}" \
|
||||||
++batch_size="${inference_batch_size}"
|
++batch_size="${inference_batch_size}" &> ${_logdir}/log.${JOB}.txt
|
||||||
}&
|
}&
|
||||||
|
|
||||||
done
|
done
|
||||||
@ -187,8 +187,8 @@ if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
|
|||||||
done
|
done
|
||||||
|
|
||||||
echo "Computing WER ..."
|
echo "Computing WER ..."
|
||||||
cp ${inference_dir}/1best_recog/text ${inference_dir}/1best_recog/text.proc
|
python utils/postprocess_text_zh.py ${inference_dir}/1best_recog/text ${inference_dir}/1best_recog/text.proc
|
||||||
cp ${data_dir}/text ${inference_dir}/1best_recog/text.ref
|
python utils/postprocess_text_zh.py ${data_dir}/text ${inference_dir}/1best_recog/text.ref
|
||||||
python utils/compute_wer.py ${inference_dir}/1best_recog/text.ref ${inference_dir}/1best_recog/text.proc ${inference_dir}/1best_recog/text.cer
|
python utils/compute_wer.py ${inference_dir}/1best_recog/text.ref ${inference_dir}/1best_recog/text.proc ${inference_dir}/1best_recog/text.cer
|
||||||
tail -n 3 ${inference_dir}/1best_recog/text.cer
|
tail -n 3 ${inference_dir}/1best_recog/text.cer
|
||||||
done
|
done
|
||||||
|
|||||||
31
examples/aishell/paraformer/utils/postprocess_text_zh.py
Executable file
31
examples/aishell/paraformer/utils/postprocess_text_zh.py
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
import sys
|
||||||
|
import re
|
||||||
|
|
||||||
|
in_f = sys.argv[1]
|
||||||
|
out_f = sys.argv[2]
|
||||||
|
|
||||||
|
|
||||||
|
with open(in_f, "r", encoding="utf-8") as f:
|
||||||
|
lines = f.readlines()
|
||||||
|
|
||||||
|
with open(out_f, "w", encoding="utf-8") as f:
|
||||||
|
for line in lines:
|
||||||
|
outs = line.strip().split(" ", 1)
|
||||||
|
if len(outs) == 2:
|
||||||
|
idx, text = outs
|
||||||
|
text = re.sub("</s>", "", text)
|
||||||
|
text = re.sub("<s>", "", text)
|
||||||
|
text = re.sub("@@", "", text)
|
||||||
|
text = re.sub("@", "", text)
|
||||||
|
text = re.sub("<unk>", "", text)
|
||||||
|
text = re.sub(" ", "", text)
|
||||||
|
text = text.lower()
|
||||||
|
else:
|
||||||
|
idx = outs[0]
|
||||||
|
text = " "
|
||||||
|
|
||||||
|
text = [x for x in text]
|
||||||
|
text = " ".join(text)
|
||||||
|
out = "{} {}\n".format(idx, text)
|
||||||
|
f.write(out)
|
||||||
12
examples/aishell/transformer/infer.sh
Normal file
12
examples/aishell/transformer/infer.sh
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
|
||||||
|
python -m funasr.bin.inference \
|
||||||
|
--config-path="/mnt/workspace/FunASR/examples/aishell/paraformer/exp/baseline_paraformer_conformer_12e_6d_2048_256_zh_char_exp3" \
|
||||||
|
--config-name="config.yaml" \
|
||||||
|
++init_param="/mnt/workspace/FunASR/examples/aishell/paraformer/exp/baseline_paraformer_conformer_12e_6d_2048_256_zh_char_exp3/model.pt.ep38" \
|
||||||
|
++tokenizer_conf.token_list="/mnt/nfs/zhifu.gzf/data/AISHELL-1-feats/DATA/data/zh_token_list/char/tokens.txt" \
|
||||||
|
++frontend_conf.cmvn_file="/mnt/nfs/zhifu.gzf/data/AISHELL-1-feats/DATA/data/train/am.mvn" \
|
||||||
|
++input="/mnt/nfs/zhifu.gzf/data/AISHELL-1/data_aishell/wav/train/S0002/BAC009S0002W0122.wav" \
|
||||||
|
++output_dir="./outputs/debug" \
|
||||||
|
++device="cuda:0" \
|
||||||
|
|
||||||
@ -43,6 +43,7 @@ config=transformer_12e_6d_2048_256.yaml
|
|||||||
model_dir="baseline_$(basename "${config}" .yaml)_${lang}_${token_type}_${tag}"
|
model_dir="baseline_$(basename "${config}" .yaml)_${lang}_${token_type}_${tag}"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if [ ${stage} -le -1 ] && [ ${stop_stage} -ge -1 ]; then
|
if [ ${stage} -le -1 ] && [ ${stop_stage} -ge -1 ]; then
|
||||||
echo "stage -1: Data Download"
|
echo "stage -1: Data Download"
|
||||||
mkdir -p ${raw_data}
|
mkdir -p ${raw_data}
|
||||||
@ -142,7 +143,7 @@ if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
|
|||||||
|
|
||||||
for dset in ${test_sets}; do
|
for dset in ${test_sets}; do
|
||||||
|
|
||||||
inference_dir="${exp_dir}/exp/${model_dir}/infer-${inference_checkpoint}/${dset}"
|
inference_dir="${exp_dir}/exp/${model_dir}/inference-${inference_checkpoint}/${dset}"
|
||||||
_logdir="${inference_dir}/logdir"
|
_logdir="${inference_dir}/logdir"
|
||||||
|
|
||||||
mkdir -p "${_logdir}"
|
mkdir -p "${_logdir}"
|
||||||
@ -171,7 +172,7 @@ if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
|
|||||||
++input="${_logdir}/keys.${JOB}.scp" \
|
++input="${_logdir}/keys.${JOB}.scp" \
|
||||||
++output_dir="${inference_dir}/${JOB}" \
|
++output_dir="${inference_dir}/${JOB}" \
|
||||||
++device="${inference_device}" \
|
++device="${inference_device}" \
|
||||||
++batch_size="${inference_batch_size}"
|
++batch_size="${inference_batch_size}" &> ${_logdir}/log.${JOB}.txt
|
||||||
}&
|
}&
|
||||||
|
|
||||||
done
|
done
|
||||||
@ -187,8 +188,8 @@ if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
|
|||||||
done
|
done
|
||||||
|
|
||||||
echo "Computing WER ..."
|
echo "Computing WER ..."
|
||||||
cp ${inference_dir}/1best_recog/text ${inference_dir}/1best_recog/text.proc
|
python utils/postprocess_text_zh.py ${inference_dir}/1best_recog/text ${inference_dir}/1best_recog/text.proc
|
||||||
cp ${data_dir}/text ${inference_dir}/1best_recog/text.ref
|
python utils/postprocess_text_zh.py ${data_dir}/text ${inference_dir}/1best_recog/text.ref
|
||||||
python utils/compute_wer.py ${inference_dir}/1best_recog/text.ref ${inference_dir}/1best_recog/text.proc ${inference_dir}/1best_recog/text.cer
|
python utils/compute_wer.py ${inference_dir}/1best_recog/text.ref ${inference_dir}/1best_recog/text.proc ${inference_dir}/1best_recog/text.cer
|
||||||
tail -n 3 ${inference_dir}/1best_recog/text.cer
|
tail -n 3 ${inference_dir}/1best_recog/text.cer
|
||||||
done
|
done
|
||||||
|
|||||||
@ -109,12 +109,8 @@ class Trainer:
|
|||||||
|
|
||||||
print(f'Checkpoint saved to {filename}')
|
print(f'Checkpoint saved to {filename}')
|
||||||
latest = Path(os.path.join(self.output_dir, f'model.pt'))
|
latest = Path(os.path.join(self.output_dir, f'model.pt'))
|
||||||
try:
|
torch.save(state, latest)
|
||||||
latest.unlink()
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
latest.symlink_to(filename)
|
|
||||||
|
|
||||||
def _resume_checkpoint(self, resume_path):
|
def _resume_checkpoint(self, resume_path):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user