A Pytorch library for audio data augmentation. Inspired by audiomentations. Useful for deep learning.
Project description
torch-audiomentations
Audio data augmentation in PyTorch. Inspired by audiomentations.
Setup
pip install torch-audiomentations
Usage example
import torch
from torch_audiomentations import Gain
# Initialize augmentation callable
apply_gain_augmentation = Gain(
min_gain_in_db=-15.0,
max_gain_in_db=5.0,
p=0.5,
)
# Note: torch-audiomentations can run on CPU or GPU
torch_device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# Make an example tensor with white noise.
# This tensor represents 8 audio snippets with 2 channels (stereo) and 2 seconds of 16 kHz audio.
audio_samples = torch.rand(size=(8, 2, 32000), dtype=torch.float32, device=torch_device) - 0.5
# Apply gain augmentation. This varies the gain of (some of) the audio snippets in the batch independently.
perturbed_audio_samples = apply_gain_augmentation(audio_samples, sample_rate=16000)
Contribute
Contributors welcome!
Join the Asteroid's slack
to start discussing about torch-audiomentations with us.
Motivation: Speed
We don't want data augmentation to be a bottle neck in model training speed. Here is a comparison of the time it takes to run 1D convolution:
Current state
torch-audiomentations is in a very early development stage, so it's not ready for prime time yet. Meanwhile, star the repo and stay tuned!
Version history
v0.2.0 (2020-10-19)
- Simplify API for using CUDA tensors. The device is now inferred from the input tensor.
- Implement
PeakNormalization - Expose
convolvein the API
v0.1.0 (2020-10-12)
- Initial release with
GainandPolarityInversion
Development
Setup
A GPU-enabled development environment for torch-audiomentations can be created with conda:
conda create --name torch-audiomentations python=3.7.3conda activate torch-audiomentationsconda install pytorch cudatoolkit=10.1 -c pytorchconda env update
Run tests
pytest
Conventions
- Format python code with black
- Use Google-style docstrings
- Use explicit relative imports, not absolute imports
Acknowledgements
The development of torch-audiomentations is kindly backed by Nomono
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 torch-audiomentations-0.2.0.tar.gz.
File metadata
- Download URL: torch-audiomentations-0.2.0.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
909b1bae2633555f302e2d5bc5c0a4812adcad0c0c8d848ccda57c47fbb6035b
|
|
| MD5 |
f5efd8572b25eed49ae029237c43000e
|
|
| BLAKE2b-256 |
ed245be7349c79b27a9357ec6771276f166e6d9d5bd495b08b63bf0006e9aeb4
|
File details
Details for the file torch_audiomentations-0.2.0-py3-none-any.whl.
File metadata
- Download URL: torch_audiomentations-0.2.0-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
161de6f2d9d67d1382eb2d7b982e0ea133a222b82dfa1b6404473b751d10cac5
|
|
| MD5 |
8fa90b38d412dccc846d0f5e307c6ef5
|
|
| BLAKE2b-256 |
7a3d517f2ee981e317e340d357ab8f8995504e3e18e33569417d22917831beb2
|