Spaces:
Running on Zero
A newer version of the Gradio SDK is available: 6.24.0
title: Audio Mood Classifier
emoji: π΅
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 5.33.0
app_file: app.py
pinned: false
fullWidth: false
license: apache-2.0
short_description: Classify the mood of an uploaded song
suggested_hardware: zero-a10g
startup_duration_timeout: 45m
preload_from_hub:
- guyPerry/audio-mood-classifier
models:
- guyPerry/audio-mood-classifier
π΅ Audio Mood Classifier π΅
Can a machine feel the mood of a song?
Upload any song (MP3) and get an instant mood prediction from a fine-tuned deep learning model β no lyrics, no metadata, just the raw audio.
The model is a fine-tuned Audio Spectrogram Transformer (AST) pre-trained by MIT on AudioSet. Because mood is inherently subjective, it targets broad emotional character rather than precise genre.
Links: Model card Β· Project on GitHub
How this demo works
For each upload, the app:
- Skips the first and last 30 seconds of the track (to avoid intros and outros).
- Extracts 3 evenly-spaced clips, 10 seconds each, from the remaining audio.
- Resamples to 16 kHz mono and applies EBU R128 loudness normalization (β20 LUFS), matching the training pipeline.
- Classifies each clip independently, then combines the confidence scores (late fusion) into one final prediction.
Training used 6 segments per song; the demo uses 3 for a faster response while keeping the same sampling logic.
Training dataset
The model was trained on a custom dataset built from scratch β a hand-curated catalog matched against a personal music library. Each song was manually assigned to one mood category.
| Total songs | 250 |
| Mood categories | 3 |
| Segments per song (training) | 6 |
| Segment length | 10 seconds |
| Guard buffer | 30 s skipped at each end of every track |
| Total training segments | up to 1,500 (250 songs Γ 6 segments) |
| Audio preprocessing | 16 kHz mono Β· EBU R128 loudness norm (β20 LUFS) |
| Train / eval / test split | ~70% / 15% / 15% (group-aware β all segments from the same song stay in the same split) |
Songs per category
| Category | Songs in catalog |
|---|---|
π§ calm_melancholic |
84 |
π moderate_neutral |
74 |
β‘ energetic_upbeat |
90 |
| Total | 250 |
Mood classes
| Label | Description |
|---|---|
π§ calm_melancholic |
Slow, introspective, melancholic |
π moderate_neutral |
Balanced, mid-energy, neutral feel |
β‘ energetic_upbeat |
Fast, high-energy, upbeat |