🚀 用於法語自動語音識別的微調版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 許可證。