{"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":"en","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,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}