High quality, one-dimensional sample-rate conversion library
Project description
Python-SoXR
High quality, one-dimensional sample-rate conversion library for Python.
- Homepage: https://github.com/dofuuz/python-soxr
- Documentation: https://python-soxr.readthedocs.io
- PyPI: https://pypi.org/project/soxr/
Keywords: Resampler, Audio resampling, Samplerate conversion, DSP(Digital Signal Processing)
Python-SoXR is a Python wrapper of libsoxr.
Installation
pip install soxr
If installation fails, upgrade pip with python -m pip install --upgrade pip
and try again.
in Conda environment
conda install -c conda-forge soxr-python
Note: Conda packge name is soxr-python
, not python-soxr.
Basic usage
import soxr
y = soxr.resample(
x, # 1D(mono) or 2D(frames, channels) array input
48000, # input samplerate
16000 # target samplerate
)
If input is not numpy.ndarray
, it will be converted to numpy.ndarray(dtype='float32')
.
dtype should be one of float32, float64, int16, int32.
Output is numpy.ndarray
with same dimension and data type of input.
Streaming usage
Use ResampleStream
for real-time processing or very long signal.
import soxr
rs = soxr.ResampleStream(
44100, # input samplerate
16000, # target samplerate
1, # channel(s)
dtype='float32' # data type (default = 'float32')
)
eof = False
while not eof:
# Get chunk
...
y_chunk = rs.resample_chunk(
x, # 1D(mono) or 2D(frames, channels) array input
last=eof # Set True at end of input
)
Output frame count may not be consistent. This is normal operation.
(ex. [0, 0, 0, 186, 186, 166, 186, 186, 168, ...])
Requirement
x86 and ARM processors are supported.
Benchmark
Sweep, impulse, speed compairsion with other Python resamplers.
https://colab.research.google.com/drive/1XgSOvWlRIau1FYwQG_yRSAhDK3KB8bEL?usp=sharing
Speed comparison summary
Downsampling 10 sec of 48000 Hz to 44100 Hz.
Ran on Google Colab.
Library | Time on CPU (ms) |
---|---|
soxr (HQ) | 7.2 |
scipy.signal.resample | 13.4 |
soxr (VHQ) | 15.8 |
torchaudio | 19.2 |
lilfilter | 21.4 |
julius | 23.1 |
resampy (kaiser_fast) | 62.6 |
samplerate (sinc_medium) | 92.5 |
resampy (kaiser_best) | 256 |
samplerate (sinc_best) | 397 |
Technical detail
For technical details behind resampler, see libsoxr docs.
- https://sourceforge.net/p/soxr/wiki/Home/
- http://sox.sourceforge.net/SoX/Resampling
- https://sourceforge.net/p/soxr/code/ci/master/tree/src/soxr.h
Python-SoXR uses forked version of libsoxr. See difference here.
These changes does not apply to dynamic linked builds. (e.g. conda-forge build)
To determine the version of libsoxr, use soxr.__libsoxr_version__
.
Credit and License
Python-SoXR is LGPL v2.1+ licensed, following libsoxr's license.
OSS libraries used
libsoxr (LGPLv2.1+)
The SoX Resampler library
https://sourceforge.net/projects/soxr/
Python-SoXR is a Python wrapper of libsoxr.
PFFFT (BSD-like)
PFFFT: a pretty fast FFT.
https://bitbucket.org/jpommier/pffft/
libsoxr dependency.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for soxr-0.5.0a1-cp312-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c49257c46e7f1fb6329f2545e72665d5256ebd95dbe36c94b7687f6f034ae690 |
|
MD5 | d034de1a17982e889ffd078a670e40cf |
|
BLAKE2b-256 | cd53a6a686eb351485063498d294b098ffa6d1cd3166546839824c60bb13cc15 |
Hashes for soxr-0.5.0a1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 806bbc7f8b43beaf68a650643027a95f633327c829b14cafdb79e9d6964c1214 |
|
MD5 | b26bc4bcc6855f0a98b809634f531609 |
|
BLAKE2b-256 | feb95f69bf1851194d0953ef4217ebc93a1d8aa20fa7d3553c1e7bfb19af6bb2 |
Hashes for soxr-0.5.0a1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d210d010c24b425963fe0264d61d56c3d17fc361535f5c95435a9f8dd444c1d |
|
MD5 | d1ebdfcc374bbaf3da2202287f045035 |
|
BLAKE2b-256 | 66271580976a799784697dcc683c4c30bca36d3ae25286fc0ecda3c718905ba1 |
Hashes for soxr-0.5.0a1-cp312-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82e4c45ad7b5c474c886a1cbfd495a081ec0fdb6652483f4b1265e5d19dea739 |
|
MD5 | 067c7137aab3816bcb65c6f1b6adad9f |
|
BLAKE2b-256 | f257c8881f2b55780c2bf7a11a4fc1129ff401e577accb4d9eca6c062277da7a |
Hashes for soxr-0.5.0a1-cp312-abi3-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94d16d0b79c880abdc65fd58ef6ecce375e0a159479266e0f213193e7a7935b3 |
|
MD5 | 787dfe0051a9a27e49ee38d55ad6fb7f |
|
BLAKE2b-256 | 5de80792dab7d1c3b5f19fd2fc644523483c9a0efd2f4e5200415226d83cad7f |
Hashes for soxr-0.5.0a1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77bb712f8664bc11fba9df0ae0eb0d7e5e75ff47cee1fd6347d1cdb0a80749b7 |
|
MD5 | 5c4eb46f320eeb29588e3be901aa39e3 |
|
BLAKE2b-256 | 6c31196caab13666017532eb3ad706a71e58cc762aad95d15df1edbc7c453892 |
Hashes for soxr-0.5.0a1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3e5b2a9cd9352c18449ae48235ccadceb53e6edf50529b1d3f4df1a41eb4a43 |
|
MD5 | 38138e9341616608542f780736cc3b8b |
|
BLAKE2b-256 | 9f5b54855969065a5c47d9c465fa5e6276d9946b683d61a7b9acd63044915ab6 |
Hashes for soxr-0.5.0a1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d53d718fef0f8c0a5ef7a9b1ce98f299b89993fdc86d9bc3363629bbc3ba38d |
|
MD5 | d42be86bfa3ff485a3fe181fc2093625 |
|
BLAKE2b-256 | 29737d8c8fdbb0303f7ad7110faf634370f8009afcf24f760913e3df4941e185 |
Hashes for soxr-0.5.0a1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92c04821bc47c62d52cee76a0f3c7f6adb272175e45bbfa90ef6172a013c4d44 |
|
MD5 | 453484d16767888cd9898b6e42255a5c |
|
BLAKE2b-256 | 7ace043a73662ed460cadbbe47ad3deebe01288ae25049480a85aa63b4721adf |
Hashes for soxr-0.5.0a1-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ca573c84ba1fb976f5f4831589d12b2c41c1c8d8b66527f930e466d4f7de6f3 |
|
MD5 | 34cbccb3c8af4c59e01e585da884a342 |
|
BLAKE2b-256 | 90e0c9e4a7a603faeab853c2818fd57a899157556846ef2b68c91766260ec483 |
Hashes for soxr-0.5.0a1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b55c9928242d471dfcf52b7d2511ad7a67e56d2cadd73a8b2f46b0959a4e3c6d |
|
MD5 | 947952c65fac84950f5484e7451c49e9 |
|
BLAKE2b-256 | 695253adf4b8792701009e70ba08bbd1fa7d6897d791c2bef697575c89e692ae |
Hashes for soxr-0.5.0a1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4025a2ae4caf4ecc279ec49375387c6876401092c90ef5bc2791ac216ebc72b1 |
|
MD5 | babe2a21470de685720c72794b318751 |
|
BLAKE2b-256 | 73ed69d88741beabb22f150fe1edce5a167b13043a7bab35bb4b276c14df0b11 |
Hashes for soxr-0.5.0a1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 423cabd82ac75564908d774ff858bd31ea23abc534a4a8d879e028be575dcdd1 |
|
MD5 | 68ed35f5ebba461de26fac8bf4fcecb2 |
|
BLAKE2b-256 | 764850c2fb1e1fa0d08110043afaa58ec6695b6b8c89153c9bb84c38b3d89fb5 |
Hashes for soxr-0.5.0a1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b666fd9a135af970583feb7210ff973c847c370d46a7ab80c65511aea72d5b39 |
|
MD5 | a534dad70d567cb864fd456072fe8fce |
|
BLAKE2b-256 | e4536ce0f561483030248c6d0261683bb69c2b1cb784744ee3438e73212ef0f7 |
Hashes for soxr-0.5.0a1-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f3e394f1ff1b0b8de321dd8843e4c837fad18f4ac565dff93dd4f8bd075344c |
|
MD5 | 68c6b4810f4ee457caa58f5e46b696f5 |
|
BLAKE2b-256 | 2cc56a9a76364fcfc8ecd82dab4bc55320d76667a0bfd79e3a40820d2e188d1d |
Hashes for soxr-0.5.0a1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf2bd071b59f354a00ac3ca2125bd9596183ca4fdd0941df0a44a54236450055 |
|
MD5 | 7908b6d4963dd05f549158053edc561f |
|
BLAKE2b-256 | 442a60e19628ac58d0d7512bccc8662118c7e0f181f0a934455b08c0b4f43355 |
Hashes for soxr-0.5.0a1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c365e284bd1a259dc9275c54974d249fe662cf84daf69c648119097df2f7a3d |
|
MD5 | 2a9a5b3b78b32d99a6b2728d5bcc7e66 |
|
BLAKE2b-256 | 91e7c0be79d830a4f0e8122c13f75dbdc085a534a2f1becdd9a1411318aedb7f |
Hashes for soxr-0.5.0a1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1b5a3500f9e3dbeec1cf0f8724065d836c66de6ca7831fb66c0a450209069f6 |
|
MD5 | 3b62c4f2d0aa5107151dfed5d3495139 |
|
BLAKE2b-256 | b483708ae0add93ab4d7f163bd60da132a1da1b2695f4fc7f3a5950fd32770a2 |
Hashes for soxr-0.5.0a1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6395661051c0e04d5daab38e288a04078be8495cf49774c231aaa29911d1200c |
|
MD5 | 0915ae3639eaf288da82a26dbe0beb5d |
|
BLAKE2b-256 | 0cb66be82b2c0188cf526ed05021a96c5cfb0afb7c743c22dba366d568cee150 |
Hashes for soxr-0.5.0a1-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1bcf67b107775dfba121604193cc7c0964af41f6711ae239a7c5e7f1f49cf47 |
|
MD5 | ed4573fb0ee74830e90446c5d59af567 |
|
BLAKE2b-256 | 6cdae485d69974f3f442c972051b7f4504d134ecf4a908d83c55f14a0c88aa94 |