Model
This model is a fine-tuned version of ntu-spml/distilhubert on the Nooon/Donate_a_cry dataset for baby cry classification — detecting the reason behind an infant's cry from raw audio.
This model classifies baby cry audio recordings into 5 categories representing common infant distress signals:
| Label ID | Label Name | Description |
|---|---|---|
| 0 | belly_pain | Cry indicating abdominal pain |
| 1 | burping | Cry indicating need to burp |
| 2 | discomfort | Cry indicating general discomfort |
| 3 | hungry | Cry indicating hunger |
| 4 | tired | Cry indicating tiredness/sleepiness |
The model uses DistilHuBERT, a distilled version of HuBERT (Hidden-Unit BERT), which is a self-supervised speech representation model. It was fine-tuned end-to-end on balanced baby cry audio data to learn acoustic patterns associated with each cry type.
The Donate_a_cry dataset contains real infant cry recordings labeled across 5 categories. The original dataset has class imbalance, which was addressed before training.
The raw dataset was preprocessed and balanced using the following pipeline:
16,000 × 10 = 160,000 samples (10 seconds at 16 kHz) using zero-padding for shorter clips and truncation for longer ones.AutoFeatureExtractor from DistilHuBERT was applied with:
ntu-spml/distilhubertattention_dropout = 0.5hidden_dropout = 0.5final_dropout = 0.5feat_proj_dropout = 0.5mask_time_prob = 0.05 (SpecAugment-style masking)| Hyperparameter | Value |
|---|---|
learning_rate | 0.001 |
train_batch_size | 16 |
eval_batch_size | 16 |
num_train_epochs | 10 |
seed | 42 |
optimizer | Adam (β₁=0.9, β₂=0.999, ε=1e-8) |
lr_scheduler_type | Linear |
lr_scheduler_warmup_ratio | 0.1 |
gradient_accumulation_steps | 1 |
early_stopping_patience | 3 epochs |
best_model_metric | accuracy |
| Library | Version |
|---|---|
| Transformers | 4.41.2 |
| PyTorch | 2.1.2 |
| Datasets | 2.19.2 |
| Tokenizers | 0.19.1 |
| imbalanced-learn | (SMOTE) |
The model was evaluated on a held-out 20% split of the SMOTE-balanced dataset. The following metrics were computed:
from transformers import pipeline
pipe = pipeline("audio-classification", model="AmeerHesham/distilhubert-finetuned-baby_cry")
# Pass a local audio file or URL
result = pipe("baby_cry_sample.wav")
print(result)
# Example output: [{'score': 0.82, 'label': 'hungry'}, ...]
from transformers import AutoProcessor, AutoModelForAudioClassification
import torch
processor = AutoProcessor.from_pretrained("AmeerHesham/distilhubert-finetuned-baby_cry")
model = AutoModelForAudioClassification.from_pretrained("AmeerHesham/distilhubert-finetuned-baby_cry")
# Load your audio (must be 16kHz)
import librosa
audio, sr = librosa.load("baby_cry_sample.wav", sr=16000)
inputs = processor(audio, sampling_rate=sr, return_tensors="pt")
with torch.no_grad():
logits = model(**inputs).logits
predicted_class_id = logits.argmax().item()
print(model.config.id2label[predicted_class_id])
id2label = {
'0': 'belly_pain',
'1': 'burping',
'2': 'discomfort',
'3': 'hungry',
'4': 'tired'
}
If you use this model in your research or application, please cite the base model and dataset:
@misc{distilhubert-baby-cry,
author = {Amir Hesham},
title = {DistilHuBERT Fine-tuned for Baby Cry Classification},
year = {2024},
publisher = {HuggingFace},
url = {https://huggingface.co/AmeerHesham/distilhubert-finetuned-baby_cry}
}
This model was developed as part of the Bambino graduation project — a mobile application for pregnant mothers and infants that integrates:
Model developed by AmeerHesham