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

相关推荐

  1. ASR语音识别纠错-fast correct

    2024-03-13 08:14:01       19 阅读
  2. 中文语音识别实战(ASR

    2024-03-13 08:14:01       12 阅读
  3. Python使用whisper实现语音识别ASR

    2024-03-13 08:14:01       16 阅读
  4. 基于Asterisk和TTS/ASR语音识别的配置示例

    2024-03-13 08:14:01       36 阅读
  5. ASR工业化语音模型总结

    2024-03-13 08:14:01       18 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-03-13 08:14:01       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-03-13 08:14:01       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-03-13 08:14:01       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-03-13 08:14:01       20 阅读

热门阅读

  1. Android手机定位

    2024-03-13 08:14:01       18 阅读
  2. (学习日记)2024.03.08:UCOSIII第十节:临界段

    2024-03-13 08:14:01       22 阅读
  3. 常用的深度学习框架

    2024-03-13 08:14:01       20 阅读
  4. @Insert注解是怎么用的?

    2024-03-13 08:14:01       25 阅读
  5. 构建轻量级CentOS Docker镜像的实战指南

    2024-03-13 08:14:01       21 阅读
  6. 微信小程序文字上下无缝轮播(滚动效果)

    2024-03-13 08:14:01       22 阅读
  7. R语言系列3——R语言数据可视化入门

    2024-03-13 08:14:01       22 阅读
  8. 微信小程序

    2024-03-13 08:14:01       19 阅读
  9. uniapp小程序上传oss

    2024-03-13 08:14:01       17 阅读
  10. Mac管理Ruby环境

    2024-03-13 08:14:01       22 阅读