🚀 Wav2vec 2.0 large-voxpopuli-sv-swedish
这是在Facebook的VoxPopuli - sv large模型基础上,使用瑞典广播、NST和Common Voice数据进行额外预训练和微调的版本,可用于自动语音识别任务。
🚀 快速开始
请注意,此模型性能更佳,且许可限制更少。
该模型是在Facebook的 VoxPopuli - sv large 模型基础上,使用瑞典广播、NST和Common Voice数据进行了额外的预训练和微调。在不使用语言模型的情况下进行评估,结果如下:NST + Common Voice测试集(占总句子的2%)的字错率(WER)为 3.95%。Common Voice测试集的字错率(WER)直接为 10.99%,使用4 - gram语言模型时为 7.82%。
使用此模型时,请确保您的语音输入采样率为16kHz。
✨ 主要特性
- 数据丰富:使用瑞典广播、NST和Common Voice数据进行额外预训练和微调。
- 性能评估:在不同测试集上有明确的字错率(WER)和字符错误率(CER)指标。
📦 安装指南
文档未提及具体安装步骤,故跳过此章节。
💻 使用示例
基础用法
import torch
import torchaudio
from datasets import load_dataset
from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
test_dataset = load_dataset("common_voice", "sv-SE", split="test[:2%]")
processor = Wav2Vec2Processor.from_pretrained("KBLab/wav2vec2-large-voxpopuli-sv-swedish")
model = Wav2Vec2ForCTC.from_pretrained("KBLab/wav2vec2-large-voxpopuli-sv-swedish")
resampler = torchaudio.transforms.Resample(48_000, 16_000)
def speech_file_to_array_fn(batch):
speech_array, sampling_rate = torchaudio.load(batch["path"])
batch["speech"] = resampler(speech_array).squeeze().numpy()
return batch
test_dataset = test_dataset.map(speech_file_to_array_fn)
inputs = processor(test_dataset["speech"][:2], sampling_rate=16_000, return_tensors="pt", padding=True)
with torch.no_grad():
logits = model(inputs.input_values, attention_mask=inputs.attention_mask).logits
predicted_ids = torch.argmax(logits, dim=-1)
print("Prediction:", processor.batch_decode(predicted_ids))
print("Reference:", test_dataset["sentence"][:2])
高级用法
文档未提及高级用法相关内容,故跳过此部分。
📚 详细文档
属性 |
详情 |
数据集 |
common_voice、NST Swedish ASR Database |
评估指标 |
字错率(wer)、字符错误率(cer) |
标签 |
音频、自动语音识别、语音、voxpopuli |
许可证 |
cc - by - nc - 4.0 |
模型评估结果
- 任务:语音识别(automatic - speech - recognition)
- 数据集:Common Voice(sv - SE)
- 指标:
- 测试字错率(Test WER):10.994764
- 测试字符错误率(Test CER):3.946846
🔧 技术细节
此模型在1000小时的瑞典本地广播上进行了额外的预训练,在NST + CommonVoice上进行了120000次更新的微调,然后仅在CommonVoice上又进行了20000次更新的微调。在CommonVoice上的额外微调在一定程度上影响了其在NST + CommonVoice测试集上的性能,但不出所料地提高了其在CommonVoice测试集上的性能。总体而言,它的表现似乎更好(需要引用证明)。
📄 许可证
本模型使用的许可证为 cc - by - nc - 4.0。