← All models

audio-classification · audio · WASM · ~90 MB

AST — name the sound in any audio clip

The Audio Spectrogram Transformer turns a sound into a 128-band log-mel spectrogram and reads that spectrogram like an image — the same trick a Vision Transformer plays on photos. Give it a clip and it returns the most likely sounds from 527 AudioSet classes — speech, a dog, a siren, applause, a guitar — entirely on your device.

At a glance

ModelXenova/ast-finetuned-audioset-10-10-0.4593
Task / pipelineaudio-classification
ArchitectureAudio Spectrogram Transformer (ViT over a log-mel spectrogram), fine-tuned on AudioSet
Classes527 AudioSet labels (speech, music, animals, vehicles, alarms, environment…)
Input16 kHz mono audio → 128×~1024 log-mel spectrogram
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; WebGPU used when an adapter exists)
Download~90 MB, cached after first load
LicenseBSD-3-Clause (MIT/ast-finetuned-audioset)
Web APIsWebAssembly, Web Workers, Web Audio, MediaRecorder, Canvas — all Baseline widely available

Run it

Pick a sample, drop an audio file, or record from your mic, then hit Classify. AST returns the sounds it hears, most confident first.

Drop an audio file here, or click to choose

The bundled Speech clip (not the tone or whistle) is a JFK inaugural excerpt (20 January 1961), spoken by John F. Kennedy — public domain, U.S. government work · JFK audio source and attribution record.

See inside

AST doesn't hear a waveform — it looks at a picture of it. Every clip becomes a log-mel spectrogram: time runs left→right, frequency runs bottom→top (low to high), and brightness is energy. The transformer cuts that image into patches and attends over them, exactly like a Vision Transformer over an image. Below is the real spectrogram of your clip, plus the full top-15 the model returned.

← earlier · time · later → · ↓ low frequency · high frequency ↑

Classify a clip to see the spectrogram and raw scores.

Why it matters

Sound is a channel most apps ignore because "understanding audio" used to mean a cloud API and an upload. AST makes it a local function call — private, offline, free per call — so the microphone becomes a sensor your page can actually reason about.

Use cases

Basics

Classify a sample sound and read the top AudioSet labels — feel what the model does.

Practical

A live sound-event monitor / accessibility alerter that watches the mic for a chosen sound.

Wild

"What's that sound?" — hold something up to the mic and let AST guess in real time.

Multi-model

AST routes audio: speech → Whisper transcribes it; everything else gets tagged.

How the API works

Classification is one call with Transformers.js. Feed a 16 kHz mono Float32Array:

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

const classify = await pipeline(
  "audio-classification",
  "Xenova/ast-finetuned-audioset-10-10-0.4593",
  { dtype: "q8" },              // downloads + caches ~90 MB once
);

const output = await classify(audio, { top_k: 5 });
// audio = Float32Array @ 16 kHz mono (decode with the Web Audio API)
// → [{ label: "Speech", score: 0.71 }, { label: "Music", score: 0.06 }, … ]

This page decodes files / mic recordings to 16 kHz mono with an OfflineAudioContext, runs the pipeline inside a Web Worker so the UI never janks, and computes the log-mel spectrogram you see — the same representation AST classifies.

References