You need to agree to share your contact information to access this dataset

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

By clicking on 'Access repository' below, you agree to use this dataset responsibly and not attempt to determine the identity of speakers in the Luganda ASR dataset.

Log in or Sign Up to review the conditions and access this dataset content.

Luganda ASR Mental Health Dataset

Dataset Description

This dataset contains Luganda speech recordings with corresponding transcriptions focused on mental health conversations. The dataset follows the Common Voice structure and is designed for automatic speech recognition research in low-resource African languages.

Dataset Summary

The Luganda ASR Dataset is a specialized speech recognition corpus for Luganda (ISO 639-1: lg), primarily focused on mental health domain conversations. This dataset contains high-quality audio recordings with corresponding transcriptions in Luganda, designed to support automatic speech recognition research and applications for this low-resource African language.

Key Features:

  • Native Luganda speakers from Uganda
  • Mental health domain focus
  • High-quality audio recordings (16kHz sampling rate)
  • Comprehensive demographic metadata
  • Parquet format with embedded audio for efficient loading

Languages

Luganda (lg) – A Bantu language spoken primarily in Uganda, particularly in the central region including Kampala.

Dataset Structure

Data Instances

A typical data point comprises the audio data and its transcription in Luganda, along with demographic metadata.

{
    'client_id': 'speaker_001_mental_health_corpus',
    'audio': {
        'path': None,
        'array': array([-0.00012207, -0.00009155, ...], dtype=float32),
        'sampling_rate': 16000
    },
    'sentence': 'Mpulira nga ndi mutawu nnyo, era nga sirina maanyi ga kukola kintu kyonna.',
    'up_votes': 2,
    'down_votes': 0,
    'age': 'twenties',
    'gender': 'female',
    'accent': 'central',
    'locale': 'lg',
    'segment': '',
    'exposure_to_luganda': '15-20'
}

Data Fields

  • client_id (string): An id for which client (voice) made the recording
  • audio (dict): Audio data with decoded array and sampling rate (16kHz)
    • array: The decoded audio array
    • sampling_rate: Sample rate (16000 Hz)
  • sentence (string): The Luganda sentence transcription
  • up_votes (int64): How many upvotes the audio file has received
  • down_votes (int64): How many downvotes the audio file has received
  • age (string): The age group of the speaker
  • gender (string): The gender of the speaker
  • accent (string): Accent of the speaker
  • locale (string): The locale of the speaker (lg)
  • segment (string): Usually an empty field
  • exposure_to_luganda (string): Years of exposure to Luganda language

Data Splits

Split Samples Description
train 307 Training data for model development
test 76 Test set for evaluation

Usage

Basic Loading

from datasets import load_dataset

# Load the dataset
dataset = load_dataset("africanobyamugisha/ASR_mental_health_luganda_dataset")

# Access splits
train_data = dataset["train"]
test_data = dataset["test"]

# View dataset info
print(dataset)
print(f"Train examples: {len(train_data)}")
print(f"Test examples: {len(test_data)}")

# Access a single example
example = train_data[0]
print(f"Text: {example['sentence']}")
print(f"Audio shape: {example['audio']['array'].shape}")
print(f"Sample rate: {example['audio']['sampling_rate']}")
print(f"Speaker: {example['gender']}, {example['age']}")

Streaming (for Large Datasets)

from datasets import load_dataset

# Load in streaming mode
dataset = load_dataset(
    "africanobyamugisha/ASR_mental_health_luganda_dataset",
    streaming=True
)

# Iterate through examples
for example in dataset["train"]:
    print(example["sentence"])
    # Process audio
    audio_array = example["audio"]["array"]
    # Your processing here

Fine-tuning Wav2Vec2 for Luganda ASR

from datasets import load_dataset, Audio
from transformers import (
    Wav2Vec2CTCTokenizer,
    Wav2Vec2FeatureExtractor,
    Wav2Vec2Processor,
    Wav2Vec2ForCTC,
    TrainingArguments,
    Trainer
)
import torch
from dataclasses import dataclass
from typing import Dict, List, Union
import numpy as np

# Load dataset
dataset = load_dataset("africanobyamugisha/ASR_mental_health_luganda_dataset")

# Prepare vocabulary from transcriptions
def extract_all_chars(batch):
    all_text = " ".join(batch["sentence"])
    vocab = list(set(all_text))
    return {"vocab": [vocab], "all_text": [all_text]}

vocab_train = dataset["train"].map(
    extract_all_chars,
    batched=True,
    batch_size=-1,
    keep_in_memory=True,
    remove_columns=dataset["train"].column_names
)

vocab_test = dataset["test"].map(
    extract_all_chars,
    batched=True,
    batch_size=-1,
    keep_in_memory=True,
    remove_columns=dataset["test"].column_names
)

# Create vocabulary
vocab_list = list(set(vocab_train["vocab"][0]) | set(vocab_test["vocab"][0]))
vocab_dict = {v: k for k, v in enumerate(sorted(vocab_list))}
vocab_dict["|"] = vocab_dict[" "]
del vocab_dict[" "]
vocab_dict["[UNK]"] = len(vocab_dict)
vocab_dict["[PAD]"] = len(vocab_dict)

# Save vocabulary
import json
with open('vocab.json', 'w', encoding='utf-8') as vocab_file:
    json.dump(vocab_dict, vocab_file, ensure_ascii=False)

# Initialize tokenizer and processor
tokenizer = Wav2Vec2CTCTokenizer(
    "./vocab.json",
    unk_token="[UNK]",
    pad_token="[PAD]",
    word_delimiter_token="|"
)

feature_extractor = Wav2Vec2FeatureExtractor(
    feature_size=1,
    sampling_rate=16000,
    padding_value=0.0,
    do_normalize=True,
    return_attention_mask=True
)

processor = Wav2Vec2Processor(
    feature_extractor=feature_extractor,
    tokenizer=tokenizer
)

# Resample audio if needed
dataset = dataset.cast_column("audio", Audio(sampling_rate=16000))

# Prepare dataset
def prepare_dataset(batch):
    audio = batch["audio"]
    
    # Compute input values
    batch["input_values"] = processor(
        audio["array"],
        sampling_rate=audio["sampling_rate"]
    ).input_values[0]
    
    # Encode target text
    with processor.as_target_processor():
        batch["labels"] = processor(batch["sentence"]).input_ids
    
    return batch

dataset = dataset.map(
    prepare_dataset,
    remove_columns=dataset.column_names["train"],
    num_proc=4
)

# Data collator for padding
@dataclass
class DataCollatorCTCWithPadding:
    processor: Wav2Vec2Processor
    padding: Union[bool, str] = True

    def __call__(self, features: List[Dict[str, Union[List[int], torch.Tensor]]]) -> Dict[str, torch.Tensor]:
        # Split inputs and labels
        input_features = [{"input_values": feature["input_values"]} for feature in features]
        label_features = [{"input_ids": feature["labels"]} for feature in features]

        batch = self.processor.pad(
            input_features,
            padding=self.padding,
            return_tensors="pt",
        )

        labels_batch = self.processor.pad(
            labels=label_features,
            padding=self.padding,
            return_tensors="pt",
        )

        # Replace padding with -100 to ignore loss
        labels = labels_batch["input_ids"].masked_fill(
            labels_batch.attention_mask.ne(1), -100
        )

        batch["labels"] = labels

        return batch

data_collator = DataCollatorCTCWithPadding(processor=processor, padding=True)

# Load pre-trained model
model = Wav2Vec2ForCTC.from_pretrained(
    "facebook/wav2vec2-base",
    attention_dropout=0.1,
    hidden_dropout=0.1,
    feat_proj_dropout=0.0,
    mask_time_prob=0.05,
    layerdrop=0.1,
    ctc_loss_reduction="mean",
    pad_token_id=processor.tokenizer.pad_token_id,
    vocab_size=len(processor.tokenizer)
)

# Freeze feature encoder
model.freeze_feature_encoder()

# Training arguments
training_args = TrainingArguments(
    output_dir="./wav2vec2-luganda-asr",
    group_by_length=True,
    per_device_train_batch_size=8,
    per_device_eval_batch_size=8,
    evaluation_strategy="steps",
    num_train_epochs=30,
    fp16=True,
    save_steps=100,
    eval_steps=100,
    logging_steps=10,
    learning_rate=3e-4,
    warmup_steps=500,
    save_total_limit=2,
    push_to_hub=False,
)

# Initialize trainer
trainer = Trainer(
    model=model,
    data_collator=data_collator,
    args=training_args,
    train_dataset=dataset["train"],
    eval_dataset=dataset["test"],
    tokenizer=processor.feature_extractor,
)

# Train
trainer.train()

Evaluation with Word Error Rate (WER)

import evaluate
from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
import torch

# Load your fine-tuned model
model = Wav2Vec2ForCTC.from_pretrained("./wav2vec2-luganda-asr")
processor = Wav2Vec2Processor.from_pretrained("./wav2vec2-luganda-asr")

# Load WER metric
wer_metric = evaluate.load("wer")

def evaluate_model(batch):
    inputs = processor(
        batch["audio"]["array"],
        sampling_rate=batch["audio"]["sampling_rate"],
        return_tensors="pt",
        padding=True
    )
    
    with torch.no_grad():
        logits = model(inputs.input_values).logits
    
    pred_ids = torch.argmax(logits, dim=-1)
    batch["prediction"] = processor.batch_decode(pred_ids)[0]
    batch["reference"] = batch["sentence"]
    
    return batch

# Evaluate on test set
result = dataset["test"].map(evaluate_model)

predictions = result["prediction"]
references = result["reference"]

wer = wer_metric.compute(predictions=predictions, references=references)
print(f"Word Error Rate: {wer:.4f}")

Using with Whisper Models

from transformers import WhisperProcessor, WhisperForConditionalGeneration
from datasets import load_dataset

# Load dataset
dataset = load_dataset("africanobyamugisha/ASR_mental_health_luganda_dataset")

# Load Whisper model (you may need to fine-tune for Luganda)
processor = WhisperProcessor.from_pretrained("openai/whisper-small")
model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-small")

# Process audio
def prepare_for_whisper(batch):
    audio = batch["audio"]
    input_features = processor(
        audio["array"],
        sampling_rate=audio["sampling_rate"],
        return_tensors="pt"
    ).input_features
    
    return {"input_features": input_features[0]}

dataset = dataset.map(prepare_for_whisper)

# Inference example
sample = dataset["test"][0]
input_features = sample["input_features"].unsqueeze(0)

# Generate transcription
predicted_ids = model.generate(input_features)
transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]

print(f"Predicted: {transcription}")
print(f"Reference: {dataset['test'][0]['sentence']}")

Dataset Creation

This dataset was created by recording native Luganda speakers reading from a curated mental health text corpus, ensuring culturally appropriate and domain-specific content. The audio was recorded at 16kHz sampling rate and stored in Parquet format with embedded audio for efficient processing.

Curation Rationale

This dataset addresses the critical lack of speech recognition resources for Luganda, particularly in specialized domains like mental health. By focusing on mental health conversations, this dataset enables:

  • Development of culturally sensitive mental health applications
  • Speech recognition for telehealth services in Uganda
  • Support for low-resource language ASR research
  • Preservation of domain-specific Luganda vocabulary

Source Data

The text corpus was carefully curated to include mental health-related phrases and conversations appropriate for the Ugandan context, reviewed by native speakers and mental health professionals.

Annotations

Demographic information (age, gender, accent, language exposure) was self-reported by speakers. Quality control was performed through community voting (up_votes/down_votes).

Personal and Sensitive Information

This dataset contains voice recordings that could potentially be used to identify speakers. Users must agree to responsible use and not attempt to determine speaker identities. No personally identifiable information is included in the metadata.

Considerations for Using the Data

Social Impact

This dataset contributes to:

  • Increased accessibility of mental health services in Uganda
  • Digital inclusion for Luganda speakers
  • Preservation and promotion of the Luganda language
  • Development of culturally appropriate AI technologies

Limitations

  • Limited size (383 samples) - may require data augmentation
  • Mental health domain-specific - may not generalize to other domains
  • Regional accent bias toward central Uganda
  • Limited age diversity in speakers

Additional Information

Dataset Curators

Africano Byamugisha

Licensing Information

This dataset is released under the MIT License. See LICENSE file for details.

Citation Information

@dataset{luganda_asr_2025,
  author = {Byamugisha, Africano},
  title = {Luganda ASR Dataset: Mental Health Domain Speech Recognition Corpus},
  year = {2025},
  publisher = {Hugging Face},
  url = {https://huggingface.co/datasets/africanobyamugisha/ASR_mental_health_luganda_dataset},
  note = {Luganda automatic speech recognition dataset with mental health domain focus}
}

Contributions

Contributions to improve the dataset are welcome! Please open an issue or pull request on the dataset repository.

Acknowledgments

Special thanks to:

  • All volunteer speakers who contributed their voices
  • Makerere University for supporting this research
  • The Luganda language community for feedback and validation
  • Mental health professionals who reviewed the content for cultural appropriateness
Downloads last month
3