Install & Compatibility
Where this runs
tested against v0.4.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
build_error
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 7.2s · import 0.922s · 288MB
285MB installed
● package 285MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
resample
✓ from resampy import resample
✗ import resampy; resampy.resample(...)
This example demonstrates how to generate a sine wave using NumPy and then resample it to a different sample rate using `resampy.resample`.
import numpy as np
import resampy
# Generate a 5-second sine wave at 440 Hz
sr_orig = 44100 # Original sample rate
duration = 5 # seconds
frequency = 440 # Hz
t = np.arange(int(sr_orig * duration)) / sr_orig
x = np.sin(2 * np.pi * frequency * t)
# Resample the signal to a new sample rate (e.g., 22050 Hz)
sr_new = 22050
y = resampy.resample(x, sr_orig, sr_new)
print(f"Original signal length: {len(x)} samples")
print(f"Resampled signal length: {len(y)} samples")
print(f"Original sample rate: {sr_orig} Hz")
print(f"New sample rate: {sr_new} Hz")
Debug
Known issues
breakingSince version 0.4.0, integer-valued inputs to `resampy.resample` will always produce floating-point outputs. Prior versions could potentially return integer outputs if the input was integer-valued.fixIf integer outputs are required, explicitly cast the output array (e.g., `y.astype(int)`) after resampling. Be aware of potential data loss during casting.
affects: >=0.4.0
gotchaStarting from version 0.4.0, parallel computation in `resampy.resample` is disabled by default (`parallel=False`). In previous versions, it was `True` by default.fixTo re-enable parallel processing for performance on multi-core systems, explicitly set `parallel=True` in the `resampy.resample` call: `resampy.resample(..., parallel=True)`.
affects: >=0.4.0
deprecatedVersions of `resampy` prior to 0.4.3 may raise a `DeprecationWarning` related to the `importlib_resources` API when used with newer Python versions, as the internal usage has been updated in 0.4.3.fixUpgrade to `resampy` version 0.4.3 or newer (`pip install --upgrade resampy`) to resolve this warning.
affects: <0.4.3
gotchaVersion 0.3.0 introduced an efficiency regression that could lead to slower performance compared to previous versions. This regression was fixed in version 0.3.1.fixAvoid using version 0.3.0. Ensure you are on version 0.3.1 or newer if you encounter unexpected performance degradation after upgrading from older releases.
affects: 0.3.0
gotchaThe output length of signals resampled with `resampy` might differ slightly from other libraries like `scipy.signal.resample` for the same upsampling ratio, due to different internal calculation and rounding strategies.fixIf precise output length matching another library is critical, carefully compare the output shapes or use a wrapper function to normalize lengths if possible. For most audio applications, the difference is negligible.
affects: All versions
gotchaIn version 0.2.0, the core resampling implementation was rewritten from Cython to Numba. This change may affect performance characteristics or introduce new dependency considerations (e.g., Numba installation issues) for users upgrading from 0.1.x versions.fixEnsure `numba` is correctly installed and configured. If performance changes are observed, review Numba's documentation for potential optimization or troubleshooting tips.
affects: From 0.1.x to 0.2.0+
Upgrade
Version history
0.4.3latest on PyPI · released Mar 5, 2024
Audit
Dependencies
numpyrequiredCore array manipulation
scipyrequiredScientific computing functionalities
numbarequiredJust-in-time compilation for performance, core implementation is Numba-based