🚀 Wav2vec 2.0 base-voxpopuli-sv-swedish
本项目是基于Facebook的 VoxPopuli-sv base 模型,使用NST和Common Voice数据进行微调后的版本。在不使用语言模型的情况下进行评估,结果如下:NST + Common Voice测试集(占总句子的2%)的字错率(WER)为 5.62%,Common Voice测试集的字错率(WER)为 19.15%。使用该模型时,请确保语音输入的采样率为16kHz。
🚀 快速开始
本模型可直接使用(无需语言模型),具体使用方法如下:
💻 使用示例
基础用法
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-base-voxpopuli-sv-swedish")
model = Wav2Vec2ForCTC.from_pretrained("KBLab/wav2vec2-base-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)作为评估指标。
模型索引
- 模型名称:Wav2vec 2.0 base VoxPopuli-sv swedish
- 评估结果:
- 任务:语音识别(automatic-speech-recognition)
- 数据集:NST Swedish ASR Database
- 评估指标:测试字错率(Test WER),值为 5.619804368919309
- 任务:语音识别(automatic-speech-recognition)
- 数据集:Common Voice(sv-SE)
- 评估指标:测试字错率(Test WER),值为 19.145252414798616
许可证
本模型使用的许可证为 cc-by-nc-4.0。
标签
本模型的标签包括:audio、automatic-speech-recognition、speech、voxpopuli。
⚠️ 重要提示
使用该模型时,请确保语音输入的采样率为16kHz。