jhuiac / audiomentations

A Python library for audio data augmentation. Inspired by albumentations. Useful for machine learning.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Audiomentations

Build status

A Python library for audio data augmentation. Inspired by albumentations. Useful for machine learning.

Setup

PyPI version Number of downloads from PyPI per month

pip install audiomentations

Usage example

from audiomentations import Compose, AddGaussianNoise, TimeStretch, PitchShift, Shift
import numpy as np

SAMPLE_RATE = 16000

augmenter = Compose([
    AddGaussianNoise(min_amplitude=0.001, max_amplitude=0.015, p=0.5),
    TimeStretch(min_rate=0.8, max_rate=1.25, p=0.5),
    PitchShift(min_semitones=-4, max_semitones=4, p=0.5),
    Shift(min_fraction=-0.5, max_fraction=0.5, p=0.5),
])

samples = np.zeros((20,), dtype=np.float32)
samples = augmenter(samples=samples, sample_rate=SAMPLE_RATE)

Development

Code style

Format the code with black

Run tests

nosetests

Generate demo sounds for empirical evaluation

python -m demo.demo

About

A Python library for audio data augmentation. Inspired by albumentations. Useful for machine learning.

License:MIT License


Languages

Language:Python 100.0%