Skip to content

About

Educational environmental sound classification project using the ESC-50 dataset.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Environmental Sound Classification (ESC-50)

Project Overview

This project is an educational implementation of an Environmental Sound Classification system using the ESC-50 dataset. The main goal of the project is to build an end-to-end audio classification pipeline, starting from raw audio files and ending with model inference on an unseen audio file.

The project covers the following stages:

  • Dataset inspection and analysis
  • Audio preprocessing and data splitting
  • Audio feature extraction
  • Feature scaling
  • Spectrogram generation
  • Training and evaluation of multiple machine learning models
  • CNN-based audio classification
  • Model comparison
  • Final model inference

Dataset

The project uses the ESC-50 dataset, a dataset containing environmental audio recordings organized into 50 classes.

The dataset contains:

  • 50 environmental sound classes
  • 2,000 audio recordings
  • 40 recordings per class
  • 5-second audio clips
  • 44.1 kHz sample rate The dataset is divided into training, validation, and test sets for model development and evaluation.

Project Pipeline

The overall pipeline of the project is: Raw Audio ↓ Dataset Inspection ↓ Audio Preprocessing ↓ Train / Validation / Test Split ↓ Feature Extraction ↓ Feature Scaling ↓ Machine Learning Models ↓ Spectrogram Generation ↓ CNN Model ↓ Model Evaluation ↓ Model Comparison ↓ Inference

Audio Feature Extraction

For the traditional machine learning models, several audio features are extracted from each audio file.

The extracted features include:

  • RMS Energy
  • Zero Crossing Rate (ZCR)
  • MFCC
  • Spectral Centroid
  • Spectral Bandwidth
  • Spectral Rolloff
  • Spectral Contrast
  • MFCC Delta
  • MFCC Delta-Delta

Statistical representations such as mean, standard deviation, minimum, maximum, and selected percentiles are calculated over the time dimension. The final feature representation contains 249 features per audio sample.

Spectrogram Representation

A separate representation based on Mel spectrograms is used for the CNN model.

The generated spectrogram representation has the shape: 128 × 126 × 1 These spectrograms are normalized using statistics calculated from the training set before being provided to the CNN.

Models

Several classification models were implemented and evaluated.

Traditional Machine Learning

  • Logistic Regression
  • Support Vector Machine (SVM)
  • Random Forest
  • K-Nearest Neighbors (KNN)

Deep Learning

  • Convolutional Neural Network (CNN)

The traditional machine learning models use the extracted and scaled feature vectors, while the CNN operates on spectrogram representations.

Model Comparison

The models were evaluated on the test set using classification accuracy.

Model Test Accuracy
Logistic Regression 60.75%
Random Forest 60.25%
CNN 58.00%
SVM 54.25%
KNN 44.75%

Based on the test accuracy, Logistic Regression achieved the best performance among the evaluated models with an accuracy of 60.75%. Random Forest performed very closely with 60.25%, while the CNN achieved 58.00%.

Best Model

The best-performing model in the current implementation is Logistic Regression. Test Accuracy: 60.75%

Inference

The project includes an inference pipeline that can load a trained model and scaler, extract features from a new audio file, apply the same feature scaling used during training, and generate a predicted environmental sound class.

The inference pipeline performs the following steps:

  1. Load the trained Logistic Regression model.
  2. Load the fitted StandardScaler.
  3. Load the input audio file.
  4. Extract the same 249-dimensional feature representation used during training.
  5. Scale the extracted features.
  6. Generate the predicted class.
  7. Map the predicted class to the corresponding ESC-50 category.

Example:

Audio file: 1-100032-A-0.wav

Sample rate: 44100
Duration: 5.00 seconds

Feature shape: (249,)
Scaled feature shape: (1, 249)

Predicted class: 0
Prediction: class= 0 -> category= dog

About

Educational environmental sound classification project using the ESC-50 dataset.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages