w2v-bert-2.0-lang-id-lug-sna-lin-xog
A spoken language identification (LID) model that classifies short
audio clips into one of four languages — Luganda, Shona, Lingala,
or Lusoga — fine-tuned from
facebook/w2v-bert-2.0
with a sequence classification head, trained on the WAXAL corpus
only. This extends the 3-language
keystats/w2v-bert-2.0-lang-id-lug-sna-lin
family with Lusoga added as a fourth class.
Model description
facebook/w2v-bert-2.0 — a large-scale, multilingual self-supervised
speech encoder pretrained with a BERT-style masked prediction
objective — is used as the backbone, with a from-scratch audio
classification head fine-tuned to predict which of the four languages
a given audio clip is spoken in. Like the other LID models in this
collection, this model does not transcribe speech — it only outputs a
language label.
Training data
| Source | Role |
|---|---|
| google/WaxalNLP — Luganda, Shona, Lingala, Lusoga configs | train splits from all four language configs pooled together (each clip labeled with its language) for training; validation splits pooled together and held out for monitoring |
Only WAXAL data was used — no additional community datasets were
pooled in, unlike the -best LID variant for the 3-language set.
Training procedure
- Base model:
facebook/w2v-bert-2.0 - Architecture:
Wav2Vec2BertForSequenceClassification(audio classification head over the pretrained encoder), 4 output classes (Luganda, Shona, Lingala, Lusoga) - Sample rate: 16 kHz mono
- Hardware: single RTX PRO 6000
Evaluation results
This model scored ~99.9% accuracy on both the WAXAL validation and test splits, with only a small handful of clips misclassified out of the full evaluation sets.
Note: adding a fourth, more closely related language (Lusoga sits in the same broader Bantu family as Luganda, and the two are more acoustically similar to each other than to Shona or Lingala) makes the classification task somewhat harder than the 3-language case, which likely explains the small gap versus the 3-language model's 100% on WAXAL. As always, treat in-domain WAXAL numbers as an upper bound rather than a guarantee of real-world performance on out-of-domain audio.
How to use
import torch
import librosa
from transformers import Wav2Vec2BertForSequenceClassification, Wav2Vec2BertProcessor
MODEL_ID = "keystats/w2v-bert-2.0-lang-id-lug-sna-lin-xog"
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
processor = Wav2Vec2BertProcessor.from_pretrained(MODEL_ID)
model = Wav2Vec2BertForSequenceClassification.from_pretrained(MODEL_ID).to(DEVICE).eval()
audio_array, sr = librosa.load("path/to/audio.wav", sr=16000, mono=True)
inputs = processor(audio_array, sampling_rate=16000, return_tensors="pt")
with torch.no_grad():
logits = model(input_features=inputs.input_features.to(DEVICE)).logits
predicted_id = torch.argmax(logits, dim=-1).item()
predicted_label = model.config.id2label[predicted_id]
print(predicted_label) # "luganda", "shona", "lingala", or "lusoga"
Intended uses & limitations
- Intended for identifying which of Luganda, Shona, Lingala, or
Lusoga is being spoken in a given audio clip — useful as a
pre-processing step to route audio to the correct language-specific
ASR model (e.g. the Luganda
-main-bestor Lusoga-main-bestcheckpoints in this collection). - This is a closed-set 4-way classifier: it will always output one of the four trained languages, even for audio in a different language or non-speech audio. It has no "none of the above" / out-of-domain detection.
- Trained and evaluated only on WAXAL data — near-perfect validation/test accuracy reflects in-domain WAXAL audio conditions and may not carry over as-is to audio from very different recording conditions, speakers, or dialectal variation.
- Not a general-purpose language ID model — it only distinguishes between these four specific languages, not the full range of African languages or languages generally.
Citation
If you use this model, please cite the training/fine-tuning work and the underlying dataset:
@misc{keystats_wav2vec2bert_langid_lug_sna_lin_xog,
title={w2v-bert-2.0-lang-id-lug-sna-lin-xog: A Luganda/Shona/Lingala/Lusoga spoken language identification model fine-tuned from facebook/w2v-bert-2.0},
author={keystats},
year={2026},
howpublished={\url{https://huggingface.co/keystats/w2v-bert-2.0-lang-id-lug-sna-lin-xog}}
}
@misc{waxal,
title={WAXAL: A Multilingual African Speech Dataset},
author={Google},
howpublished={\url{https://huggingface.co/datasets/google/WaxalNLP}}
}
@inproceedings{w2vbert2,
title={Seamless: Multilingual Expressive and Streaming Speech Translation},
author={Seamless Communication and others},
year={2023},
howpublished={\url{https://huggingface.co/facebook/w2v-bert-2.0}}
}