Wav2vec2 Xlsr Multilingual 56
这是一个支持56种语言的多语言自动语音识别(ASR)模型,基于facebook/wav2vec2-large-xlsr-53在通用语音数据集上微调而成。
下载量 21.69k
发布时间 : 3/2/2022
模型简介
该模型用于多语言自动语音识别任务,支持包括阿拉伯语、中文、英语、法语等在内的56种语言。
模型特点
多语言支持
支持56种语言的语音识别,覆盖广泛的语言需求
基于XLSR架构
基于facebook/wav2vec2-large-xlsr-53模型微调,具有强大的语音识别能力
通用语音数据集
使用通用语音(Common Voice)数据集进行训练,数据来源广泛
模型能力
自动语音识别
多语言语音转文本
语音内容分析
使用案例
语音转写
多语言会议记录
将多语言会议录音自动转写为文本
支持56种语言的语音转写
语音助手
为多语言语音助手提供语音识别能力
语音分析
语音内容分析
分析语音内容中的关键词和主题
🚀 XLSR Wav2Vec2 56 语言模型卡
本模型是用于 56 种语言的自动语音识别模型,由 Voidful 开发,基于 Apache-2.0 许可证开源。它在多种语言的语音识别任务中表现出色,为多语言语音处理提供了强大的支持。
🚀 快速开始
使用以下代码开始使用该模型:
点击展开
环境设置:
!pip install torchaudio
!pip install datasets transformers
!pip install asrp
!wget -O lang_ids.pk https://huggingface.co/voidful/wav2vec2-xlsr-multilingual-56/raw/main/lang_ids.pk
使用方法
import torchaudio
from datasets import load_dataset, load_metric
from transformers import (
Wav2Vec2ForCTC,
Wav2Vec2Processor,
AutoTokenizer,
AutoModelWithLMHead
)
import torch
import re
import sys
import soundfile as sf
model_name = "voidful/wav2vec2-xlsr-multilingual-56"
device = "cuda"
processor_name = "voidful/wav2vec2-xlsr-multilingual-56"
import pickle
with open("lang_ids.pk", 'rb') as output:
lang_ids = pickle.load(output)
model = Wav2Vec2ForCTC.from_pretrained(model_name).to(device)
processor = Wav2Vec2Processor.from_pretrained(processor_name)
model.eval()
def load_file_to_data(file,sampling_rate=16_000):
batch = {}
speech, _ = torchaudio.load(file)
if sampling_rate != '16_000' or sampling_rate != '16000':
resampler = torchaudio.transforms.Resample(orig_freq=sampling_rate, new_freq=16_000)
batch["speech"] = resampler.forward(speech.squeeze(0)).numpy()
batch["sampling_rate"] = resampler.new_freq
else:
batch["speech"] = speech.squeeze(0).numpy()
batch["sampling_rate"] = '16000'
return batch
def predict(data):
features = processor(data["speech"], sampling_rate=data["sampling_rate"], padding=True, return_tensors="pt")
input_values = features.input_values.to(device)
attention_mask = features.attention_mask.to(device)
with torch.no_grad():
logits = model(input_values, attention_mask=attention_mask).logits
decoded_results = []
for logit in logits:
pred_ids = torch.argmax(logit, dim=-1)
mask = pred_ids.ge(1).unsqueeze(-1).expand(logit.size())
vocab_size = logit.size()[-1]
voice_prob = torch.nn.functional.softmax((torch.masked_select(logit, mask).view(-1,vocab_size)),dim=-1)
comb_pred_ids = torch.argmax(voice_prob, dim=-1)
decoded_results.append(processor.decode(comb_pred_ids))
return decoded_results
def predict_lang_specific(data,lang_code):
features = processor(data["speech"], sampling_rate=data["sampling_rate"], padding=True, return_tensors="pt")
input_values = features.input_values.to(device)
attention_mask = features.attention_mask.to(device)
with torch.no_grad():
logits = model(input_values, attention_mask=attention_mask).logits
decoded_results = []
for logit in logits:
pred_ids = torch.argmax(logit, dim=-1)
mask = ~pred_ids.eq(processor.tokenizer.pad_token_id).unsqueeze(-1).expand(logit.size())
vocab_size = logit.size()[-1]
voice_prob = torch.nn.functional.softmax((torch.masked_select(logit, mask).view(-1,vocab_size)),dim=-1)
filtered_input = pred_ids[pred_ids!=processor.tokenizer.pad_token_id].view(1,-1).to(device)
if len(filtered_input[0]) == 0:
decoded_results.append("")
else:
lang_mask = torch.empty(voice_prob.shape[-1]).fill_(0)
lang_index = torch.tensor(sorted(lang_ids[lang_code]))
lang_mask.index_fill_(0, lang_index, 1)
lang_mask = lang_mask.to(device)
comb_pred_ids = torch.argmax(lang_mask*voice_prob, dim=-1)
decoded_results.append(processor.decode(comb_pred_ids))
return decoded_results
predict(load_file_to_data('audio file path',sampling_rate=16_000)) # 注意音频文件的采样率
predict_lang_specific(load_file_to_data('audio file path',sampling_rate=16_000),'en') # 注意音频文件的采样率
✨ 主要特性
- 多语言支持:支持 56 种语言的自动语音识别。
- 基于 XLSR Wav2Vec2:利用先进的预训练模型进行微调。
- 在多个数据集上训练:在 Common Voice 等数据集上进行训练,提高模型的泛化能力。
📦 安装指南
在使用该模型之前,需要安装以下依赖:
!pip install torchaudio
!pip install datasets transformers
!pip install asrp
!wget -O lang_ids.pk https://huggingface.co/voidful/wav2vec2-xlsr-multilingual-56/raw/main/lang_ids.pk
📚 详细文档
模型详情
模型描述
- 开发者:voidful
- 共享方:Hugging Face
- 模型类型:自动语音识别
- 支持语言:多语言(56 种语言,1 个多语言自动语音识别模型)
- 许可证:Apache-2.0
- 相关模型:
- 父模型:wav2vec
- 更多信息资源:
使用场景
直接使用
该模型可用于自动语音识别任务。
下游使用
更多信息待补充。
超出使用范围
该模型不应被用于故意为人们创造敌对或疏远的环境。
偏差、风险和局限性
大量研究已经探讨了语言模型的偏差和公平性问题(例如,参见 Sheng 等人 (2021) 和 Bender 等人 (2021))。模型生成的预测可能包含针对受保护类别、身份特征以及敏感、社会和职业群体的令人不安和有害的刻板印象。
建议
用户(直接用户和下游用户)应该了解该模型的风险、偏差和局限性。关于进一步的建议,更多信息待补充。
训练详情
训练数据
请参阅 Common Voice 数据集卡片。该模型在 56 种语言上对 facebook/wav2vec2-large-xlsr-53 进行了微调,使用的数据集为 Common Voice。
训练过程
预处理
更多信息待补充。
速度、大小、时间
使用该模型时,请确保语音输入的采样率为 16kHz。
评估
测试数据、因素和指标
测试数据
更多信息待补充。
因素
更多信息待补充。
指标
更多信息待补充。
结果
点击展开
通用语音语言 | 数据数量 | 时长(小时) | 词错误率(WER) | 字符错误率(CER) |
---|---|---|---|---|
ar | 21744 | 81.5 | 75.29 | 31.23 |
as | 394 | 1.1 | 95.37 | 46.05 |
br | 4777 | 7.4 | 93.79 | 41.16 |
ca | 301308 | 692.8 | 24.80 | 10.39 |
cnh | 1563 | 2.4 | 68.11 | 23.10 |
cs | 9773 | 39.5 | 67.86 | 12.57 |
cv | 1749 | 5.9 | 95.43 | 34.03 |
cy | 11615 | 106.7 | 67.03 | 23.97 |
de | 262113 | 822.8 | 27.03 | 6.50 |
dv | 4757 | 18.6 | 92.16 | 30.15 |
el | 3717 | 11.1 | 94.48 | 58.67 |
en | 580501 | 1763.6 | 34.87 | 14.84 |
eo | 28574 | 162.3 | 37.77 | 6.23 |
es | 176902 | 337.7 | 19.63 | 5.41 |
et | 5473 | 35.9 | 86.87 | 20.79 |
eu | 12677 | 90.2 | 44.80 | 7.32 |
fa | 12806 | 290.6 | 53.81 | 15.09 |
fi | 875 | 2.6 | 93.78 | 27.57 |
fr | 314745 | 664.1 | 33.16 | 13.94 |
fy-NL | 6717 | 27.2 | 72.54 | 26.58 |
ga-IE | 1038 | 3.5 | 92.57 | 51.02 |
hi | 292 | 2.0 | 90.95 | 57.43 |
hsb | 980 | 2.3 | 89.44 | 27.19 |
hu | 4782 | 9.3 | 97.15 | 36.75 |
ia | 5078 | 10.4 | 52.00 | 11.35 |
id | 3965 | 9.9 | 82.50 | 22.82 |
it | 70943 | 178.0 | 39.09 | 8.72 |
ja | 1308 | 8.2 | 99.21 | 62.06 |
ka | 1585 | 4.0 | 90.53 | 18.57 |
ky | 3466 | 12.2 | 76.53 | 19.80 |
lg | 1634 | 17.1 | 98.95 | 43.84 |
lt | 1175 | 3.9 | 92.61 | 26.81 |
lv | 4554 | 6.3 | 90.34 | 30.81 |
mn | 4020 | 11.6 | 82.68 | 30.14 |
mt | 3552 | 7.8 | 84.18 | 22.96 |
nl | 14398 | 71.8 | 57.18 | 19.01 |
or | 517 | 0.9 | 90.93 | 27.34 |
pa-IN | 255 | 0.8 | 87.95 | 42.03 |
pl | 12621 | 112.0 | 56.14 | 12.06 |
pt | 11106 | 61.3 | 53.24 | 16.32 |
rm-sursilv | 2589 | 5.9 | 78.17 | 23.31 |
rm-vallader | 931 | 2.3 | 73.67 | 21.76 |
ro | 4257 | 8.7 | 83.84 | 21.95 |
ru | 23444 | 119.1 | 61.83 | 15.18 |
sah | 1847 | 4.4 | 94.38 | 38.46 |
sl | 2594 | 6.7 | 84.21 | 20.54 |
sv-SE | 4350 | 20.8 | 83.68 | 30.79 |
ta | 3788 | 18.4 | 84.19 | 21.60 |
th | 4839 | 11.7 | 141.87 | 37.16 |
tr | 3478 | 22.3 | 66.77 | 15.55 |
tt | 13338 | 26.7 | 86.80 | 33.57 |
uk | 7271 | 39.4 | 70.23 | 14.34 |
vi | 421 | 1.7 | 96.06 | 66.25 |
zh-CN | 27284 | 58.7 | 89.67 | 23.96 |
zh-HK | 12678 | 92.1 | 81.77 | 18.82 |
zh-TW | 6402 | 56.6 | 85.08 | 29.07 |
模型检查
更多信息待补充。
环境影响
可以使用 Lacoste 等人 (2019) 中提出的 机器学习影响计算器 来估算碳排放量。
- 硬件类型:更多信息待补充
- 使用时长:更多信息待补充
- 云服务提供商:更多信息待补充
- 计算区域:更多信息待补充
- 碳排放:更多信息待补充
技术规格(可选)
模型架构和目标
更多信息待补充。
计算基础设施
硬件
更多信息待补充。
软件
更多信息待补充。
引用
BibTeX
More information needed
APA
More information needed
术语表(可选)
更多信息待补充。
更多信息(可选)
更多信息待补充。
模型卡片作者(可选)
voidful 与 Ezi Ozoani 和 Hugging Face 团队合作完成。
模型卡片联系方式
更多信息待补充。
📄 许可证
该模型遵循 Apache-2.0 许可证。
Voice Activity Detection
MIT
基于pyannote.audio 2.1版本的语音活动检测模型,用于识别音频中的语音活动时间段
语音识别
V
pyannote
7.7M
181
Wav2vec2 Large Xlsr 53 Portuguese
Apache-2.0
这是一个针对葡萄牙语语音识别任务微调的XLSR-53大模型,基于Common Voice 6.1数据集训练,支持葡萄牙语语音转文本。
语音识别 其他
W
jonatasgrosman
4.9M
32
Whisper Large V3
Apache-2.0
Whisper是由OpenAI提出的先进自动语音识别(ASR)和语音翻译模型,在超过500万小时的标注数据上训练,具有强大的跨数据集和跨领域泛化能力。
语音识别 支持多种语言
W
openai
4.6M
4,321
Whisper Large V3 Turbo
MIT
Whisper是由OpenAI开发的最先进的自动语音识别(ASR)和语音翻译模型,经过超过500万小时标记数据的训练,在零样本设置下展现出强大的泛化能力。
语音识别
Transformers 支持多种语言

W
openai
4.0M
2,317
Wav2vec2 Large Xlsr 53 Russian
Apache-2.0
基于facebook/wav2vec2-large-xlsr-53模型微调的俄语语音识别模型,支持16kHz采样率的语音输入
语音识别 其他
W
jonatasgrosman
3.9M
54
Wav2vec2 Large Xlsr 53 Chinese Zh Cn
Apache-2.0
基于facebook/wav2vec2-large-xlsr-53模型微调的中文语音识别模型,支持16kHz采样率的语音输入。
语音识别 中文
W
jonatasgrosman
3.8M
110
Wav2vec2 Large Xlsr 53 Dutch
Apache-2.0
基于facebook/wav2vec2-large-xlsr-53微调的荷兰语语音识别模型,在Common Voice和CSS10数据集上训练,支持16kHz音频输入。
语音识别 其他
W
jonatasgrosman
3.0M
12
Wav2vec2 Large Xlsr 53 Japanese
Apache-2.0
基于facebook/wav2vec2-large-xlsr-53模型微调的日语语音识别模型,支持16kHz采样率的语音输入
语音识别 日语
W
jonatasgrosman
2.9M
33
Mms 300m 1130 Forced Aligner
基于Hugging Face预训练模型的文本与音频强制对齐工具,支持多种语言,内存效率高
语音识别
Transformers 支持多种语言

M
MahmoudAshraf
2.5M
50
Wav2vec2 Large Xlsr 53 Arabic
Apache-2.0
基于facebook/wav2vec2-large-xlsr-53微调的阿拉伯语语音识别模型,在Common Voice和阿拉伯语语音语料库上训练
语音识别 阿拉伯语
W
jonatasgrosman
2.3M
37
精选推荐AI模型
Llama 3 Typhoon V1.5x 8b Instruct
专为泰语设计的80亿参数指令模型,性能媲美GPT-3.5-turbo,优化了应用场景、检索增强生成、受限生成和推理任务
大型语言模型
Transformers 支持多种语言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一个基于SODA数据集训练的超小型对话模型,专为边缘设备推理设计,体积仅为Cosmo-3B模型的2%左右。
对话系统
Transformers 英语

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基于RoBERTa架构的中文抽取式问答模型,适用于从给定文本中提取答案的任务。
问答系统 中文
R
uer
2,694
98