← All models

audio-classification · audio · WASM · ~24 MB

Music genre classification — what genre is this?

Drop in an audio file — or record a few seconds — and the model listens and names its musical genre across ten classes (blues, classical, country, disco, hip-hop, jazz, metal, pop, reggae, rock), showing the full confidence distribution. It hears timbre and rhythm, not metadata. Everything runs on your device — the audio never leaves the tab.

At a glance

Modelonnx-community/Musical-genres-Classification-Hubert-V1-ONNX (ONNX build of SeyedAli/Musical-genres-Classification-Hubert-V1)
Task / pipelineaudio-classification
Genres10 (GTZAN): blues, classical, country, disco, hip-hop, jazz, metal, pop, reggae, rock
ArchitectureDistilHuBERT (base ntu-spml/distilhubert) fine-tuned for genre
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Input16 kHz mono audio (decoded/resampled in the browser)
Download~24 MB, cached after first load
LicenseApache-2.0 (base model → DistilHuBERT, both Apache-2.0)

Run it

Drop or choose an audio file, record a clip, or try a built-in sample. The clip is decoded to 16 kHz mono in the browser and classified locally.

Drag & drop an audio file here, or:

Use-case ladder

Why it matters

Genre is the classic music-understanding task — the model learns what disco or metal sounds like from the raw waveform, no tags or filenames. Doing it in the browser means a library of audio can be organised or filtered without uploading a single track.

It's a best-effort classifier trained on the small GTZAN set: it's strongest on clear, full productions and can be swayed by a track's dominant texture — a chord progression reads as jazz, a drum-heavy loop as hip-hop — and non-music audio (speech) just gets the nearest-looking genre. The built-in samples are short procedural clips (a chord progression, a drum beat); upload a real song for the full ten-genre range.

How the API works

Genre classification is one pipeline call on a 16 kHz mono waveform:

import { pipeline } from "@huggingface/transformers";

const classify = await pipeline("audio-classification",
  "onnx-community/Musical-genres-Classification-Hubert-V1-ONNX");
const out = await classify(audioFloat32, { top_k: 10 });
// → [{ label: "classical", score: 0.97 }, { label: "jazz", score: 0.01 }, … ]

The browser decodes/resamples the file to 16 kHz mono; the DistilHuBERT model turns the waveform into features and scores the ten genres. It all runs in a Web Worker so the UI stays responsive.

References