Skip to main content

Python augmentation toolkit for Automatic Music Transcription datasets

Project description

AMT-AugPy

Python Data Augmentation Toolkit for Automatic Music Transcription (AMT)

Python License: MIT Librosa NumPy SoundFile

A comprehensive Python toolkit for augmenting Automatic Music Transcription (AMT) datasets through various audio transformations while maintaining synchronization between audio and MIDI files. The dataset follows the same format as MAESTRO v3.0.0, which is commonly used for Automatic Music Transcription (AMT) tasks.

The toolkit expects a folder containing paired audio and MIDI files with matching names. The audio file and MIDI file must be ground truth data, as this toolkit is only for augmenting existing datasets - a common technique in Machine Learning.

Folder/
├── song1.wav        # Audio file
├── song1.mid        # Ground truth annotated midi file

Features

  • Time Stretching: Modify the tempo of audio files while maintaining pitch
  • Pitch Shifting: Transpose audio files up or down while preserving timing
  • Reverb & Filtering: Apply room acoustics and frequency filtering effects
  • Gain & Chorus: Add depth and richness through gain and chorus effects
  • Smart Pause Detection: Identify and manipulate musical pauses based on note timing
  • Audio Standardization: Convert various audio formats to 44.1kHz WAV
  • Parallel Processing: Utilize multi-core processing for faster augmentation
  • Configurable Parameters: Easily customize all augmentation parameters

What's New in 1.0.5

  • Configuration System: Use YAML configuration files to customize all parameters
  • Parallel Processing: Process multiple effects concurrently for faster performance
  • Better Error Handling: Improved error detection and reporting
  • Extended Format Support: Added support for M4A and AIFF audio formats
  • Type Annotations: Full Python type hints for better code quality
  • Expanded Documentation: Improved documentation and examples

Installation

You can install amt-augpy either via pip or by cloning the repository:

Using pip

pip install amt-augpy1.0

From source

git clone https://github.com/LarsMonstad/amt-augpy1.0.git
cd amt-augpy1.0
pip install -e .

For development, install with additional development dependencies:

pip install -e ".[dev]"

Dependencies

  • librosa
  • soundfile
  • numpy
  • pedalboard
  • pretty_midi
  • pyyaml
  • tqdm

Usage

Basic Usage

amt-augpy /path/to/dataset/directory
# Or running directly
python -m amt_augpy.main /path/to/dataset/directory

This will process all compatible audio files in the directory and their corresponding MIDI files. The script automatically selects random parameters within predefined ranges for each augmentation type.

Advanced Usage

# Use a custom configuration file
amt-augpy /path/to/dataset/directory --config my_config.yaml

# Specify an output directory
amt-augpy /path/to/dataset/directory --output-directory /path/to/output

# Generate a default configuration file
amt-augpy --generate-config my_config.yaml

# Disable specific effects
amt-augpy /path/to/dataset/directory --disable-effect timestretch --disable-effect chorus

# Parallel processing with 8 workers
amt-augpy /path/to/dataset/directory --num-workers 8

# Custom train/test/validation split
amt-augpy /path/to/dataset/directory --train-ratio 0.8 --test-ratio 0.1 --validation-ratio 0.1

Help and options

amt-augpy --help

Configuration

All augmentation parameters can be customized using a YAML configuration file. See config.sample.yaml for a complete example with documentation.

Sample Configuration

# Time stretching configuration
time_stretch:
  enabled: true
  variations: 3
  min_factor: 0.6
  max_factor: 1.6

# Pitch shifting configuration
pitch_shift:
  enabled: true
  variations: 3
  min_semitones: -5
  max_semitones: 5

# Processing configuration
processing:
  num_workers: 4
  output_dir: null

File Format Support

Audio

  • Input: WAV, FLAC, MP3, M4A, AIFF
  • Output: WAV (44.1kHz)

Annotations

  • MIDI (.mid)

Output Structure

For each input file pair (audio + MIDI), the toolkit generates multiple augmented versions with the following naming convention:

original_name_effect_parameter_randomsuffix.extension

Example:

piano_timestretch_1.2_abc123.wav
piano_timestretch_1.2_abc123.mid

Dataset Creation & Validation

The dataset follows the same format as MAESTRO v3.0.0. Songs assigned to test or validation splits will have their augmented versions excluded to prevent data leakage.

Creating the Dataset CSV

# Create dataset with default split ratios (70% train, 15% test, 15% validation)
amt-augpy /path/to/directory

# Create dataset with custom split ratios
amt-augpy /path/to/directory --train-ratio 0.8 --test-ratio 0.1 --validation-ratio 0.1

Validating the Dataset Split

Dataset split validation is automatically performed after CSV creation to ensure:

  • Augmented songs are not included in test/validation splits
  • No cross-split contamination occurs
  • Original and augmented songs are properly distributed

CSV Format

The generated CSV follows the MAESTRO format with the following columns:

  • canonical_composer
  • canonical_title
  • split
  • year
  • midi_filename
  • audio_filename
  • duration

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

For development:

  1. Install development dependencies: pip install -e ".[dev]"
  2. Run tests: pytest tests/
  3. Check typing: mypy amt_augpy
  4. Format code: black amt_augpy

License

MIT License - see LICENSE file for details.

Citation

If you use this toolkit in your research, please cite:

@software{amt_augpy,
  author    = {Lars Monstad},
  title     = {amt-augpy: Audio augmentation toolkit for AMT datasets},
  version   = {1.0},
  year      = {2025}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

amt_augpy1_0-1.0.8.tar.gz (29.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

amt_augpy1_0-1.0.8-py3-none-any.whl (27.8 kB view details)

Uploaded Python 3

File details

Details for the file amt_augpy1_0-1.0.8.tar.gz.

File metadata

  • Download URL: amt_augpy1_0-1.0.8.tar.gz
  • Upload date:
  • Size: 29.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.18

File hashes

Hashes for amt_augpy1_0-1.0.8.tar.gz
Algorithm Hash digest
SHA256 92b0ad9e6f887ea614cface670d34492235411689381bf791ee794caae388122
MD5 f1c50e7d4c636f6765bc5684bafb030c
BLAKE2b-256 05ecec46fe4eec85f04530b4dfd0b3fc85775d6c52db208d8515d91abb891f85

See more details on using hashes here.

File details

Details for the file amt_augpy1_0-1.0.8-py3-none-any.whl.

File metadata

  • Download URL: amt_augpy1_0-1.0.8-py3-none-any.whl
  • Upload date:
  • Size: 27.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.18

File hashes

Hashes for amt_augpy1_0-1.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 d985ea268bb8a1f1b30ea6d78e75a36ea180b5185ca1d7e9ac07a9f1f8dcbf0b
MD5 0af695283bc785dc950dc144b6e77e1f
BLAKE2b-256 17f68e11a55d3dadcfbb0e9e61d3dd8e1a3bbe3e2b3aa756459c55e6bbfe3b7a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page