python-stretch
Simple python library for pitch shifting and time stretching
What it is and what it does
python-stretch is a Python wrapper around the Signalsmith Stretch C++ library that provides time stretching and pitch shifting for audio. It accepts audio as 2D arrays (channels × samples) and outputs processed audio in the same format, supporting both mono and multichannel audio with independent control of pitch (via semitone shifts) and playback speed (via time factor).
The package is actively maintained, has prebuilt wheels for Python 3.10–3.12 across macOS, Linux, and Windows, and carries no known security vulnerabilities. It is a thin binding to a mature C++ algorithm library, so installation is straightforward on supported platforms, though building from source requires a C++ compiler and CMake.
Use it for:
- Transpose audio by semitones while preserving original tempo for music analysis or remixing.
- Slow down or speed up audio playback without changing pitch for speech processing or practice.
- Batch process multichannel recordings with consistent pitch and tempo adjustments.
- Integrate pitch and time stretching into audio processing pipelines.
- Create pitch-shifted or time-stretched augmentations of audio data for training.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Pitch-shifts and time-stretches audio using the Signalsmith Stretch C++ library, working with mono and multichannel audio data.
Yes. The package is actively maintained, has no known vulnerabilities, carries a permissive MIT license, and offers a straightforward interface to a proven C++ algorithm. Install friction is moderate but manageable via prebuilt wheels on common platforms. It is a good choice if you need reliable pitch shifting and time stretching.
Install
python-stretch on PyPI
pip
pip install python-stretchuv
uv add python-stretchpoetry
poetry add python-stretchInstalling python-stretch
Before you install
Medium install friction due to compiled wheels; prebuilt binaries available for Python 3.10–3.12 on macOS, Linux, and Windows, but building from source requires a C++ compiler and CMake.
License in practice
MIT license (permissive); you can use, modify, and distribute this package freely with minimal restrictions.
Quickstart
import python_stretch as ps
# Assume audio is a 2D array (channels × samples)
stretch = ps.Signalsmith.Stretch()
stretch.preset(audio.shape[0], sr) # numChannels, sampleRate
stretch.setTransposeSemitones(12) # Shift up one octave
stretch.timeFactor = 0.75 # Slow down to 75% speed
audio_processed = stretch.process(audio)
If building from source, requires a C++ compiler and CMake.
Verify before relying
- Real-world latency or quality characteristics compared to other pitch-shifting libraries.
- Whether the package supports streaming or only batch processing of audio.
- Performance scaling with audio length or channel count.
- Compatibility with audio libraries beyond those mentioned in the description.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 546 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 183,267/month — #10,069 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: python_stretch-0.3.1-cp310-cp310-macosx_10_14_x86_64.whl; python_stretch-0.3.1-cp310-cp310-macosx_11_0_arm64.whl; python_stretch-0.3.1-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl; python_stretch-0.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; python_stretch-0.3.1-cp310-cp310-musllinux_1_2_i686.whl; python_stretch-0.3.1-cp310-cp310-musllinux_1_2_x86_64.whl; python_stretch-0.3.1-cp310-cp310-win32.whl; python_stretch-0.3.1-cp310-cp310-win_amd64.whl; python_stretch-0.3.1-cp311-cp311-macosx_10_14_x86_64.whl; python_stretch-0.3.1-cp311-cp311-macosx_11_0_arm64.whl; python_stretch-0.3.1-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl; python_stretch-0.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; python_stretch-0.3.1-cp311-cp311-musllinux_1_2_i686.whl; python_stretch-0.3.1-cp311-cp311-musllinux_1_2_x86_64.whl; python_stretch-0.3.1-cp311-cp311-win32.whl; python_stretch-0.3.1-cp311-cp311-win_amd64.whl; python_stretch-0.3.1-cp312-abi3-macosx_10_14_x86_64.whl; python_stretch-0.3.1-cp312-abi3-macosx_11_0_arm64.whl; python_stretch-0.3.1-cp312-abi3-manylinux_2_17_i686.manylinux2014_i686.whl; python_stretch-0.3.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Tags
More Sound/Audio packages
Reads and writes audio files in formats like…
permissive · top 1,000 on PyPI
pydubPydub provides a high-level Python interface…
permissive · top 5,000 on PyPI
mutagenMutagen reads and writes audio metadata (tags)…
copyleft · top 5,000 on PyPI
torchaudioProvides PyTorch-based audio processing,…
permissive · top 5,000 on PyPI
moviepyMoviePy is a Python library for video editing…
permissive · top 5,000 on PyPI
tinytagReads metadata (artist, title, duration,…
permissive · top 5,000 on PyPI
pyrubberbandProvides Python wrappers for time-stretching…
permissive · top 15,000 on PyPI
stftpitchshiftShifts the pitch and timbre of audio signals…
permissive · top 15,000 on PyPI
basic-pitchBasic Pitch converts audio files to MIDI…
unclear · top 15,000 on PyPI
audiomentationsAudiomentations applies randomized audio…
permissive · top 15,000 on PyPI
soxPython wrapper that exposes SoX audio…
permissive · top 5,000 on PyPI
pretty-midiProvides utilities for reading, modifying, and…
permissive · top 15,000 on PyPI
pysrtpysrt parses, edits, and writes SubRip (.srt)…
copyleft · top 15,000 on PyPI
soxrPerforms high-quality sample-rate conversion…
copyleft · top 5,000 on PyPI
aubioaubio is a Python wrapper around a C library…
copyleft · top 15,000 on PyPI
symusicsymusic parses and transforms MIDI and ABC…
permissive · top 15,000 on PyPI