Instructions to use Bwenge840/whisper-medium-ugandan-languages with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Bwenge840/whisper-medium-ugandan-languages with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("automatic-speech-recognition", model="Bwenge840/whisper-medium-ugandan-languages")# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForSpeechSeq2Seq processor = AutoProcessor.from_pretrained("Bwenge840/whisper-medium-ugandan-languages") model = AutoModelForSpeechSeq2Seq.from_pretrained("Bwenge840/whisper-medium-ugandan-languages", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Whisper Medium - Ugandan Languages
Whisper medium fine-tuned for Luganda, Runyankole, Acholi, and Lusoga transcription. One model supports all four languages; select the language when transcribing.
| Language | Code |
|---|---|
| Luganda | lug |
| Runyankole | nyn |
| Acholi | ach |
| Lusoga | sog |
Usage
pip install torch transformers==4.57.1 accelerate huggingface-hub soundfile scipy numpy
hf download Bwenge840/whisper-medium-ugandan-languages inference.py --local-dir .
python inference.py recording.wav --language lug
Use nyn, ach, or sog for the other languages. The helper loads the model and
its tokenizer, resamples audio to 16 kHz, and processes recordings in 30-second
windows. CUDA uses FP16; CPU uses FP32.
The four languages use added decoder tokens. Use the supplied helper or pass an explicit decoder prefix; Whisper's standard language argument does not recognize these codes. Always load the tokenizer from this repository with the model.
Python
For a mono or stereo recording at 16 kHz, up to 30 seconds:
import os
os.environ.setdefault("USE_TF", "0")
import soundfile as sf
import torch
from transformers import WhisperProcessor, WhisperForConditionalGeneration
repo = "Bwenge840/whisper-medium-ugandan-languages"
language = "lug" # lug, nyn, ach, sog
assert language in {"lug", "nyn", "ach", "sog"}
device = "cuda" if torch.cuda.is_available() else "cpu"
dtype = torch.float16 if device == "cuda" else torch.float32
processor = WhisperProcessor.from_pretrained(repo)
model = WhisperForConditionalGeneration.from_pretrained(
repo, dtype=dtype, low_cpu_mem_usage=True, device_map=device
).eval()
model.config.forced_decoder_ids = None
model.generation_config.forced_decoder_ids = None
model.generation_config.language = None
model.generation_config.task = None
model.generation_config.is_multilingual = False
audio, sample_rate = sf.read("recording.wav", dtype="float32", always_2d=True)
audio = audio.mean(axis=1)
assert sample_rate == 16000 and 0 < len(audio) <= 30 * sample_rate
inputs = processor.feature_extractor(
audio, sampling_rate=16000, return_tensors="pt", return_attention_mask=True
)
prefix = ["<|startoftranscript|>", f"<|{language}|>",
"<|transcribe|>", "<|notimestamps|>"]
prompt = torch.tensor([processor.tokenizer.convert_tokens_to_ids(prefix)], device=device)
with torch.inference_mode():
output = model.generate(
input_features=inputs.input_features.to(device=device, dtype=dtype),
attention_mask=inputs.attention_mask.to(device),
decoder_input_ids=prompt, max_new_tokens=440, num_beams=3,
)
print(processor.tokenizer.batch_decode(output, skip_special_tokens=True)[0].strip())
For longer recordings or other sample rates, use inference.py above.
Results
Preliminary evaluation on 100 held-out clips: 25 per language. Lower WER and
CER are better. The combined score uses 1 - (WER + CER) / 2; higher is better.
| Language | WER | CER | Combined score |
|---|---|---|---|
| Luganda | 23.95% | 5.50% | 85.27% |
| Runyankole | 40.53% | 10.01% | 74.73% |
| Acholi | 33.48% | 13.14% | 76.69% |
| Lusoga | 44.71% | 9.08% | 73.11% |
| Average across languages | 35.67% | 9.43% | 77.45% |
These are results from a small, non-random subset of the test set. The combined score is a custom summary, not standard accuracy. Evaluation details and examples.
Training and limitations
Full fine-tuning of openai/whisper-medium for five epochs on about 111 hours of
prepared WAXAL training audio. The checkpoint with the best validation loss was
saved. Training configuration.
Transcriptions still need review. Automatic language detection, code-switching, and performance on Whisper's original languages have not been evaluated. Output has no speaker labels or timestamps; words can be lost at 30-second boundaries. This is a Transformers checkpoint. Faster-whisper requires CTranslate2 conversion and custom language-prefix handling.
License and data
Apache 2.0. Training data: Google WAXAL, with the four language subsets contributed by Makerere University / Yogera under CC BY-SA 4.0. See LICENSE and data attribution.
- Downloads last month
- 55
Model tree for Bwenge840/whisper-medium-ugandan-languages
Base model
openai/whisper-medium