Implementation:Speechbrain Speechbrain Prepare ESC50 Root
| Knowledge Sources | |
|---|---|
| Domains | Audio_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 creates JSON data manifest files for the ESC-50 (Environmental Sound Classification) dataset. It automatically downloads the dataset if not found locally, converts metadata into SpeechBrain-compatible JSON format, and splits data by the predefined 5-fold cross-validation scheme. The ESC-50 dataset contains 2,000 environmental audio recordings across 50 classes.
Usage
Use this when preparing the ESC-50 dataset for environmental sound classification training with SpeechBrain recipes.
Code Reference
Source Location
- Repository: SpeechBrain
- File: recipes/ESC50/esc50_prepare.py
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 recipes.ESC50.esc50_prepare import prepare_esc50
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| data_folder | str | Yes | Path to the folder where the ESC50 dataset (including metadata) is stored |
| audio_data_folder | str | Yes | Path to the folder where the ESC50 audio files are stored |
| save_json_train | str | Yes | Path where the train data specification file will be saved |
| save_json_valid | str | Yes | Path where the validation data specification file will be saved |
| save_json_test | str | Yes | Path where the test data specification file will be saved |
| train_fold_nums | list | No | Pre-defined folds to use for training (default: [1, 2, 3]) |
| valid_fold_nums | list | No | Pre-defined folds to use for validation (default: [4]) |
| test_fold_nums | list | No | Pre-defined folds to use for test (default: [5]) |
| skip_manifest_creation | bool | No | Whether to skip the manifest creation step (default: False) |
Outputs
| Name | Type | Description |
|---|---|---|
| train.json | JSON | Training split manifest with audio paths and labels |
| valid.json | JSON | Validation split manifest with audio paths and labels |
| test.json | JSON | Test split manifest with audio paths and labels |
Usage Examples
from recipes.ESC50.esc50_prepare import prepare_esc50
prepare_esc50(
data_folder="/path/to/ESC-50",
audio_data_folder="/path/to/ESC-50/audio",
save_json_train="train.json",
save_json_valid="valid.json",
save_json_test="test.json",
train_fold_nums=[1, 2, 3],
valid_fold_nums=[4],
test_fold_nums=[5],
)