AudioTree
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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file audiotree-1.0.0.tar.gz.
File metadata
- Download URL: audiotree-1.0.0.tar.gz
- Upload date:
- Size: 176.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
edd76415eda7d1fa2bd7ff923e2f8af7b482cfd62559d573aaca3d785e66ac88
|
|
| MD5 |
3be1d1c2b123dbb5af4a5ecd417fc9d6
|
|
| BLAKE2b-256 |
04c80599ea3653cda56a075e93fe4dcd974994d755378655d4e47afb9f161633
|
Provenance
The following attestation bundles were made for audiotree-1.0.0.tar.gz:
Publisher:
all.yml on DBraun/audiotree
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
audiotree-1.0.0.tar.gz -
Subject digest:
edd76415eda7d1fa2bd7ff923e2f8af7b482cfd62559d573aaca3d785e66ac88 - Sigstore transparency entry: 2425135125
- Sigstore integration time:
-
Permalink:
DBraun/audiotree@c7aa039c6f69274a4d42e27ae756dfe27e4f7453 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/DBraun
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
all.yml@c7aa039c6f69274a4d42e27ae756dfe27e4f7453 -
Trigger Event:
release
-
Statement type:
File details
Details for the file audiotree-1.0.0-py3-none-any.whl.
File metadata
- Download URL: audiotree-1.0.0-py3-none-any.whl
- Upload date:
- Size: 157.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b378c0bacedec4f6df15f2ac04c82d343da17b8d4f24e24f421b3cb78affdf6
|
|
| MD5 |
baca836ee793cfc488571fa72bbe5c7a
|
|
| BLAKE2b-256 |
c941ab96155efc354052aa6f6870c50fef525690586ae0151366d2cc8b4faa79
|
Provenance
The following attestation bundles were made for audiotree-1.0.0-py3-none-any.whl:
Publisher:
all.yml on DBraun/audiotree
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
audiotree-1.0.0-py3-none-any.whl -
Subject digest:
7b378c0bacedec4f6df15f2ac04c82d343da17b8d4f24e24f421b3cb78affdf6 - Sigstore transparency entry: 2425135203
- Sigstore integration time:
-
Permalink:
DBraun/audiotree@c7aa039c6f69274a4d42e27ae756dfe27e4f7453 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/DBraun
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
all.yml@c7aa039c6f69274a4d42e27ae756dfe27e4f7453 -
Trigger Event:
release
-
Statement type: