🚀 用于法语自动语音识别的微调版whisper-large-v2模型
该模型是 openai/whisper-large-v2 的微调版本,在包含超过2200小时法语语音音频的复合数据集上进行训练。这些数据集来自 Common Voice 11.0、Multilingual LibriSpeech、Voxpopuli、Fleurs、Multilingual TEDx、MediaSpeech 和 African Accented French 的训练集和验证集。使用该模型时,请确保语音输入的采样率为16Khz。该模型不会预测大小写或标点符号。

🚀 快速开始
本模型可用于法语的自动语音识别任务。使用前需确保语音输入采样率为16Khz,且该模型不会预测大小写和标点符号。
✨ 主要特性
📦 安装指南
文档未提及安装步骤,可参考 🤗 Transformers 库的安装方式。
💻 使用示例
基础用法
使用 🤗 Pipeline 进行推理:
import torch
from datasets import load_dataset
from transformers import pipeline
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
pipe = pipeline("automatic-speech-recognition", model="bofenghuang/whisper-large-v2-french", device=device)
pipe.model.config.forced_decoder_ids = pipe.tokenizer.get_decoder_prompt_ids(language="fr", task="transcribe")
ds_mcv_test = load_dataset("mozilla-foundation/common_voice_11_0", "fr", split="test", streaming=True)
test_segment = next(iter(ds_mcv_test))
waveform = test_segment["audio"]
generated_sentences = pipe(waveform, max_new_tokens=225)["text"]
高级用法
使用 🤗 底层API进行推理:
import torch
import torchaudio
from datasets import load_dataset
from transformers import AutoProcessor, AutoModelForSpeechSeq2Seq
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
model = AutoModelForSpeechSeq2Seq.from_pretrained("bofenghuang/whisper-large-v2-french").to(device)
processor = AutoProcessor.from_pretrained("bofenghuang/whisper-large-v2-french", language="french", task="transcribe")
model.config.forced_decoder_ids = processor.get_decoder_prompt_ids(language="fr", task="transcribe")
model_sample_rate = processor.feature_extractor.sampling_rate
ds_mcv_test = load_dataset("mozilla-foundation/common_voice_11_0", "fr", split="test", streaming=True)
test_segment = next(iter(ds_mcv_test))
waveform = torch.from_numpy(test_segment["audio"]["array"])
sample_rate = test_segment["audio"]["sampling_rate"]
if sample_rate != model_sample_rate:
resampler = torchaudio.transforms.Resample(sample_rate, model_sample_rate)
waveform = resampler(waveform)
inputs = processor(waveform, sampling_rate=model_sample_rate, return_tensors="pt")
input_features = inputs.input_features
input_features = input_features.to(device)
generated_ids = model.generate(inputs=input_features, max_new_tokens=225)
generated_sentences = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
📚 详细文档
性能表现
预训练模型的WER
以下是预训练模型在 Common Voice 9.0、Multilingual LibriSpeech、Voxpopuli 和 Fleurs 上的字错率(WER)。这些结果来自原始 论文。
微调模型的WER
以下是微调模型在 Common Voice 11.0、Multilingual LibriSpeech、Voxpopuli 和 Fleurs 上的字错率(WER)。请注意,这些评估数据集经过过滤和预处理,仅包含法文字符,并去除了撇号以外的标点符号。表格中的结果以 WER (贪心搜索) / WER (束宽为5的束搜索)
形式呈现。
📄 许可证
本模型采用 Apache-2.0 许可证。