Views
No views yet
| Model | Common Voice 9.0 | MLS | VoxPopuli | Fleurs |
|---|---|---|---|---|
| openai/whisper-small | 22.7 | 16.2 | 15.7 | 15.0 |
| openai/whisper-medium | 16.0 | 8.9 | 12.2 | 8.7 |
| openai/whisper-large | 14.7 | 8.9 | 11.0 | 7.7 |
| openai/whisper-large-v2 | 13.9 | 7.3 | 11.4 | 8.3 |
WER (greedy search) / WER (beam search with beam width 5).| Model | Common Voice 11.0 | MLS | VoxPopuli | Fleurs |
|---|---|---|---|---|
| bofenghuang/whisper-small-cv11-french | 11.76 / 10.99 | 9.65 / 8.91 | 14.45 / 13.66 | 10.76 / 9.83 |
| bofenghuang/whisper-medium-cv11-french | 9.03 / 8.54 | 6.34 / 5.86 | 11.64 / 11.35 | 7.13 / 6.85 |
| bofenghuang/whisper-medium-french | 9.03 / 8.73 | 4.60 / 4.44 | 9.53 / 9.46 | 6.33 / 5.94 |
| bofenghuang/whisper-large-v2-cv11-french | 8.05 / 7.67 | 5.56 / 5.28 | 11.50 / 10.69 | 5.42 / 5.05 |
| bofenghuang/whisper-large-v2-french | 8.15 / 7.83 | 4.20 / 4.03 | 9.10 / 8.66 | 5.22 / 4.98 |
1import torch
2
3from datasets import load_dataset
4from transformers import pipeline
5
6device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
7
8# Load pipeline
9pipe = pipeline("automatic-speech-recognition", model="bofenghuang/whisper-medium-french", device=device)
10
11# NB: set forced_decoder_ids for generation utils
12pipe.model.config.forced_decoder_ids = pipe.tokenizer.get_decoder_prompt_ids(language="fr", task="transcribe")
13
14# Load data
15ds_mcv_test = load_dataset("mozilla-foundation/common_voice_11_0", "fr", split="test", streaming=True)
16test_segment = next(iter(ds_mcv_test))
17waveform = test_segment["audio"]
18
19# Run
20generated_sentences = pipe(waveform, max_new_tokens=225)["text"] # greedy
21# generated_sentences = pipe(waveform, max_new_tokens=225, generate_kwargs={"num_beams": 5})["text"] # beam search
22
23# Normalise predicted sentences if necessary1import torch
2import torchaudio
3
4from datasets import load_dataset
5from transformers import AutoProcessor, AutoModelForSpeechSeq2Seq
6
7device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
8
9# Load model
10model = AutoModelForSpeechSeq2Seq.from_pretrained("bofenghuang/whisper-medium-french").to(device)
11processor = AutoProcessor.from_pretrained("bofenghuang/whisper-medium-french", language="french", task="transcribe")
12
13# NB: set forced_decoder_ids for generation utils
14model.config.forced_decoder_ids = processor.get_decoder_prompt_ids(language="fr", task="transcribe")
15
16# 16_000
17model_sample_rate = processor.feature_extractor.sampling_rate
18
19# Load data
20ds_mcv_test = load_dataset("mozilla-foundation/common_voice_11_0", "fr", split="test", streaming=True)
21test_segment = next(iter(ds_mcv_test))
22waveform = torch.from_numpy(test_segment["audio"]["array"])
23sample_rate = test_segment["audio"]["sampling_rate"]
24
25# Resample
26if sample_rate != model_sample_rate:
27 resampler = torchaudio.transforms.Resample(sample_rate, model_sample_rate)
28 waveform = resampler(waveform)
29
30# Get feat
31inputs = processor(waveform, sampling_rate=model_sample_rate, return_tensors="pt")
32input_features = inputs.input_features
33input_features = input_features.to(device)
34
35# Generate
36generated_ids = model.generate(inputs=input_features, max_new_tokens=225) # greedy
37# generated_ids = model.generate(inputs=input_features, max_new_tokens=225, num_beams=5) # beam search
38
39# Detokenize
40generated_sentences = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
41
42# Normalise predicted sentences if necessary