{"id":1717,"library":"soxr","title":"soxr","description":"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.","status":"active","version":"1.0.0","language":"python","source_language":"en","source_url":"https://github.com/dofuuz/python-soxr","tags":["audio","resampling","sample-rate-conversion","signal-processing","numpy"],"install":[{"cmd":"pip install soxr","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Essential for handling audio data as numerical arrays; `soxr` heavily integrates with NumPy arrays for input/output.","package":"numpy","optional":false}],"imports":[{"symbol":"soxr","correct":"import soxr"}],"quickstart":{"code":"import soxr\nimport numpy as np\n\n# Example: Resample stereo audio from 48 kHz to 44.1 kHz\ninput_sample_rate = 48000\noutput_sample_rate = 44100\nduration_seconds = 1\nnum_samples_in = int(input_sample_rate * duration_seconds)\n\n# Generate dummy stereo audio data (e.g., sine wave)\n# Use float32, as it's common for audio processing\nt = np.linspace(0, duration_seconds, num_samples_in, endpoint=False)\ninput_audio = np.array([\n    np.sin(2 * np.pi * 440 * t),  # Left channel\n    np.sin(2 * np.pi * 660 * t)   # Right channel\n], dtype=np.float32).T # Transpose to (samples, channels) for soxr\n\n# Perform resampling\noutput_audio = soxr.resample(input_audio, input_sample_rate, output_sample_rate)\n\nprint(f\"Input audio shape: {input_audio.shape}\") # (samples_in, channels)\nprint(f\"Output audio shape: {output_audio.shape}\") # (samples_out, channels)\nprint(f\"Output sample rate: {output_sample_rate} Hz\")","lang":"python","description":"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."},"warnings":[{"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.","message":"Version 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.","severity":"breaking","affected_versions":"0.5.0 and later"},{"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.","message":"Version 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.","severity":"breaking","affected_versions":"0.4.0 and later"},{"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.","message":"Version 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.","severity":"gotcha","affected_versions":"1.0.0"}],"env_vars":null,"search_vec":"'1.0.0':25 'activ':32 'api':28 'audio':44 'convers':14,49 'current':22 'dimension':10 'high':6 'high-qual':5 'improv':39 'includ':40 'leverag':18 'librari':15 'libsoxr':19 'maintain':33 'numpi':53 'one':9 'one-dimension':8 'optim':43 'perform':38 'process':52 'python':17 'qualiti':7 'rate':13,48 'regular':35 'resampl':45 'sampl':12,47 'sample-r':11 'sample-rate-convers':46 'signal':51 'signal-process':50 'signifi':27 'signific':41 'soxr':1,2 'speed':42 'stabil':29 'updat':36 'version':24","created_at":"2026-04-09T04:00:06.713587+00:00","updated_at":"2026-04-16T21:58:00.263245+00:00","problems":[{"fix":"pip install soxr","cause":"The 'soxr' library is not installed in your Python environment.","error":"ModuleNotFoundError: No module named 'soxr'"},{"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.","cause":"On Windows, this usually means the underlying `libsoxr` C library, which `soxr` wraps, could not be loaded or its dependencies are missing.","error":"ImportError: DLL load failed while importing _soxr_impl: The specified module could not be found."},{"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.","cause":"The `soxr.resample` function expects a single-channel (1-dimensional) audio array, but received a multi-dimensional array (e.g., stereo data).","error":"ValueError: Input must be a 1D array."},{"fix":"Provide positive integer values for both `srate_in` and `srate_out` arguments.","cause":"The input or output sample rate provided to `soxr.resample` is zero or negative, which is not a valid sample rate.","error":"ValueError: Sample rate must be positive."},{"fix":"Verify that the variable intended for the `input` argument to `soxr.resample` holds a valid numpy array, not `None`.","cause":"This error occurs when the input data passed to `soxr.resample` is `None`, often because a preceding operation failed to return valid audio data.","error":"AttributeError: 'NoneType' object has no attribute 'dtype'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.1.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/dofuuz/python-soxr","docs":"https://python-soxr.readthedocs.io","changelog":"https://github.com/dofuuz/python-soxr/releases","pypi":"https://pypi.org/project/soxr/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-27","next_check":"2026-07-28","install_tag":null}}