torchaudio

GPU-accelerated audio processing library built on PyTorch, with differentiable transforms, Kaldi-compatible features, and pretrained speech models.

Library
PyPI
v2.11.0
2,948 stars
BSD-2-Clause

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
76 /100 Good
Development Activity 68
Maintenance 48
Community 88
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
79 /100 Good
Architecture 78
Code Quality 80
Innovation 68
Learning Curve 90

torchaudio extends PyTorch into the audio domain, giving machine learning practitioners GPU-accelerated tensor operations for transforming and modeling audio and speech data. Rather than acting as a general signal-processing library, it is scoped specifically to the operations that matter for training audio ML models: differentiable transforms through PyTorch’s autograd system, consistent tensor and dimension naming, and tight integration with the rest of the PyTorch ecosystem.

As of the 2.9 release the library has moved into a maintenance phase, narrowing its scope: audio decoding and encoding are now delegated to the sibling torchcodec project, while torchaudio itself focuses on spectrogram and filter transforms, Kaldi-compatible compliance functions, forced alignment, and reference model architectures (Wav2Vec2, Conformer, Tacotron2, HDemucs, and more) alongside their pretrained pipelines.

What You Get

  • Differentiable audio transforms (Spectrogram, MelSpectrogram, MFCC, Resample, and more) built as PyTorch nn.Module classes with autograd support
  • A Kaldi-compatible compliance layer for spectrogram, fbank, and mfcc feature extraction
  • Pretrained model architectures and pipelines for speech recognition, forced alignment, and source separation (Wav2Vec2, Conformer, HDemucs, Tacotron2)
  • Dataset loaders for two dozen standard speech and audio corpora (LibriSpeech, CommonVoice, VCTK, MUSDB-HQ, and others)
  • Low-level functional building blocks for custom DSP pipelines, from mu-law encoding to multi-channel beamforming

Common Use Cases

  • Training speech recognition or TTS models on GPU with differentiable spectrogram transforms
  • Extracting Kaldi-compatible MFCC/fbank features for compatibility with existing ASR pipelines
  • Building audio source-separation systems using the bundled HDemucs model
  • Benchmarking against standard speech datasets (LibriSpeech, VoxCeleb, TEDLIUM) via built-in loaders

Under The Hood

Architecture torchaudio is organized as a layered PyTorch extension: at the base sit native C++/CUDA kernels (RNNT loss, CUCTC, forced alignment) compiled into a native extension loaded through the package’s extension-init module; above that sits a functional layer providing stateless tensor operations, then transforms wrapping those functionals as nn.Module classes for use inside a training graph, and finally model and pipeline modules compose transforms and functionals into full architectures (Wav2Vec2, HDemucs, Conformer) paired with pretrained-weight pipeline wrappers, with dataset loaders sitting alongside as a parallel data layer. This is a conventional layered library architecture with clear separation of concerns; the main coupling risk is that models and pipelines depend on exact functional signatures, so a change to a core transform’s tensor-shape convention would ripple through every downstream pipeline.

Tech Stack Built for Python 3.8+ with setuptools, depending at runtime on torch (required) and optionally torchcodec for audio decode/encode now that I/O has been delegated out of the core package. Native code is C++/CUDA, compiled per-platform through dedicated GitHub Actions wheel-build workflows for Linux, Windows, aarch64, and macOS; linting runs through flake8 and black/usort (configured in pyproject.toml) enforced via pre-commit hooks, with Sphinx-generated docs published to pytorch.org/audio.

Code Quality Tests live under a mirrored unittest tree covering transforms, functional, models, datasets, compliance, and utils, plus separate integration and smoke-test suites built on shared test-utility helpers, with autograd-consistency tests exercising CPU/CUDA/quantized code paths in parallel. CI runs dedicated unittest workflows for Linux, Windows, and macOS (CPU and GPU variants) alongside a bandit security scan and a standalone lint workflow. Type hints are present throughout the functional API though not exhaustively enforced by a strict mypy configuration, and no obvious swallowed-exception patterns turned up in the sampled source.

API Design The public API mirrors idiomatic PyTorch conventions closely: transforms are nn.Module subclasses that compose with Sequential and DataParallel, and a stateless functional equivalent exists for every transform. The Kaldi-compliance namespace is a deliberate ergonomic bridge for teams migrating existing Kaldi feature-extraction pipelines without a mismatch in output values — a well-executed compatibility layer rather than a novel algorithm. Documentation maps closely to the API surface, and the README states an explicit versioning contract decoupling TorchAudio releases from torch upgrades. Its distinguishing value is being a tightly-integrated adapter/toolkit into the PyTorch ecosystem rather than inventing new signal-processing methods.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers