Skip to main content

AudioTree

PyPI Docs

AudioTree is an audio data loading and augmentation library supporting PyTorch and with extra features for JAX. Its central type, AudioTree, holds a batch of audio as a pytree: waveform, sample rate, loudness, and more, including your own per-item arrays. Augmentations come in matched NumPy and JAX backends (NumPy for CPU data-loader workers, JAX for jitted training steps).

The documentation carries the full guides, tested examples, and the API reference; start there.

Install

pip install audiotree

JAX, Flax, Grain, NumPy, librosa, and soundfile come with it. Two extras: audiotree[bagz] adds Bagz record files, which back string leaves in TreeWriter/TreeDataSource and the windowed-LUFS cache (an extra rather than a dependency because bagz publishes manylinux x86-64 wheels only, and a hard dependency made pip install audiotree unsatisfiable elsewhere); audiotree[progress] adds tqdm for AudioWriter(show_progress=True). audiotree[all] is both, wherever bagz has a wheel.

Quickstart

from audiotree import AudioTree
from audiotree.sources import create_audio_dataset
from audiotree.transforms import stereo, volume_norm

# One file in, one AudioTree out. Even a single file is a batch (of 1).
audio = AudioTree.from_file("/data/audio/song.wav", sample_rate=44_100)
print(audio.waveform.shape)   # (1, channels, samples)

# The same idea for a whole directory: a shuffled, infinite stream of 5-second
# excerpts. num_epochs=None repeats forever; an integer gives that many passes
# over the files.
ds = create_audio_dataset(
    sources=["/data/audio"],
    sample_rate=44_100,
    duration=5.0,
    shuffle=True,
    num_epochs=None,
)

# Augment. One .seed() call: each random_map derives its own stream from it.
ds = ds.seed(42)
ds = ds.map(stereo())
ds = ds.random_map(volume_norm(min_db=-20, max_db=-15))

# Batch. AudioTree.batch concatenates along the leading axis items already have,
# rather than stacking a new one.
it = iter(ds.to_iter_dataset().batch(8, batch_fn=AudioTree.batch))

batch: AudioTree = next(it)
print(batch.waveform.shape)   # (8, 2, 220500) == (batch, channels, samples)
print(batch.sample_rate)      # 44100, one scalar for the whole batch
print(batch.lufs.shape)       # (8,): volume_norm leaves the achieved loudness behind
print(batch.filepath[0])      # the source file item 0 was drawn from

The same transforms exist in two backends: audiotree.transforms (NumPy, for CPU Grain workers) and audiotree.transforms.jax (JAX, for jitted training steps), bindable from YAML or the command line with DBraun's ArgBind fork. Beyond the quickstart: balanced sampling across source groups, length-aware windowed sampling, loudness-gated excerpt search, per-dataset read-error policies, two on-disk dataset writers, and neural-codec protocols. The guides cover all of it, including how AudioTree compares to audiotools and torchaudio.

Versioning

AudioTree follows Effort-based Versioning: the version communicates the effort a change is likely to cost you, not a syntactic classification. Breaking changes are documented in the changelog.

Citation

@software{Braun_AudioTree_2026,
   author = {Braun, David},
   title = {{AudioTree}},
   url = {https://github.com/DBraun/audiotree},
   version = {1.0.0},
   year = {2026}
}

See CITATION.cff.

License

MIT, with third-party notices for the julius-derived resampler and the pyloudnorm-derived loudness code under LICENSES/. The audio fixtures under tests/assets/ in the repository are carved out of the MIT grant (the MUSDB18-HQ excerpt is CC BY-NC-SA 4.0) and are not part of any published distribution.

Metadata

Release files for audiotree 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for audiotree 1.0.0
File Size Uploaded Provenance
audiotree-1.0.0.tar.gz 176.2 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for audiotree 1.0.0
File Interpreter ABI Platform
audiotree-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 333.7 kB

Release files / audiotree-1.0.0.tar.gz

Download URL audiotree-1.0.0.tar.gz
Size 176.2 kB
Tags Source
SHA-256 checksum
How to use checksums
edd76415eda7d1fa2bd7ff923e2f8af7b482cfd62559d573aaca3d785e66ac88
BLAKE2b-256 checksum
How to use checksums
04c80599ea3653cda56a075e93fe4dcd974994d755378655d4e47afb9f161633
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 11, 2026.

Transparency log

Release files / audiotree-1.0.0-py3-none-any.whl

Download URL audiotree-1.0.0-py3-none-any.whl
Size 157.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b378c0bacedec4f6df15f2ac04c82d343da17b8d4f24e24f421b3cb78affdf6
BLAKE2b-256 checksum
How to use checksums
c941ab96155efc354052aa6f6870c50fef525690586ae0151366d2cc8b4faa79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 11, 2026.

Transparency log

Security for audiotree 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for audiotree-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 11, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page