Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Speechbrain Speechbrain Prepare ESC50

From Leeroopedia


Knowledge Sources
Domains Environmental Sound Classification, Data Preparation
Last Updated 2026-02-09 00:00 GMT

Overview

Concrete tool for preparing the ESC-50 dataset for environmental sound classification provided by the SpeechBrain library.

Description

This script prepares JSON manifest files from the ESC-50 (Environmental Sound Classification) dataset, a collection of 2000 environmental audio recordings across 50 classes organized into 5 folds. It can automatically download the dataset from GitHub if not found locally. The script reads the ESC-50 metadata CSV, assigns audio files to train/valid/test splits based on configurable fold numbers (default: folds 1-3 for train, fold 4 for validation, fold 5 for test), and generates SpeechBrain-compatible JSON manifest files with audio paths and class labels.

Usage

Use this when preparing the ESC-50 dataset for environmental sound classification training with SpeechBrain recipes.

Code Reference

Source Location

Signature

def prepare_esc50(
    data_folder,
    audio_data_folder,
    save_json_train,
    save_json_valid,
    save_json_test,
    train_fold_nums=[1, 2, 3],
    valid_fold_nums=[4],
    test_fold_nums=[5],
    skip_manifest_creation=False,
):

Import

from esc50_prepare import prepare_esc50

I/O Contract

Inputs

Name Type Required Description
data_folder str Yes Path to the folder where the ESC-50 dataset (including metadata) is stored
audio_data_folder str Yes Path to the folder where the ESC-50 audio files are stored
save_json_train str Yes Path where the train data specification JSON file will be saved
save_json_valid str Yes Path where the validation data specification JSON file will be saved
save_json_test str Yes Path where the test data specification JSON file will be saved
train_fold_nums list[int] No Fold numbers to use for training (default: [1, 2, 3])
valid_fold_nums list[int] No Fold numbers to use for validation (default: [4])
test_fold_nums list[int] No Fold numbers to use for testing (default: [5])
skip_manifest_creation bool No If True, skip manifest creation (default: False)

Outputs

Name Type Description
save_json_train JSON File Train split manifest with audio paths, class labels, and fold information
save_json_valid JSON File Validation split manifest
save_json_test JSON File Test split manifest

Usage Examples

from esc50_prepare import prepare_esc50

prepare_esc50(
    data_folder="/datasets/ESC-50",
    audio_data_folder="/datasets/ESC-50/audio",
    save_json_train="/output/train.json",
    save_json_valid="/output/valid.json",
    save_json_test="/output/test.json",
    train_fold_nums=[1, 2, 3],
    valid_fold_nums=[4],
    test_fold_nums=[5],
)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment