ASR语音识别纠错-fast correct

1、使用方式说明

ASR对应的文本越长,识别准确率和召回率越高

识别的错误分类:

编号错误类型示例
1谐音字词配副眼睛-配副眼镜
2混淆音字词流浪织女-牛郎织女
3多字错误关关机-关机
4少字错误

爱有天意-假如爱有天意

5形似字错误高梁-高粱
6中文拼音全拼xingfu-幸福
7中文拼音缩写sz-深圳
8语法错误

想象难以-难以想象

ASR纠错,主要是解决1、2、3、4、5几个问题

ASR是实时语音回话,所以对性能要求极高,模型性能要求:

1、可以快速并行纠错。可以解决上线实时处理需求,时延在100ms以内。

备选对比模型:

模型1:fastcorrect、fastcorrect2

模型2:softcorrect

模型3:macbert

本次探讨fastcorrect模型

fast correct 环境准备

conda create -n fast_speech python=3.7 cudnn=8.9.2.26 cudatoolkit=11.3.1

pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113

git clone https://github.com/pytorch/fairseq (可以手动下载指定的稳定版本代码,建议下载0.10.1)

cd fairseq
pip install --editable ./

pip install sentencepiece

**********************数据预处理************************************

*********************数据对齐************************************

align_cal_werdur_v2.py   original_query_file target_query_file  可以将纠错内容进行对齐生成对齐数据集

********************训练数据二进制编码合成************************************

cd FastCorrect/runs

vi data-gen.sh (第9行数据赋值为data-bin)

chmod +x data-gen.sh

./data-gen.sh

**********************生成预训练模型*************************************

cd FastCorrect/runs

vi train_pretrain.sh (第9行数据赋值为data-bin,第12行为data-pretrain,第13行修改增加CUDA_VISIBLE_DEVICES=3,4)

chmod +x train_pretrain.sh

./train_pretrain.sh

**********************下载sentencepiece对应的模型*************************************

我下载的是https://hf-mirror.com/IDEA-CCNL/Erlangshen-DeBERTa-v2-186M-Chinese-SentencePiece/tree/main/spm.model

创建一个目录sentencepiece_model_path 并将模型复制到这个目录下

*********************模型推理*************************************

from fairseq import utils
utils.import_user_module(argparse.Namespace(user_dir='./FastCorrect'))
from FastCorrect.fastcorrect_model import FastCorrectModel

model_name_or_path=saved_model_path

checkpoint_file = "checkpoint_best.pt" 可以指定具体的模型文件(多个版本选择)

data_name_or_path ="" #数据预处理data-gen 生成的训练数据二进制文件夹。默认为data-bin

bpe = "sentencepiece"

sentencepiece_model_path="" #sentencepiece_model_path 包含模型名称

transf_gec = FastCorrectModel.from_pretrained(model_name_or_path, checkpoint_file=checkpoint_file, data_name_or_path=data_name_or_path, bpe=bpe,sentencepiece_model=sentencepiece_model_path)

transf_gec.eval()
transf_gec.cuda()

input_text= remove_ch_spaces(input_text)
standard_input = " ".join(list(input_text))
text = transf_gec.binarize(standard_input)

batched_hypos = transf_gec.generate(text, iter_decode_max_iter=10)

translated = [transf_gec.decode(hypos[0]['tokens']) for hypos in batched_hypos][0]

print(translated )

 结论:训练epoch 为200

对于1、2、5错误,解决较好。对于3、4的多字、少字错误解决不是狠理想(有更好的模型欢迎留言)。

相关参考链接:

FastCorrect git:https://github.com/microsoft/NeuralSpeech/tree/master/FastCorrect

Fairseq git:https://github.com/facebookresearch/fairseq

Fairseq 文档:https://fairseq.readthedocs.io/en/latest/command_line_tools.html

fairseq训练参数说明:https://www.cnblogs.com/hanlaomo/p/16708102.html

  • 18
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

会发paper的学渣

您的鼓励和将是我前进的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值