Run this model with HF Jobs
Run xlab-gbe/whisper-small-fon on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/xlab-gbe/whisper-small-fon. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/xlab-gbe/whisper-small-fon on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use xlab-gbe/whisper-small-fon with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use xlab-gbe/whisper-small-fon with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("automatic-speech-recognition", model="xlab-gbe/whisper-small-fon")# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForSpeechSeq2Seq processor = AutoProcessor.from_pretrained("xlab-gbe/whisper-small-fon") model = AutoModelForSpeechSeq2Seq.from_pretrained("xlab-gbe/whisper-small-fon", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Fon speech recognition (Whisper-small)
A Fon speech recognizer fine-tuned from openai/whisper-small (242 M parameters). It writes Fon with its tone marks. Training added simulated background voices (babble), so it holds up better when other people speak near the microphone.
- Input: 16 kHz mono audio, one utterance up to 30 s.
- Output: Fon text with tone marks, in lower case and without punctuation.
- Decoding: greedy, with a small loop guard (below) that removes Whisper's repetition loops.
- Licence: CC BY-SA 4.0. The training speech comes from JaimeMaLangue/JML-fon-speech-v1 (CC BY-SA 4.0).
- Part of: a set of Fon/French models (speech recognition, translation). Paper in preparation. The matching translator is xlab-gbe/nllb-fon-fr-1.3b.
How to use
Whisper has no Fon language token; the model was trained with the French token, which must be kept.
import json, math
import librosa, torch
from huggingface_hub import hf_hub_download
from transformers import WhisperForConditionalGeneration, WhisperProcessor
repo = "xlab-gbe/whisper-small-fon"
proc = WhisperProcessor.from_pretrained(repo)
model = WhisperForConditionalGeneration.from_pretrained(repo).eval()
guard = json.load(open(hf_hub_download(repo, "loop_guard.json")))
def collapse(text, K):
"""Cut any 1-4 word group repeated more than K times in a row back to K copies."""
w, changed = text.split(), True
while changed:
changed = False
for n in range(1, 5):
s = 0
while s + n <= len(w):
k = 1
while w[s + k * n:s + (k + 1) * n] == w[s:s + n]:
k += 1
if k > K:
w, changed = w[:s + K * n] + w[s + k * n:], True
s += 1
return " ".join(w)
@torch.no_grad()
def transcribe(path):
audio, _ = librosa.load(path, sr=16000)
cap = min(225, math.ceil(guard["R_p999"] * len(audio) / 16000) + 10) # length cap from the audio duration
feats = proc(audio, sampling_rate=16000, return_tensors="pt").input_features
ids = model.generate(feats, language="fr", task="transcribe", num_beams=1, do_sample=False, max_new_tokens=cap)
text = " ".join(proc.batch_decode(ids, skip_special_tokens=True)[0].split())
return collapse(text, guard["K"])
print(transcribe("sentence.wav"))
Loop guard (loop_guard.json, set from the training transcripts only): the number of new tokens is capped at
ceil(16.99 x seconds) + 10 (16.99 tokens per second is the 99.9th percentile of the training transcripts), and a
1-4 word group repeated more than 4 times in a row is cut back to 4 copies (4 is the most found in training). On
clean audio it changed no output in our tests; under noise it removes rare loops.
Evaluation
Character error rate (CER, %) with tones unless said, lower is better. Test speakers and sentences were not used for training. The two JML sets were used to compare training recipes; ALFFA was never used for any choice. The released checkpoint is training seed 1; seeds 2 and 3 of the same recipe show the spread.
| test | condition | CER | seeds 1 / 2 / 3 |
|---|---|---|---|
| JML held-out set (876 utterances, 11 speakers) | clean | 6.72 | |
| same | babble 10 dB | 9.95 | |
| same | babble 5 dB | 14.33 | |
| JML sample (X19, harder sentences) | clean | 9.81 | 9.81 / 10.38 / 9.94 |
| ALFFA Fongbe test (other recordings, no tones in its references) | clean, tones removed | 10.97 | 10.97 / 11.12 / 10.90 |
Word error rate with tones on the JML held-out set, clean: 15.45. ALFFA word error rate without tones: 33.10.
Against the same recipe without babble training, the babble 10 dB CER drops by 4.0 points on average over 3 seeds
(p < 0.01 by speakers in each seed), with no loss on clean speech. On ALFFA the model is level with our earlier
model and with kanbior (11.07), and behind finanfa-asr-v6 (8.58), whose training data are not documented.
Babble is simulated by mixing other speakers of the same set.
Limitations
- Trained on read speech. Spontaneous speech, market or phone recordings, accents and recording conditions far from the training data give clearly higher error rates (without tones, the CER on ALFFA is about twice that on JML).
- Tone marks are the most frequent source of errors, followed by word boundaries.
- Numbers, prices and dates were not evaluated separately.
- One utterance up to 30 s at a time; longer audio must be cut first.
- About 4 to 6 s per utterance on a shared 4-core CPU; much faster on a GPU.
Citation
Paper in preparation. Until then, please cite this repository and the JML dataset.
- Downloads last month
- 31
Model tree for xlab-gbe/whisper-small-fon
Base model
openai/whisper-small