B
Bp400 Xlsr
由 lgris 开发
基于巴西葡萄牙语数据集微调的Wav2vec 2.0语音识别模型,支持巴西葡萄牙语自动语音识别任务。
下载量 55
发布时间 : 3/2/2022
模型介绍
内容详情
替代品
模型简介
该模型是针对巴西葡萄牙语优化的自动语音识别(ASR)系统,基于Wav2vec 2.0架构,在多个巴西葡萄牙语数据集上进行了微调。
模型特点
多数据集训练
模型融合了7个巴西葡萄牙语数据集,包括CETUC、Common Voice等,总计超过400小时的训练数据。
语言模型支持
可结合4-gram语言模型进一步提升识别准确率,平均WER从12.4%降至10.5%。
高准确率
在多个测试集上表现优异,CETUC测试集WER低至3.0%,Common Voice测试集WER为9.6%。
模型能力
巴西葡萄牙语语音识别
音频转录
语音转文本
使用案例
语音转录
巴西葡萄牙语语音转录
将巴西葡萄牙语语音内容转换为文本
在CETUC数据集上达到3.0% WER的高准确率
语音助手
巴西葡萄牙语语音指令识别
用于巴西葡萄牙语语音助手系统中的指令识别
language: pt datasets:
- common_voice
- mls
- cetuc
- lapsbm
- voxforge
- tedx
- sid metrics:
- wer tags:
- audio
- speech
- wav2vec2
- pt
- portuguese-speech-corpus
- automatic-speech-recognition
- speech
- PyTorch
- hf-asr-leaderboard model-index:
- name: bp400-xlsr
results:
- task:
name: 自动语音识别
type: automatic-speech-recognition
dataset:
name: Common Voice 7.0
type: mozilla-foundation/common_voice_7_0
args: pt
metrics:
- name: 测试WER type: wer value: 14.0 license: apache-2.0
- task:
name: 自动语音识别
type: automatic-speech-recognition
dataset:
name: Common Voice 7.0
type: mozilla-foundation/common_voice_7_0
args: pt
metrics:
bp400-xlsr:基于巴西葡萄牙语(BP)数据集的Wav2vec 2.0模型
论文: https://arxiv.org/abs/2107.11414
这是针对巴西葡萄牙语微调的Wav2vec模型的演示,使用了以下数据集:
- CETUC:包含约145小时的巴西葡萄牙语语音,由50名男性和50名女性发音人录制,每人朗读约1000个从CETEN-Folha语料库中选出的语音平衡句子。
- Common Voice 7.0:由Mozilla基金会提出的项目,旨在创建多种语言的开放数据集。志愿者通过官方网站捐赠并验证语音。
- Lapsbm:"Falabrasil - UFPA"是Fala Brasil小组用于评估巴西葡萄牙语ASR系统的数据集。包含35名发音人(10名女性),每人朗读20个独特句子,总计700条巴西葡萄牙语语音。音频以22.05 kHz采样率录制,无环境控制。
- Multilingual Librispeech (MLS):一个多语言大规模数据集,基于LibriVox等公共领域的有声书录音。葡萄牙语子集(主要为巴西变体)包含约284小时语音,来自62名发音人朗读的55本有声书。
- Multilingual TEDx:包含8种语言TEDx演讲的音频集。葡萄牙语子集(主要为巴西变体)含164小时转录语音。
- Sidney (SID):包含72名发音人(20名女性,年龄17-59岁)的5777条录音,涵盖出生地、年龄、性别、教育程度和职业等信息。
- VoxForge:旨在构建声学模型开放数据集的项目。巴西葡萄牙语部分约100名发音人,4130条语音,采样率16kHz至44.1kHz不等。
这些数据集被合并构建更大的巴西葡萄牙语数据集。除Common Voice的开发/测试集用于验证/测试外,其余数据均用于训练。我们还为所有数据集创建了测试集。
数据集 | 训练 | 验证 | 测试 |
---|---|---|---|
CETUC | 93.9h | -- | 5.4h |
Common Voice | 37.6h | 8.9h | 9.5h |
LaPS BM | 0.8h | -- | 0.1h |
MLS | 161.0h | -- | 3.7h |
Multilingual TEDx (Portuguese) | 144.2h | -- | 1.8h |
SID | 5.0h | -- | 1.0h |
VoxForge | 2.8h | -- | 0.1h |
总计 | 437.2h | 8.9h | 21.6h |
原始模型使用fairseq微调。本笔记本使用转换后的版本。原始fairseq模型链接在此。
效果概览
CETUC | CV | LaPS | MLS | SID | TEDx | VF | 平均 | |
---|---|---|---|---|---|---|---|---|
bp_400 (下方演示) | 0.052 | 0.140 | 0.074 | 0.117 | 0.121 | 0.245 | 0.118 | 0.124 |
bp_400 + 3-gram | 0.033 | 0.095 | 0.046 | 0.123 | 0.112 | 0.212 | 0.123 | 0.106 |
bp_400 + 4-gram (下方演示) | 0.030 | 0.096 | 0.043 | 0.106 | 0.118 | 0.229 | 0.117 | 0.105 |
bp_400 + 5-gram | 0.033 | 0.094 | 0.043 | 0.123 | 0.111 | 0.210 | 0.123 | 0.105 |
bp_400 + 变换器 | 0.032 | 0.092 | 0.036 | 0.130 | 0.115 | 0.215 | 0.125 | 0.106 |
转录示例
文本 | 转录结果 |
---|---|
alguém sabe a que horas começa o jantar | alguém sabe a que horas começo jantar |
lila covas ainda não sabe o que vai fazer no fundo | lilacovas ainda não sabe o que vai fazer no fundo |
que tal um pouco desse bom spaghetti | quetá um pouco deste bom ispaguete |
hong kong em cantonês significa porto perfumado | rongkong en cantones significa porto perfumado |
vamos hackear esse problema | vamos rackar esse problema |
apenas a poucos metros há uma estação de ônibus | apenas ha poucos metros á uma estação de ônibus |
relâmpago e trovão sempre andam juntos | relampagotrevão sempre andam juntos |
演示
MODEL_NAME = "lgris/bp400-xlsr"
导入与依赖
%%capture
!pip install torch==1.8.2+cu111 torchvision==0.9.2+cu111 torchaudio===0.8.2 -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html
!pip install datasets
!pip install jiwer
!pip install transformers
!pip install soundfile
!pip install pyctcdecode
!pip install https://github.com/kpu/kenlm/archive/master.zip
import jiwer
import torchaudio
from datasets import load_dataset, load_metric
from transformers import (
Wav2Vec2ForCTC,
Wav2Vec2Processor,
)
from pyctcdecode import build_ctcdecoder
import torch
import re
import sys
辅助函数
chars_to_ignore_regex = '[\,\?\.\!\;\:\"]' # noqa: W605
def map_to_array(batch):
speech, _ = torchaudio.load(batch["path"])
batch["speech"] = speech.squeeze(0).numpy()
batch["sampling_rate"] = 16_000
batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower().replace("’", "'")
batch["target"] = batch["sentence"]
return batch
def calc_metrics(truths, hypos):
wers = []
mers = []
wils = []
for t, h in zip(truths, hypos):
try:
wers.append(jiwer.wer(t, h))
mers.append(jiwer.mer(t, h))
wils.append(jiwer.wil(t, h))
except: # 空字符串?
pass
wer = sum(wers)/len(wers)
mer = sum(mers)/len(mers)
wil = sum(wils)/len(wils)
return wer, mer, wil
def load_data(dataset):
data_files = {'test': f'{dataset}/test.csv'}
dataset = load_dataset('csv', data_files=data_files)["test"]
return dataset.map(map_to_array)
模型
class STT:
def __init__(self,
model_name,
device='cuda' if torch.cuda.is_available() else 'cpu',
lm=None):
self.model_name = model_name
self.model = Wav2Vec2ForCTC.from_pretrained(model_name).to(device)
self.processor = Wav2Vec2Processor.from_pretrained(model_name)
self.vocab_dict = self.processor.tokenizer.get_vocab()
self.sorted_dict = {
k.lower(): v for k, v in sorted(self.vocab_dict.items(),
key=lambda item: item[1])
}
self.device = device
self.lm = lm
if self.lm:
self.lm_decoder = build_ctcdecoder(
list(self.sorted_dict.keys()),
self.lm
)
def batch_predict(self, batch):
features = self.processor(batch["speech"],
sampling_rate=batch["sampling_rate"][0],
padding=True,
return_tensors="pt")
input_values = features.input_values.to(self.device)
attention_mask = features.attention_mask.to(self.device)
with torch.no_grad():
logits = self.model(input_values, attention_mask=attention_mask).logits
if self.lm:
logits = logits.cpu().numpy()
batch["predicted"] = []
for sample_logits in logits:
batch["predicted"].append(self.lm_decoder.decode(sample_logits))
else:
pred_ids = torch.argmax(logits, dim=-1)
batch["predicted"] = self.processor.batch_decode(pred_ids)
return batch
下载数据集
%%capture
!gdown --id 1HFECzIizf-bmkQRLiQD0QVqcGtOG5upI
!mkdir bp_dataset
!unzip bp_dataset -d bp_dataset/
测试
stt = STT(MODEL_NAME)
CETUC
ds = load_data('cetuc_dataset')
result = ds.map(stt.batch_predict, batched=True, batch_size=8)
wer, mer, wil = calc_metrics(result["sentence"], result["predicted"])
print("CETUC WER:", wer)
CETUC WER: 0.05159104708285062
Common Voice
ds = load_data('commonvoice_dataset')
result = ds.map(stt.batch_predict, batched=True, batch_size=8)
wer, mer, wil = calc_metrics(result["sentence"], result["predicted"])
print("CV WER:", wer)
CV WER: 0.14031426198658084
LaPS
ds = load_data('lapsbm_dataset')
result = ds.map(stt.batch_predict, batched=True, batch_size=8)
wer, mer, wil = calc_metrics(result["sentence"], result["predicted"])
print("Laps WER:", wer)
Laps WER: 0.07432133838383838
MLS
ds = load_data('mls_dataset')
result = ds.map(stt.batch_predict, batched=True, batch_size=8)
wer, mer, wil = calc_metrics(result["sentence"], result["predicted"])
print("MLS WER:", wer)
MLS WER: 0.11678793514817509
SID
ds = load_data('sid_dataset')
result = ds.map(stt.batch_predict, batched=True, batch_size=8)
wer, mer, wil = calc_metrics(result["sentence"], result["predicted"])
print("Sid WER:", wer)
Sid WER: 0.12152357273433984
TEDx
ds = load_data('tedx_dataset')
result = ds.map(stt.batch_predict, batched=True, batch_size=8)
wer, mer, wil = calc_metrics(result["sentence"], result["predicted"])
print("TEDx WER:", wer)
TEDx WER: 0.24666815906766504
VoxForge
ds = load_data('voxforge_dataset')
result = ds.map(stt.batch_predict, batched=True, batch_size=8)
wer, mer, wil = calc_metrics(result["sentence"], result["predicted"])
print("VoxForge WER:", wer)
VoxForge WER: 0.11873106060606062
语言模型测试
!rm -rf ~/.cache
!gdown --id 1GJIKseP5ZkTbllQVgOL98R4yYAcIySFP # 基于维基百科训练
stt = STT(MODEL_NAME, lm='pt-BR-wiki.word.4-gram.arpa')
# !gdown --id 1dLFldy7eguPtyJj5OAlI4Emnx0BpFywg # 基于bp训练
# stt = STT(MODEL_NAME, lm='pt-BR.word.4-gram.arpa')
Cetuc
ds = load_data('cetuc_dataset')
result = ds.map(stt.batch_predict, batched=True, batch_size=8)
wer, mer, wil = calc_metrics(result["sentence"], result["predicted"])
print("CETUC WER:", wer)
CETUC WER: 0.030266462438593742
Common Voice
ds = load_data('commonvoice_dataset')
result = ds.map(stt.batch_predict, batched=True, batch_size=8)
wer, mer, wil = calc_metrics(result["sentence"], result["predicted"])
print("CV WER:", wer)
CV WER: 0.09577710237417715
LaPS
ds = load_data('lapsbm_dataset')
result = ds.map(stt.batch_predict, batched=True, batch_size=8)
wer, mer, wil = calc_metrics(result["sentence"], result["predicted"])
print("Laps WER:", wer)
Laps WER: 0.043617424242424235
MLS
ds = load_data('mls_dataset')
result = ds.map(stt.batch_predict, batched=True, batch_size=8)
wer, mer, wil = calc_metrics(result["sentence"], result["predicted"])
print("MLS WER:", wer)
MLS WER: 0.10642133314350002
SID
ds = load_data('sid_dataset')
result = ds.map(stt.batch_predict, batched=True, batch_size=8)
wer, mer, wil = calc_metrics(result["sentence"], result["predicted"])
print("Sid WER:", wer)
Sid WER: 0.11839021001747055
TEDx
ds = load_data('tedx_dataset')
result = ds.map(stt.batch_predict, batched=True, batch_size=8)
wer, mer, wil = calc_metrics(result["sentence"], result["predicted"])
print("TEDx WER:", wer)
TEDx WER: 0.22929952467810416
VoxForge
ds = load_data('voxforge_dataset')
result = ds.map(stt.batch_predict, batched=True, batch_size=8)
wer, mer, wil = calc_metrics(result["sentence"], result["predicted"])
print("VoxForge WER:", wer)
VoxForge WER: 0.11716314935064935
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
AIbase是一个专注于MCP服务的平台,为AI开发者提供高质量的模型上下文协议服务,助力AI应用开发。
简体中文