🚀 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。