Audio classification

Audio Classification

Classifying audio clips into categories such as environmental sounds, music, animals, and acoustic scenes, and detecting events over time.

Educational content in the form of a scientific draft that needs expert review before being adopted as an academic reference. No experimental result that was not actually run is shown here.

Overview

Build an understanding of the classification pipeline from features to model, evaluate it with appropriate metrics, and recognize the effect of class imbalance and data leakage.

Learning Objectives

  • Convert a clip into features suitable for classification
  • Distinguish between clip-level classification and event detection
  • Read a confusion matrix and analyze class errors
  • Compute precision, recall, F1, and mAP
  • Avoid data leakage between the training and test sets

Scientific and Ethical Notes

  • Accuracy alone is misleading with class imbalance; reporting per-class F1 and the confusion matrix is recommended.
  • Leakage of segments cut from the same recording between training and testing inflates the results.
  • The platform's local classifier is educational and relies on the user's clips; it does not represent a model trained on broad data.
  • Generalization of models across different environments and recording devices is not guaranteed.

Topics

Audio classification Audio Classification

Classification assigns one or more labels to an audio clip. The pipeline consists of segmentation, feature extraction such as a mel spectrogram or MFCC, and then a traditional classifier (SVM, kNN) or a deep network (CNN, transformer). Tasks distinguish between a single label and multiple labels for the same clip. The class scheme and the data splitting method are defined from the start to avoid leakage.

Environmental Sound Recognition Environmental Sound Recognition

It recognizes sounds such as rain, sirens, and car horns. These are characterized by large variety within a single class and by overlapping sounds in realistic recordings. Standard datasets such as ESC-50 and UrbanSound8K are used, respecting the predefined evaluation folds to avoid leakage of similar clips. Error analysis is reviewed to find which acoustically similar classes get confused with each other.

Music Classification Music Classification

It includes classification of musical genre, instrument, mood, and rhythm. Features rely on the spectrum, harmonics, and rhythm. Genre boundaries are ambiguous and subjective, which makes ground-truth labeling contentious, and copyright in music data requires choosing licensed datasets. The labeling method and the source are always stated when presenting any classification result.

Animal Sound Recognition Animal Sound Recognition

It serves biodiversity monitoring and environmental surveillance, such as distinguishing bird calls. The task faces high background noise, rare classes, and little labeled data, so audio augmentation and transfer learning are used. Generalization across different recording sites is a persistent challenge. It helps to tune the range of frequencies that matter for the target species before extracting features.

Acoustic Scene Classification Acoustic Scene Classification

It identifies the overall environment of a recording, such as a cafe, a station, or a street, rather than the individual events within it. It relies on overall spectral characteristics and their temporal distribution. Performance is affected by differences in recording devices, so models are tested on devices not seen during training. Results are reported for each recording device separately to reveal the generalization gap.

Sound event detection Sound Event Detection

It does not merely label the clip, but determines the start time, end time, and class of each event, with the possibility of overlapping events. CRNN networks or transformers with per-frame outputs are used, followed by post-processing such as smoothing. It is evaluated with segment-based or event-based metrics, and results are affected by the temporal tolerance (collar). The balance between precision and recall is considered according to the cost of a false alarm in the application.

Experiments

Model-Based Audio Classification

Audio Classification (model)

An interface for classifying audio with a real model through a hosted inference endpoint configured by the administrators. Without a configured endpoint, the tool shows…

Requires an External Model

Local User Classifier

Local Sound Classifier

Train a real classifier on your own recordings: you add samples for classes you define, statistical MFCCs are extracted for each sample, and kNN is applied with Leave-On…

Runs in the Browser

MFCC Explorer

MFCC Explorer

Visualizes all the MFCC extraction steps: frames, windowing, FFT, Mel filterbank, logarithm, DCT, and then the coefficients.

Runs in the Browser

Audio Spectrum Explorer

Spectrogram Explorer

Computes a real STFT with control over window size, hop length, and window type (Hann/Hamming), and shows the Spectrogram and Mel Spectrogram side by side.

Runs in the Browser

Model Comparison

Model Benchmark

A table in which you enter the results of your actual experiments (WER, CER, Accuracy, F1, Latency, model size, and memory) for different models and compare them. They a…

Runs in the Browser

Sound Event Detection

Sound Event Detection

Requires a temporal classifier (such as CRNN) and time-labeled data; differs from classifying an entire clip.

Requires an External Model

Classification Model Comparison

Classification Models Comparison

Compare YAMNet, PANNs, and AST using Accuracy/F1/mAP on a licensed test set; requires running the models.

Requires an External Model

Algorithms

Mel-Frequency Cepstral Coefficients

Mel-Frequency Cepstral Coefficients

Compact audio features extracted from the log energies of mel filters by applying the discrete cosine transform (DCT) and keeping the first few coefficients (often 13).

IntermediateSignal Processing

Mel Spectrogram

Mel Spectrogram

A spectrogram in which frequency bins are grouped by triangular filters spaced on the perceptual mel scale. It reduces dimensionality and emphasizes detail at low freque…

IntermediateSignal Processing

k-Nearest Neighbors

k-Nearest Neighbors

An example-based classifier: a new input is classified by a vote among the k training examples closest to it under a distance measure, with no actual training phase.

BeginnerMachine Learning

Support Vector Machine

Support Vector Machine

A classifier that searches for a separating hyperplane with the largest margin between two classes. It can be extended to nonlinear cases with kernels and to multiple cl…

IntermediateMachine Learning

Random Forest

Random Forest

An ensemble of decision trees, each trained on a bootstrap sample of the data and with a random subset of features at each split, whose predictions are then aggregated b…

IntermediateMachine Learning

XGBoost (Gradient Boosting)

Gradient Boosting / XGBoost

A boosting method that builds sequential decision trees, where each tree corrects the errors of the sum of the previous trees using a second-order Taylor approximation o…

AdvancedMachine Learning

Convolutional Neural Network

Convolutional Neural Network

A neural network that uses convolutional filters with shared weights that slide over the input to extract local patterns. In audio, it is often applied to the spectrogra…

IntermediateDeep Learning

Convolutional Recurrent Neural Network

Convolutional Recurrent Neural Network

A hybrid architecture that starts with convolutional layers to extract local features from the spectrogram, then recurrent layers to model the temporal sequence, and end…

IntermediateDeep Learning

YAMNet

YAMNet

A lightweight audio event classifier based on depthwise-separable convolutions, trained on the AudioSet ontology classes, with a multi-label output over short audio wind…

IntermediateAcoustic Models

PANNs

PANNs

A family of convolutional networks pre-trained on AudioSet for audio pattern recognition, used directly or fine-tuned for audio classification and detection tasks.

IntermediateAcoustic Models

Audio Spectrogram Transformer

Audio Spectrogram Transformer

An audio classifier without convolution that splits the spectrogram into patches, treats them as tokens in a vision transformer (ViT), and then outputs a classification…

AdvancedAcoustic Models

CLAP

CLAP

A contrastive model trained on audio-text pairs to place both in a shared embedding space, enabling zero-shot classification and audio retrieval with a text description.

AdvancedAcoustic Models

Lessons

Datasets

ESC-50

ESC-50

2000 short environmental clips in 50 categories for environmental sound classification.

Non-Commercial

UrbanSound8K

UrbanSound8K

Urban sound clips labeled with ten categories for urban sound classification.

Unverified

AudioSet

AudioSet

An ontology and a collection of YouTube clips labeled with audio events; the clips themselves are not included, and the license covers the labels.

Open

Speech Commands

Speech Commands

Short clips of English command words for keyword spotting.

Open

Models

YAMNet

YAMNet

Google sound classifier trained on the AudioSet ontology (details on the official page).

Educational Reference Only

PANNs

PANNs

CNNs pre-trained on AudioSet for recognizing audio patterns.

Educational Reference Only

CLAP

CLAP

Contrastive training on audio and text-caption pairs for a joint representation (zero-shot).

Educational Reference Only

Wav2Vec 2.0

Wav2Vec 2.0

Self-supervised learning: a CNN encoder then a Transformer with a contrastive objective over discrete units.

Educational Reference Only

Evaluation Metrics

AccuracyThe proportion of correctly classified clips; misleading when classes are imbalanced.
PrecisionFor a class: the proportion of predictions of it that were correct.
RecallFor a class: the proportion of actual clips of the class that were detected.
F1-scoreThe harmonic mean of precision and recall for each class, aggregated by macro or weighted average.
Confusion MatrixA table that matches the true class against the predicted one and reveals which classes are confused with each other.
mAPMean average precision (AP) across classes, where AP is the area under the precision-recall curve for each class.

References

  1. Kong et al.. PANNs: Large-Scale Pretrained Audio Neural Networks for Audio Pattern Recognition. arXiv (2019). DOI
  2. Gong et al.. AST: Audio Spectrogram Transformer. arXiv (2021). DOI
  3. Google. YAMNet (Google, Kaggle Models). Kaggle Models. Source
  4. Elizalde et al.. CLAP: Learning Audio Concepts From Natural Language Supervision. arXiv (2022). DOI
  5. Gemmeke et al.. Audio Set: An ontology and human-labeled dataset for audio events (2017). Source
  6. Warden et al.. Speech Commands: A Dataset for Limited-Vocabulary Speech Recognition (2018). Source

Audio processing in the experiments takes place inside your browser. Audio, texts, and conversations are not saved on the server. Privacy Policy