torch-audiomentations
A Pytorch library for audio data augmentation. Inspired by audiomentations. Useful for deep learning.
What it is and what it does
torch-audiomentations is a PyTorch library for augmenting audio data during training. It provides a collection of transforms—gain adjustment, filtering, pitch shifting, noise addition, and more—that extend nn.Module and can be composed into a pipeline. Most transforms are differentiable and support batches of multichannel audio, running efficiently on both CPU and GPU. The library is designed to avoid becoming a bottleneck in model training.
The transforms support three application modes (per_batch, per_example, per_channel) and probability-based triggering, giving fine control over how augmentation is applied to different samples in a batch. It is inspired by the audiomentations library but optimized for PyTorch workflows. The package is in early development (alpha status), so APIs may change, and some features like target data processing and multi-GPU support remain experimental or unsupported.
Use it for:
- Augment audio batches during training of speech recognition or audio classification models to improve robustness.
- Apply differentiable transforms as part of an end-to-end learnable audio processing pipeline.
- Add background noise, pitch variation, or filtering to synthetic training data for audio ML tasks.
- Accelerate augmentation on GPU to reduce training bottlenecks when processing large audio datasets.
- Compose multiple transforms (gain, filtering, polarity inversion) into a single augmentation routine.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides PyTorch-native audio data augmentation transforms that run on CPU or GPU, designed to integrate directly into neural network models as differentiable modules.
Yes, if you are training audio models with PyTorch and need GPU-accelerated augmentation. The library is mature enough for production use (1164 GitHub stars, top 5000 PyPI packages), has no known vulnerabilities, and offers a permissive license. However, be aware that maintenance is aging (last release 576 days ago), multiprocessing and multi-GPU setups have known limitations, and some transforms have edge cases (e.g., PitchShift at low sample rates). For single-GPU training on CPU or GPU, it is a solid choice.
Install
torch-audiomentations on PyPI
pip
pip install torch-audiomentationsuv
uv add torch-audiomentationspoetry
poetry add torch-audiomentationsInstalling torch-audiomentations
Before you install
Low friction install with a pure Python wheel. Maintenance status is aging—last release was 576 days ago—but the repository remains active with recent commits and no archived status. The four runtime dependencies (torch, torchaudio, julius, torch-pitch-shift) are standard in audio ML workflows.
License in practice
MIT license is permissive; you can use this package freely in commercial and private projects without restriction or attribution requirement.
Quickstart
pip install torch-audiomentations
import torch
from torch_audiomentations import Compose, Gain, PolarityInversion
apply_augmentation = Compose([
Gain(min_gain_in_db=-15.0, max_gain_in_db=5.0, p=0.5),
PolarityInversion(p=0.5)
])
audio_samples = torch.rand(8, 2, 32000, dtype=torch.float32) - 0.5
perturbed = apply_augmentation(audio_samples, sample_rate=16000)
Requires torch and torchaudio installed; multiprocessing contexts may cause memory leaks and multi-GPU/DDP is not officially supported.
Verify before relying
- Whether PitchShift limitations (small shifts at low sample rates) affect your intended use case.
- Performance characteristics of specific transforms on your hardware (GPU speedup varies by transform).
- Stability of target data processing, still marked experimental in the documentation.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 4 — julius, torch, torchaudio, torch-pitch-shift |
| Maintenance | aging — 576 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,125,883/month — #3,273 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: torch_audiomentations-0.12.0-py3-none-any.whl
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
audiomentationsAudiomentations applies randomized audio…
permissive · top 15,000 on PyPI
asteroid-filterbanksProvides PyTorch-based filterbank…
permissive · top 5,000 on PyPI
ttachWraps PyTorch models to apply test-time…
permissive · top 15,000 on PyPI
batchgeneratorsv2Reimplemented data augmentation transforms for…
permissive · top 15,000 on PyPI
descript-audiotoolsProvides object-oriented audio signal handling…
permissive · top 15,000 on PyPI
torchPyTorch provides GPU-accelerated tensor…
permissive · top 1,000 on PyPI
nlpaugnlpaug generates synthetic augmented text and…
permissive · top 15,000 on PyPI
batchgeneratorsbatchgenerators provides data augmentation…
permissive · top 15,000 on PyPI
torchlibrosaProvides PyTorch implementations of librosa…
permissive · top 15,000 on PyPI
pedalboardpedalboard reads, writes, and processes audio…
copyleft · top 5,000 on PyPI