Skip to main content

fast-mp3-augment

A fast Python library for MP3 encoder + decoder data augmentation. Made for integration with audiomentations. Intentionally applying audio degradation by lossy compression help machine learning models learn to deal with audio that gets streamed from various internet services, which is commonly lossy/compressed.

Installation

PyPI version python 3.10, 3.11, 3.12, 3.13, 3.14 os: Linux, macOS, Windows

$ pip install fast-mp3-augment

Code example

import numpy as np

import fast_mp3_augment

audio = np.random.uniform(-1, 1, (2, 2 * 48000)).astype("float32")
augmented_audio = fast_mp3_augment.compress_roundtrip(
    audio, sample_rate=48000, bitrate_kbps=64, preserve_delay=False, quality=7
)

Features

  • The output is perfectly aligned (no delay/offset and padding) with the input by default, but this trimming behavior can be disabled (with preserve_delay=True)
  • Supports mono and stereo
  • Supports standard MP3 bitrates (8-320 kbps)
  • Supports common sample rates (8-48 kHz)
  • Inputs and outputs float32 numpy array
  • Adjustable quality parameter for various tradeoffs between speed and audio quality

Performance

This library is largely developed with Rust under the hood (via pyo3 & maturin), and applies a few nice little tricks for achieving speedy execution (which is important during large-scale audio ML training!), such as:

  • Fast numpy array interop between Python and rust
  • In-memory computations (no disk I/O)
  • SIMD-optimized max abs calculation (for avoiding clipping distortion)
  • Pipelining/streaming (LAME encoder and minimp3 decoder in separate threads)

A quick performance benchmark (based on demo.py in audiomentations), which augmented 3 short (~7-9 sec) audio snippets (2 mono, 1 stereo) on a laptop with i7-13700HX and a 2 TB Samsung PM9A1 NVMe shows that fast-mp3-augment is superior when it comes to speed:

perf_benchmark_results.png

Changelog

[0.2.0] - 2025-12-15

  • Bump min Python version to 3.10
  • Officially add support for Python 3.14
  • Make builds slightly slimmer

For the complete changelog, go to CHANGELOG.md

Development setup

  • conda create --name fast-mp3-augment python=3.11
  • conda activate fast-mp3-augment
  • pip install -r dev_requirements.txt
  • maturin develop
  • pytest

LAME note

fast_mp3_augment statically links libmp3lame 3.100 (LGPL-2.1-or-later). Full source is available here. To rebuild the wheel against a modified LAME, see mp3lame-sys

Metadata

Release files for fast-mp3-augment 0.2.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 fast-mp3-augment 0.2.0
File Size Uploaded
fast_mp3_augment-0.2.0.tar.gz 639.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for fast-mp3-augment 0.2.0
File
fast_mp3_augment-0.2.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl PyPy 3.11 PyPy 3.11 7.3 Linux glibc 2.17+ x86-64 Details
fast_mp3_augment-0.2.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
fast_mp3_augment-0.2.0-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details
fast_mp3_augment-0.2.0-cp39-abi3-musllinux_1_2_aarch64.whl CPython 3.9 abi3 Linux musl 1.2+ ARM64 Details
fast_mp3_augment-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details
fast_mp3_augment-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details
fast_mp3_augment-0.2.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details

Total release size: 4.1 MB

Release files / fast_mp3_augment-0.2.0.tar.gz

Download URL fast_mp3_augment-0.2.0.tar.gz
Size 639.9 kB
Tags Source
SHA-256 checksum
How to use checksums
dae94a3abb7f8336d3d00b528f6132413cee72dfcdc91baf617f0a1d1bc8b8a9
BLAKE2b-256 checksum
How to use checksums
17bdf4bd35409f5a304f6b71614c3bde63fbbab8bc12915c35387f6d1fa86df0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release files / fast_mp3_augment-0.2.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL fast_mp3_augment-0.2.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 454.8 kB
Tags Linux glibc 2.17+ x86-64 PyPy 3.11 PyPy 3.11 7.3
SHA-256 checksum
How to use checksums
fa99e21ada08dd4cbf3145a89f9c33947881e52a9b13c432740b064f5a3f53d0
BLAKE2b-256 checksum
How to use checksums
94f214961e735518d7e341aa29a81dd4a30074664c9a5b94c80f210a5cfee3eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release files / fast_mp3_augment-0.2.0-cp39-abi3-win_amd64.whl

Download URL fast_mp3_augment-0.2.0-cp39-abi3-win_amd64.whl
Size 362.9 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
ebd3c60b00e2fbd8f2f507d867dab150979df23ad07b6da31da1163a448e43d2
BLAKE2b-256 checksum
How to use checksums
72ba1fd2bb82e59b2ef30c4846d5f40205d07f56cdd69746592d56414161ebef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release files / fast_mp3_augment-0.2.0-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL fast_mp3_augment-0.2.0-cp39-abi3-musllinux_1_2_x86_64.whl
Size 680.8 kB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
eda7af23231a657169f0f6f5be738e65b352e66b3a1b94dbd4d42b5e32825a31
BLAKE2b-256 checksum
How to use checksums
0cae32b96a043054edebd829b2ca43d38c9521b84f23db15eac717dfd2d19651
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release files / fast_mp3_augment-0.2.0-cp39-abi3-musllinux_1_2_aarch64.whl

Download URL fast_mp3_augment-0.2.0-cp39-abi3-musllinux_1_2_aarch64.whl
Size 633.9 kB
Tags CPython 3.9 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
ef8c0d0253e0a2a69d7afdde1fdd707b7d6dc051f017a53732eb23eaaa59c27f
BLAKE2b-256 checksum
How to use checksums
ea7a48b940814cf28af0a7f2efb257379b5371b23b6b2173c6451328bea7fb8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release files / fast_mp3_augment-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL fast_mp3_augment-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 460.1 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
d55288625b052635defbb0ab627fb49734b52985eb6d3ef69c35237cd80e2075
BLAKE2b-256 checksum
How to use checksums
928e335515e06d3967191e5be393c8b8de72f6f43cd047f34ee271e3f60c74d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release files / fast_mp3_augment-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL fast_mp3_augment-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 447.1 kB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
4b404f8ca64505c9f35faf8c966af9a9877f44c060dcc492d90be47e32994724
BLAKE2b-256 checksum
How to use checksums
9f2473b9d6e2327c0a4fdbaace1d661bd2159b22e53252db196d50e52ebcfb54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release files / fast_mp3_augment-0.2.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL fast_mp3_augment-0.2.0-cp39-abi3-macosx_11_0_arm64.whl
Size 428.6 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
192a1193641253a3755bbe868a189cdf068e266a6a3b695f7e63daee5ee29eb0
BLAKE2b-256 checksum
How to use checksums
f2fbc4739734d151c022cddcb02650ab411e02906b3a00fd0ae23c9a07f50b67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release history Release notifications | RSS feed

This release

0.2.0 This release

8 release files

0.1.0

7 release files

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