Views
No views yet
openai/whisper-small fine-tuned for Swahili–English code-switched speech recognition (including Sheng slang), part of a bilingual voice-agent project for East Africa. The adapter keeps Whisper's multilingual weights frozen and adds low-rank adapters to the attention q_proj/v_proj layers, then is merged back into the base weights for deployment.⚠️ Status: experimental quick-test checkpoint. This was trained with the notebook'sQUICK_TESTsetting (50 steps), not the full 5,000-step production run. It is intended to validate the training pipeline and is not a converged, production-quality model.
sw), English (en), and code-switched Swahili–English (incl. Sheng)liva-ai/swahili-english-asr) is CC-BY-NC. The base model (openai/whisper-small, MIT) does not impose this; retraining on CC0/own data would lift the non-commercial restriction.openai/whisper-small (244M params)1from transformers import WhisperForConditionalGeneration, WhisperProcessor
2from peft import PeftModel
3import torch
4
5base_model_id = "openai/whisper-small"
6adapter_id = "Karsamanja/swahili-english-whisper-cs-lora"
7
8processor = WhisperProcessor.from_pretrained(adapter_id)
9model = WhisperForConditionalGeneration.from_pretrained(base_model_id)
10model = PeftModel.from_pretrained(model, adapter_id)
11
12# Optional: merge for deployment (no peft dependency at inference)
13# model = model.merge_and_unload()
14
15audio_array = ... # 16 kHz mono float32 numpy array
16inputs = processor.feature_extractor(audio_array, sampling_rate=16000, return_tensors="pt")
17with torch.no_grad():
18 generated = model.generate(
19 inputs.input_features,
20 language=None, # auto-detect: do not force a language (code-switch mode)
21 task="transcribe",
22 temperature=0.0,
23 )
24print(processor.batch_decode(generated, skip_special_tokens=True)[0])QUICK_TEST = False (5,000 steps) before any real use.liva-ai/swahili-english-asr; dialectal/Sheng coverage is limited and other East-African language varieties (Kiswahili sanifu vs. colloquial) may be underrepresented.1# Adapter-style loading (see Direct Use for the full snippet)
2from transformers import WhisperForConditionalGeneration, WhisperProcessor
3from peft import PeftModel
4
5model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-small")
6model = PeftModel.from_pretrained(model, "Karsamanja/swahili-english-whisper-cs-lora")
7processor = WhisperProcessor.from_pretrained("Karsamanja/swahili-english-whisper-cs-lora")liva-ai/swahili-english-asr (~50h, conversational Swahili–English, CC-BY-NC, gated).Shelton1013/SwitchLingua_audio was loaded as an intended supplementary corpus in the training notebook but was not actually consumed by the quick-test training run.whisper-small. Encoder–decoder compatibility required a small PEFT wrapper that strips the leaked input_ids kwarg. Audio resampled to 16 kHz mono; text tokenized with max_length=448.datasets Audio(sampling_rate=16000).input_ids (max 448); collator pads features and masks labels with -100.q_proj, v_proj]liva-ai/swahili-english-asr (streaming, first 15), evaluated on CPU at batch size 2, language auto-detect. Indicative only — tiny, non-representative sample.| Metric | Fine-tuned (merged LoRA) | whisper-small baseline | whisper-tiny baseline (older) |
|---|---|---|---|
| Overall WER | 0.996 | 0.999 | 0.9996 |
| Overall CER | 0.962 | 0.968 | 0.995 |
| Swahili WER (approx.) | 0.998 | 1.000 | 1.000 |
| English WER (approx.) | 1.000 | 0.993 | 1.000 |
| PIER@3 | 0.998 | 0.996 | 1.000 |
Speaker 2 [00:00:00.000 - 00:00:04.930]: …, [laughing], [unintelligible] — while the model transcribes a single audio segment (≤30s window). Consequently every model saturates at WER ≈ 1.0 (whisper-tiny also scored 0.9996; one smoke run even produced WER > 1.0, which is structurally impossible with sane reference/prediction pairs). The fine-tuned model slightly edges the same-base baseline (0.996 vs 0.999 WER), but no conclusion about quality should be drawn. A fair evaluation requires a clean single-utterance benchmark (e.g., Common Voice sw, FLEURS sw, or turn-segmented transcripts).1@misc{karsamanja2026swahilienglishwhispercs,
2 title={Swahili--English Code-Switching Whisper (LoRA)},
3 author={Karsamanja},
4 year={2026},
5 howpublished={\url{https://huggingface.co/Karsamanja/swahili-english-whisper-cs-lora}},
6 note={Quick-test LoRA adapter fine-tuned from openai/whisper-small}
7}