🚀 用于葡萄牙语语音识别的微调XLS - R 1B模型
本模型是在葡萄牙语数据集上对 [facebook/wav2vec2 - xls - r - 1b](https://huggingface.co/facebook/wav2vec2 - xls - r - 1b) 进行微调得到的。训练和验证数据来自 [Common Voice 8.0](https://huggingface.co/datasets/mozilla - foundation/common_voice_8_0)、[CORAA](https://github.com/nilc - nlp/CORAA)、Multilingual TEDx 和 Multilingual LibriSpeech。使用此模型时,请确保语音输入的采样率为16kHz。
该模型由 HuggingSound 工具进行微调,感谢 [OVHcloud](https://www.ovhcloud.com/en/public - cloud/ai - training/) 慷慨提供的GPU计算资源。
🚀 快速开始
模型信息
属性 |
详情 |
模型类型 |
用于葡萄牙语语音识别的微调XLS - R 1B模型 |
训练数据 |
Common Voice 8.0、CORAA、Multilingual TEDx、Multilingual LibriSpeech |
许可证 |
Apache - 2.0 |
标签 |
自动语音识别、hf - asr - leaderboard、mozilla - foundation/common_voice_8_0、pt、robust - speech - event |
模型评估结果
任务 |
数据集 |
指标 |
值 |
自动语音识别 |
Common Voice 8(葡萄牙语) |
测试字错误率 (WER) |
8.7 |
自动语音识别 |
Common Voice 8(葡萄牙语) |
测试字符错误率 (CER) |
2.55 |
自动语音识别 |
Common Voice 8(葡萄牙语,+LM) |
测试字错误率 (WER) |
6.04 |
自动语音识别 |
Common Voice 8(葡萄牙语,+LM) |
测试字符错误率 (CER) |
1.98 |
自动语音识别 |
Robust Speech Event - Dev Data(葡萄牙语) |
开发集字错误率 (WER) |
24.23 |
自动语音识别 |
Robust Speech Event - Dev Data(葡萄牙语) |
开发集字符错误率 (CER) |
11.3 |
自动语音识别 |
Robust Speech Event - Dev Data(葡萄牙语,+LM) |
开发集字错误率 (WER) |
19.41 |
自动语音识别 |
Robust Speech Event - Dev Data(葡萄牙语,+LM) |
开发集字符错误率 (CER) |
10.19 |
自动语音识别 |
Robust Speech Event - Test Data(葡萄牙语) |
测试字错误率 (WER) |
18.8 |
✨ 主要特性
- 基于微调的XLS - R 1B模型,适用于葡萄牙语语音识别任务。
- 支持使用语言模型 (LM) 来降低字错误率和字符错误率。
💻 使用示例
基础用法
使用 HuggingSound 库:
from huggingsound import SpeechRecognitionModel
model = SpeechRecognitionModel("jonatasgrosman/wav2vec2-xls-r-1b-portuguese")
audio_paths = ["/path/to/file.mp3", "/path/to/another_file.wav"]
transcriptions = model.transcribe(audio_paths)
高级用法
编写自己的推理脚本:
import torch
import librosa
from datasets import load_dataset
from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
LANG_ID = "pt"
MODEL_ID = "jonatasgrosman/wav2vec2-xls-r-1b-portuguese"
SAMPLES = 10
test_dataset = load_dataset("common_voice", LANG_ID, split=f"test[:{SAMPLES}]")
processor = Wav2Vec2Processor.from_pretrained(MODEL_ID)
model = Wav2Vec2ForCTC.from_pretrained(MODEL_ID)
def speech_file_to_array_fn(batch):
speech_array, sampling_rate = librosa.load(batch["path"], sr=16_000)
batch["speech"] = speech_array
batch["sentence"] = batch["sentence"].upper()
return batch
test_dataset = test_dataset.map(speech_file_to_array_fn)
inputs = processor(test_dataset["speech"], 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)
predicted_sentences = processor.batch_decode(predicted_ids)
📚 详细文档
评估命令
- 在
mozilla - foundation/common_voice_8_0
数据集的 test
分割上进行评估:
python eval.py --model_id jonatasgrosman/wav2vec2-xls-r-1b-portuguese --dataset mozilla-foundation/common_voice_8_0 --config pt --split test
- 在
speech - recognition - community - v2/dev_data
数据集上进行评估:
python eval.py --model_id jonatasgrosman/wav2vec2-xls-r-1b-portuguese --dataset speech-recognition-community-v2/dev_data --config pt --split validation --chunk_length_s 5.0 --stride_length_s 1.0
📄 许可证
本模型采用Apache - 2.0许可证。
📝 引用
如果您想引用此模型,可以使用以下格式:
@misc{grosman2021xlsr-1b-portuguese,
title={Fine-tuned {XLS-R} 1{B} model for speech recognition in {P}ortuguese},
author={Grosman, Jonatas},
howpublished={\url{https://huggingface.co/jonatasgrosman/wav2vec2-xls-r-1b-portuguese}},
year={2022}
}