nlpaug helps you synthesize training data for NLP and audio ML without hand-labeling every variant. You compose augmenters or flows in a few lines of Python.
Overview
nlpaug is a Python library for augmenting natural language, audio waveforms, and spectrogram inputs used in machine learning pipelines. An Augmenter applies a single transform; a Flow chains or selectively runs multiple augmenters in sequence.
Text augmenters cover character-level noise such as keyboard or OCR substitutions, word-level synonym or antonym swaps, spelling changes, splits, reserved-word replacement, and model-backed methods including abstractive summarization and Lambada-style generation with filtering.
Audio and spectrogram augmenters adjust loudness, pitch, speed, masking, cropping, noise injection, polarity, normalization, and spec augment time or frequency masks. Optional extras pull in transformers, torch, librosa, and related stacks when you install feature-specific dependency sets.
The project targets Python 3.12 or newer, documents offline default tests, and is meant to plug into common ML frameworks to expand limited labeled datasets for training or robustness experiments.
Key features
- Text character and word augmenters
- Audio pitch, speed, and noise transforms
- Spectrogram time and frequency masking
- Sequential and stochastic Flow pipelines
- Transformer-backed text augmentation
- Optional dependency extras
- Change-log and history helpers
- Custom augmenter extension points
Use cases
- Expanding small NLP training sets
- Adversarial or noisy text robustness
- Speech and audio classifier augmentation
- SpecAugment-style model regularization
- Rapid experimentation without manual relabeling