samplerate
Monolithic python wrapper for libsamplerate based on pybind11 and NumPy
What it is and what it does
samplerate is a Python wrapper around libsamplerate (Secret Rabbit Code), a high-quality audio sample rate conversion library. It exposes three APIs for resampling: a Simple API for one-shot conversion of large chunks, a Full API for processing successive chunks of data, and a Callback API where input is provided by a callback function. The library bundles libsamplerate statically using pybind11 and requires numpy as its only runtime dependency.
The package is designed for developers and researchers working with audio signal processing who need to convert audio between different sample rates while maintaining high fidelity. It supports modern Python versions (3.7+) and provides pre-built wheels for common platforms (macOS, Linux, Windows on x86_64 and aarch64 architectures), though building from source on other platforms requires a C++14 compiler.
Use it for:
- Convert audio recordings between different sample rates for compatibility with target systems or workflows.
- Resample streaming audio chunks in processing pipelines using the Full or Callback API.
- Perform high-quality audio format conversion in scientific audio analysis or music processing workflows.
- Implement sample rate adaptation in audio applications that need to handle multiple input sample rates.
- Process audio signals in signal processing research where libsamplerate's quality algorithms are required.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Wraps libsamplerate (Secret Rabbit Code) to perform high-quality audio sample rate conversion using three APIs: Simple, Full, and Callback.
Yes, if you need high-quality audio resampling. The package is actively maintained, has no known vulnerabilities, uses permissive licenses, and provides convenient access to a well-established C library. Medium install friction is acceptable given the availability of pre-built wheels for common platforms. Not necessary if you only need basic resampling or are on an unsupported architecture without a C++ compiler.
Install
samplerate on PyPI
pip
pip install samplerateuv
uv add sampleratepoetry
poetry add samplerateInstalling samplerate
Before you install
Medium install friction due to compiled C++ bindings, but pre-built wheels cover macOS (x86_64, arm64), Linux (x86_64, aarch64), and Windows (x86_64). Last release 145 days ago; maintenance status is active.
License in practice
MIT license (permissive); the bundled libsamplerate is licensed under 2-clause BSD as of version 0.1.9, both permissive and compatible with most projects.
Quickstart
import numpy as np
import samplerate
input_data = np.sin(2 * np.pi * 5 * np.arange(1000) / 1000.)
output_data = samplerate.resample(input_data, ratio=1.5, converter='sinc_best')
Requires C++14 compiler if building from source on platforms without pre-built wheels; binary wheels available for common platforms.
Verify before relying
- Whether the package is suitable for real-time audio processing or only batch resampling.
- Performance characteristics and quality trade-offs between the three converter options (sinc_best, sinc_fastest, etc.).
- Typical use cases for sample rate conversion (e.g., converting between specific audio formats or standards).
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 1 — numpy |
| Maintenance | actively maintained — 145 days since the last release |
| First released | |
| Downloads | 289,126/month — #8,006 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: samplerate-0.2.4-cp310-cp310-macosx_10_9_universal2.whl; samplerate-0.2.4-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; samplerate-0.2.4-cp310-cp310-win_amd64.whl; samplerate-0.2.4-cp311-cp311-macosx_10_9_universal2.whl; samplerate-0.2.4-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; samplerate-0.2.4-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; samplerate-0.2.4-cp311-cp311-win_amd64.whl; samplerate-0.2.4-cp312-cp312-macosx_10_13_universal2.whl; samplerate-0.2.4-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; samplerate-0.2.4-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; samplerate-0.2.4-cp312-cp312-win_amd64.whl; samplerate-0.2.4-cp313-cp313-macosx_10_13_universal2.whl; samplerate-0.2.4-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; samplerate-0.2.4-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; samplerate-0.2.4-cp313-cp313-win_amd64.whl; samplerate-0.2.4-cp314-cp314-macosx_10_15_universal2.whl; samplerate-0.2.4-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; samplerate-0.2.4-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; samplerate-0.2.4-cp314-cp314-win_amd64.whl; samplerate-0.2.4-cp39-cp39-macosx_10_9_universal2.whl
Keywords: samplerate, converter, signal processing, audio
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
soxrPerforms high-quality sample-rate conversion…
copyleft · top 5,000 on PyPI
audiolabaudiolab loads, processes, and saves audio…
permissive · top 15,000 on PyPI
pyloudnormMeasures and normalizes audio loudness…
permissive · top 5,000 on PyPI
juliusJulius provides differentiable, GPU-accelerated…
permissive · top 5,000 on PyPI
audiomentationsAudiomentations applies randomized audio…
permissive · top 15,000 on PyPI
soundfileReads and writes audio files in formats like…
permissive · top 1,000 on PyPI
pyworldPyWorld wraps the WORLD vocoder to decompose…
unclear · top 15,000 on PyPI
soxPython wrapper that exposes SoX audio…
permissive · top 5,000 on PyPI
descript-audio-codecCompresses audio into discrete codes at 8 kbps…
permissive · top 15,000 on PyPI