Registry / data / soxr
library1.1.0pypypi✓ verified 30d ago

soxr is a high-quality, one-dimensional sample-rate conversion library for Python, leveraging libsoxr. It is currently at version 1.0.0, which signifies API stability and is actively maintained with regular updates and performance improvements, including significant speed optimizations.

pip install soxr
INSTALL
IMPORT
SIG · SOXR
S
soxr
datapythonv1.1.0
Install
3.7s avg
Import
244ms
Disk
88MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v1.1.0 · 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 3.7s · import 0.244s · 86MB
88MB installed
● package 88MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

soxr
✓ import soxr

This quickstart demonstrates how to use `soxr.resample` to convert the sample rate of a NumPy array containing audio data. It generates a dummy stereo signal and resamples it from 48kHz to 44.1kHz.

import soxr import numpy as np # Example: Resample stereo audio from 48 kHz to 44.1 kHz input_sample_rate = 48000 output_sample_rate = 44100 duration_seconds = 1 num_samples_in = int(input_sample_rate * duration_seconds) # Generate dummy stereo audio data (e.g., sine wave) # Use float32, as it's common for audio processing t = np.linspace(0, duration_seconds, num_samples_in, endpoint=False) input_audio = np.array([ np.sin(2 * np.pi * 440 * t), # Left channel np.sin(2 * np.pi * 660 * t) # Right channel ], dtype=np.float32).T # Transpose to (samples, channels) for soxr # Perform resampling output_audio = soxr.resample(input_audio, input_sample_rate, output_sample_rate) print(f"Input audio shape: {input_audio.shape}") # (samples_in, channels) print(f"Output audio shape: {output_audio.shape}") # (samples_out, channels) print(f"Output sample rate: {output_sample_rate} Hz")
Debug
Known issues
breakingVersion 0.5.0 removed deprecated implicit conversions within the `ResampleStream` class, requiring explicit type handling or conversion before processing. This affects code directly using `ResampleStream` from versions prior to 0.5.0.
fix
Review any direct usage of `soxr.ResampleStream` and ensure all input data is explicitly converted to the expected format and type before being passed to the stream for processing.
affects: 0.5.0 and later
breakingVersion 0.4.0 dropped support for Python versions older than 3.9 and introduced compatibility with NumPy 2. Projects targeting older Python versions (e.g., 3.8 or earlier) or NumPy 1 will encounter errors.
fix
Upgrade your Python environment to 3.9 or newer and ensure NumPy is version 2.x or later. If upgrading is not feasible, pin `soxr<0.4.0` in your project dependencies.
affects: 0.4.0 and later
gotchaVersion 1.0.0 introduces support for free-threaded Python, but the release notes explicitly state it is 'not battle-tested yet'. Users deploying `soxr` in free-threaded environments should be aware of potential instabilities.
fix
Exercise caution and thorough testing when using `soxr` in free-threaded Python environments with version 1.0.0. Monitor future releases for improved stability and explicit assurances regarding free-threading.
affects: 1.0.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'soxr'
The 'soxr' library is not installed in your Python environment.
fix
pip install soxr
ImportError: DLL load failed while importing _soxr_impl: The specified module could not be found.
On Windows, this usually means the underlying `libsoxr` C library, which `soxr` wraps, could not be loaded or its dependencies are missing.
fix
Ensure your Python environment is correct and try reinstalling `soxr` with `pip install --no-cache-dir soxr`. For some complex environments, you might need to ensure system-wide `libsoxr` dependencies are met, but generally, the `soxr` wheels bundle necessary components.
ValueError: Input must be a 1D array.
The `soxr.resample` function expects a single-channel (1-dimensional) audio array, but received a multi-dimensional array (e.g., stereo data).
fix
Ensure the input audio data is a 1D numpy array. If you have stereo data, process each channel separately or convert to mono first.
ValueError: Sample rate must be positive.
The input or output sample rate provided to `soxr.resample` is zero or negative, which is not a valid sample rate.
fix
Provide positive integer values for both `srate_in` and `srate_out` arguments.
AttributeError: 'NoneType' object has no attribute 'dtype'
This error occurs when the input data passed to `soxr.resample` is `None`, often because a preceding operation failed to return valid audio data.
fix
Verify that the variable intended for the `input` argument to `soxr.resample` holds a valid numpy array, not `None`.
Upgrade
Version history
1.1.0latest on PyPI · released May 3, 2026
Audit
Dependencies
numpyrequiredEssential for handling audio data as numerical arrays; `soxr` heavily integrates with NumPy arrays for input/output.
Agent activity
13 hits · last 30 days
node
10
OpenAI (training)
1
Resources