|
1 | | -# Wav2Aug: Toward Universal Time-Domain Speech Augmentation |
| 1 | +# 🎛️ Wav2Aug: Toward Universal Time-Domain Speech Augmentation |
2 | 2 |
|
3 | | -A minimalistic PyTorch-based audio augmentation library for speech and audio processing. The goal of this library is to provide a general purpose speech augmentation policy that can be used on any task and perform well without having to tune augmentation hyperparameters. Just install, and start augmenting. Applies two random augmentations per call. |
| 3 | +A minimalistic PyTorch-based audio augmentation library for speech and audio augmentation. The goal of this library is to provide a general purpose speech augmentation policy that can be used on any task and perform well without having to tune augmentation hyperparameters. Just install, and start augmenting. Applies two random augmentations per call. |
4 | 4 |
|
5 | 5 |  |
6 | 6 |
|
7 | | -## Features |
| 7 | +## ⚙️ Features |
8 | 8 |
|
9 | | -- **Minimal dependencies**: We only rely on PyTorch and torchcodec. |
10 | | -- **9 core augmentations**: amplitude scaling/clipping, noise addition, frequency dropout, polarity inversion, chunk swapping, speed perturbation, time dropout, and babble noise. |
11 | | -- **In-place operations**: All cpu augmentations are done in place. |
| 9 | +* **Minimal dependencies**: we only rely on PyTorch, torchcodec, and torchaudio. |
| 10 | +* **9 core augmentations**: amplitude scaling/clipping, noise addition, frequency dropout, polarity inversion, chunk swapping, speed perturbation, time dropout, and babble noise. |
| 11 | +* **Simplicity**: just install and start augmenting! |
| 12 | +* **Randomness**: All stochastic ops use PyTorch RNGs. Set a single seed and be done, e.g. torch.manual_seed(0); torch.cuda.manual_seed_all(0) |
12 | 13 |
|
13 | | -## Installation |
| 14 | +## 📦 Installation |
14 | 15 |
|
15 | 16 | ### pip |
| 17 | + |
16 | 18 | ```bash |
17 | 19 | pip install wav2aug |
18 | 20 | ``` |
19 | 21 |
|
20 | 22 | ### uv |
| 23 | + |
21 | 24 | ```bash |
22 | 25 | uv add wav2aug |
23 | 26 | ``` |
24 | 27 |
|
25 | | -## Quick Start |
| 28 | +## 🚀 Quick Start |
26 | 29 |
|
27 | 30 | ```python |
28 | 31 | import torch |
29 | | -from wav2aug import Wav2Aug |
| 32 | +from wav2aug.gpu import Wav2Aug |
30 | 33 |
|
31 | | -# Initialize augmenter |
32 | | -aug = Wav2Aug(sample_rate=16000) |
| 34 | +# Initialize the augmenter once |
| 35 | +augmenter = Wav2Aug(sample_rate=16000) |
33 | 36 |
|
34 | | -# Process audio (supports [T] mono or [C, T] multi-channel) |
35 | | -waveform = torch.randn(8000) # 0.5s at 16kHz |
36 | | -augmented = aug(waveform) |
| 37 | +# in the forward pass |
| 38 | +wavs = torch.randn(3, 50000) |
| 39 | +lens = torch.tensor([1]) |
| 40 | + |
| 41 | +aug_wavs, aug_lens = augmenter(wavs, lens) |
37 | 42 | ``` |
38 | 43 |
|
39 | | -## Augmentation Types |
| 44 | +That's it! |
| 45 | + |
| 46 | +## 🧪 Augmentation Types |
40 | 47 |
|
41 | | -- **Amplitude Scaling/Clipping**: Random gain and peak limiting |
42 | | -- **Noise Addition**: Environmental noise with SNR control |
43 | | -- **Frequency Dropout**: Spectral masking with random notch filters |
44 | | -- **Polarity Inversion**: Random phase flip |
45 | | -- **Chunk Swapping**: Temporal segment reordering |
46 | | -- **Speed Perturbation**: Time-scale modification |
47 | | -- **Time Dropout**: Random silence insertion |
48 | | -- **Babble Noise**: Multi-speaker background (auto-enabled with sufficient buffer) |
| 48 | +* 🔊 **Amplitude Scaling/Clipping**: Random gain and peak limiting |
| 49 | +* 🌫️ **Noise Addition**: Environmental noise with SNR control |
| 50 | +* 📶 **Frequency Dropout**: Spectral masking with random notch filters |
| 51 | +* 🔄 **Polarity Inversion**: Random phase flip |
| 52 | +* 🧩 **Chunk Swapping**: Temporal segment reordering |
| 53 | +* ⏱️ **Speed Perturbation**: Time-scale modification |
| 54 | +* 🕳️ **Time Dropout**: Random silence insertion |
| 55 | +* 👥 **Babble Noise**: Multi-speaker background (auto-enabled with sufficient buffer) |
49 | 56 |
|
50 | | -## Development Installation |
| 57 | +## 🛠️ Development Installation |
| 58 | + |
| 59 | +### uv |
51 | 60 |
|
52 | 61 | ```bash |
53 | 62 | git clone https://github.com/gfdb/wav2aug |
54 | 63 | cd wav2aug |
55 | | -uv python pin 3.10 # or greater |
| 64 | + |
| 65 | +# create venv and pin Python |
| 66 | +uv venv |
| 67 | +source .venv/bin/activate |
| 68 | +uv python pin 3.10 # or 3.11/3.12 |
| 69 | + |
| 70 | +# runtime only |
56 | 71 | uv sync |
57 | | -uv sync --extra test # for test deps |
| 72 | + |
| 73 | +# extras |
| 74 | +uv sync --extra dev |
| 75 | +uv sync --extra test |
58 | 76 | ``` |
59 | 77 |
|
60 | | -## Tests |
| 78 | +### pip |
61 | 79 |
|
62 | 80 | ```bash |
63 | | -uv run pytest tests/ |
| 81 | +git clone https://github.com/gfdb/wav2aug |
| 82 | +cd wav2aug |
| 83 | + |
| 84 | +# create venv |
| 85 | +python -m venv .venv |
| 86 | +source .venv/bin/activate |
| 87 | + |
| 88 | +# runtime only |
| 89 | +python -m pip install . |
| 90 | + |
| 91 | +# editable + extras for development |
| 92 | +python -m pip install -e '.[dev,test]' |
64 | 93 | ``` |
| 94 | + |
| 95 | +## ✅ Tests |
| 96 | + |
| 97 | +### uv |
| 98 | + |
| 99 | +```bash |
| 100 | +uv run pytest -q tests/ |
| 101 | +``` |
| 102 | + |
| 103 | +### pip |
| 104 | + |
| 105 | +```bash |
| 106 | +pytest -q tests/ |
| 107 | +``` |
| 108 | + |
| 109 | +## 🤝 Contributing |
| 110 | + |
| 111 | +* Issues and PRs are welcome and encouraged! |
| 112 | + |
| 113 | +* Bug reports: please open an issue with a minimal repro (env, torch/torchaudio/torchcodec versions, code snippet, expected vs. actual, traceback). |
| 114 | + |
| 115 | +* Feature requests: please open an issue with use-case and proposed feature. |
| 116 | + |
| 117 | +* PRs: keep them focused. Add tests when behavior changes. Don't forget to run formatters and tests before submitting! |
0 commit comments