Registry / data / resampy

resampy

JSON →
library0.4.3pypypi✓ verified 28d ago

resampy is a Python module for efficient time-series resampling, primarily designed for audio applications. It implements the band-limited sinc interpolation method for sampling rate conversion, offering performance advantages over `scipy.signal.resample` for long-duration signals. The current version is 0.4.3, with maintenance releases occurring periodically to ensure compatibility and address minor issues.

pip install resampy
INSTALL
IMPORT
SIG · RESAMPY
R
resampy
datapythonv0.4.3
Install
7.2s avg
Import
922ms
Disk
285MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.9–3.13
musl
3.9–3.13
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
musl
py 3.10–3.95 runs
build_error
glibc
py 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.
fix
If 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.
fix
To 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.
fix
Upgrade 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.
fix
Avoid 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.
fix
If 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.
fix
Ensure `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
Agent activity
14 hits · last 30 days
node
10
Amazon
1
OpenAI (training)
1
Resources
resampy — pip install resampy · libregistry