A Python library for audio data augmentation. Inspired by albumentations. Useful for machine learning.
Project description
Audiomentations
A Python library for audio data augmentation. Inspired by albumentations. Useful for machine learning.
Setup
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)
Go to audiomentations/augmentations/transforms.py to see which transforms you can apply.
Version history
v0.11.0 (2020-08-27)
- Implement
GainandPolarityInversion. Thanks to Spijkervet for the inspiration.
v0.10.1 (2020-07-27)
- Improve the performance of
AddBackgroundNoiseandAddShortNoisesby optimizing the implementation ofcalculate_rms. - Improve compatibility of output files written by the demo script. Thanks to xwJohn.
- Fix division by zero bug in
Normalize. Thanks to ZFTurbo.
v0.10.0 (2020-05-05)
- Breaking change:
AddImpulseResponse,AddBackgroundNoiseandAddShortNoisesnow include subfolders when searching for files. This is useful when your sound files are organized in subfolders. AddImpulseResponse,AddBackgroundNoiseandAddShortNoisesnow support aiff files in addition to flac, mp3, ogg and wav- Fix filter instability bug in
FrequencyMask. Thanks to kvilouras.
v0.9.0 (2020-02-20)
- Disregard non-audio files when looking for impulse response files
- Remember randomized/chosen effect parameters. This allows for freezing the parameters and applying the same effect to multiple sounds. Use transform.freeze_parameters() and transform.unfreeze_parameters() for this.
- Fix a bug in
ClippingDistortionwhere the min_percentile_threshold was not respected as expected. - Implement transform.serialize_parameters(). Useful for when you want to store metadata on how a sound was perturbed.
- Switch to a faster convolve implementation. This makes
AddImpulseResponsesignificantly faster. - Add a rollover parameter to
Shift. This allows for introducing silence instead of a wrapped part of the sound. - Expand supported range of librosa versions
- Add support for flac in
AddImpulseResponse - Implement
AddBackgroundNoisetransform. Useful for when you want to add background noise to all of your sound. You need to give it a folder of background noises to choose from. - Implement
AddShortNoises. Useful for when you want to add (bursts of) short noise sounds to your input audio. - Improve handling of empty input
v0.8.0 (2020-01-28)
- Add shuffle parameter in
Composer - Add
Resampletransformation - Add
ClippingDistortiontransformation - Add
SmoothFadeTimeMaskas alternative toTimeMask
Thanks to askskro
v0.7.0 (2020-01-14)
Add new transforms:
AddImpulseResponseFrequencyMaskTimeMaskAddGaussianSNR
Thanks to karpnv
v0.6.0 (2019-05-27)
- Implement peak normalization
v0.5.0 (2019-02-23)
- Implement
Shifttransform - Ensure p is within bounds
v0.4.0 (2019-02-19)
- Implement
PitchShifttransform - Fix output dtype of
AddGaussianNoise
v0.3.0 (2019-02-19)
Implement leave_length_unchanged in TimeStretch
v0.2.0 (2019-02-18)
- Add
TimeStretchtransform - Parametrize
AddGaussianNoise
v0.1.0 (2019-02-15)
Initial release. Includes only one transform: AddGaussianNoise
Development
Install the dependencies specified in requirements.txt
Code style
Format the code with black
Run tests and measure code coverage
pytest
Generate demo sounds for empirical evaluation
python -m demo.demo
Alternatives
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file audiomentations-0.11.0.tar.gz.
File metadata
- Download URL: audiomentations-0.11.0.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.7.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d96e449aa931eea9bf0daf9e057c2b6bef8c441bfc81f683e277474ab52254e6
|
|
| MD5 |
344446cdf5962e33eee630cbca263e4e
|
|
| BLAKE2b-256 |
8ee08e83697f1c43dd0522777f8e3616cd01762830bd23c69f959cdee79e7e95
|
File details
Details for the file audiomentations-0.11.0-py3-none-any.whl.
File metadata
- Download URL: audiomentations-0.11.0-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.7.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2fa7fa8d55f1fdfb9da6ebee19d30bdeda1c3b4ab34e4247e41eb0a5046cbcf7
|
|
| MD5 |
dee70e0e3b28234cfe4b55c9c6f37bc2
|
|
| BLAKE2b-256 |
250d0be48b33c461110fe17c7a4480ab0c65a5201e8891166c0d4021286e4929
|