AudioStretchy is a Python library and CLI tool for high-quality time-stretching of audio files without changing pitch. Uses David Bryant's audio-stretch C library with Pedalboard for versatile audio I/O.
Maintained. Last release 13 days ago, commits in 4 of the last 26 weeks. Weaker on commit activity and contributor spread.
pip install audiostretchythis_file: README.md
AudioStretchy
Change audio duration without changing pitch, using David Bryant's audio-stretch TDHS engine. Pedalboard reads and writes WAV, MP3, FLAC, OGG and AIFF; NumPy handles samples and linear-interpolation resampling.
uv tool install audiostretchy
# 10% shorter, at the same pitch:
audiostretchy input.mp3 output.mp3 --ratio 0.9
For a Python project, use uv add audiostretchy:
from audiostretchy import AudioStretch, stretch_audio
stretch_audio("input.wav", "output.wav", ratio=0.9)
processor = AudioStretch()
processor.open("input.wav")
processor.stretch(ratio=1.2) # 20% longer
processor.resample(24000)
processor.save("output.wav")
Run audiostretchy --help for all parameters. Ratios from 0.25 to 4.0 are
supported; the extended range automatically cascades two TDHS instances.
Input must be mono or stereo. Stretching uses 16-bit PCM internally.
gap_ratio, buffer_ms, threshold_gap_db, and normal_detection remain
compatibility arguments: separate silence stretching is not implemented.
Installation and platforms
Python 3.10 or newer. Published wheels contain one freshly compiled native library and the corresponding C sources and license:
- Linux x86_64 and aarch64 (manylinux/glibc).
- macOS Intel and Apple Silicon (macOS 11 or newer).
- Windows x86_64.
The native library uses ctypes and is independent of the CPython ABI, so wheels
carry py3-none-<platform> tags. Dependencies install separately; NumPy and
Pedalboard are not copied into the wheel. Other platforms can build from the
source distribution when a C compiler and dependency wheels are available.
Linux musl and Windows ARM are not part of the tested wheel matrix.
All required TDHS source is bundled under src/audiostretchy/_vendor/audio-stretch.
There is no submodule initialization, build-time download, or compiler needed
when installing a compatible wheel. UPSTREAM.md records the pinned upstream
commit. Builds are reproducible from that snapshot; upstream is not fetched
implicitly during releases.
Development
uv sync --frozen
./test.sh # lint, format check and all tests
uvx hatch test # alternative Hatch test environment
uv build # sdist, then a native wheel built from that sdist
Building from source needs a C compiler ( on Unix or MSVC on Windows). On Windows run from a Visual Studio developer shell. The Hatch wheel hook and share the same compiler implementation. Editable installs compile the library too. , , and are honoured on Unix; defaults to 11.0 on macOS.