模型:
ccoreilly/wav2vec2-large-100k-voxpopuli-catala
⚠️NOTICE⚠️:此模型已移至以下URL: https://huggingface.co/softcatala/wav2vec2-large-100k-voxpopuli-catala
使用 Common Voice 和 ParlamentParla 数据集在加泰罗尼亚语上进行Fine-tuned facebook/wav2vec2-large-100k-voxpopuli 。
注意:使用的训练/验证/测试集与 CommonVoice 6.1数据集不完全匹配。使用了自定义的训练集,结合了CommonVoice和ParlamentParla数据集,可以在 here 中找到。在CV测试数据集上进行评估将产生有偏差的WER,因为该数据集的1144个音频文件在训练/评估该模型时使用了。WER是使用这个在训练/评估过程中模型未见过的 test.csv 计算出来的。
您可以在github存储库 ccoreilly/wav2vec2-catala 中找到训练和评估脚本。
使用此模型时,请确保您的语音输入采样率为16kHz。
在模型未见的以下数据集上评估了单词错误率:
| Dataset | WER |
|---|---|
| 1238321 | 5.98% |
| 1239321 | 12.14% |
| Audiobook “La llegenda de Sant Jordi” | 12.02% |
可以直接(无需语言模型)使用该模型,如下所示:
import torch
import torchaudio
from datasets import load_dataset
from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
test_dataset = load_dataset("common_voice", "ca", split="test[:2%]")
processor = Wav2Vec2Processor.from_pretrained("ccoreilly/wav2vec2-large-100k-voxpopuli-catala")
model = Wav2Vec2ForCTC.from_pretrained("ccoreilly/wav2vec2-large-100k-voxpopuli-catala")
resampler = torchaudio.transforms.Resample(48_000, 16_000)
# Preprocessing the datasets.
# We need to read the audio files as arrays
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])