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/
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.
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, ...])
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
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 Distributions
Built Distributions
Hashes for soxr-0.2.5a3-pp37-pypy37_pp73-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0371382d76cc0dc57dfe3d98b894d3652c1da2d5afd5d3ddcecf50d9ef350e7 |
|
MD5 | 4a4ec53db02a996fe64cb02e93e1b53e |
|
BLAKE2b-256 | 5cb3e43cfc1ccdc167e463223ce1d91c694e1fcb02f62f50142c07e7caf0eba9 |
Hashes for soxr-0.2.5a3-pp37-pypy37_pp73-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6815631cff183cf5cee22a9da2d61521c249f4572acd50e766650c474796bbb2 |
|
MD5 | 30c9419e60eb5ab11edd954e60285365 |
|
BLAKE2b-256 | c10f1bf5ed3902ed49f156a27e7d215cbcf658c6146bb282d0e39c7f26a532e2 |
Hashes for soxr-0.2.5a3-pp36-pypy36_pp73-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c73087149945f116af546b90fe1cf21d4e900427642bdae0f27f86ddec16ffb1 |
|
MD5 | a65a800eafe456e1ea19a7485a9030cd |
|
BLAKE2b-256 | 682233fe35e0265128aacc48cfbe7966cf63ab25fa6c301f29e45e9e2e131c11 |
Hashes for soxr-0.2.5a3-pp36-pypy36_pp73-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5581bc256e4b98c101c7adb00615b625d033330ce5654cd3e446215ba39d19b |
|
MD5 | db9628000cf5254e48f838f2f335827a |
|
BLAKE2b-256 | 10ece89600f1ec15aba2ff624a460ea8d7ae71133ee92eeb23c1eb14cf7597b8 |
Hashes for soxr-0.2.5a3-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7351a2507c0ad26dc2ef99ab727e999854c35002bf6eea991bec806397bdcae6 |
|
MD5 | da103a30e37bce0edcd74a4f50e73442 |
|
BLAKE2b-256 | 94e729c54599ef6fda818eeb0b42f94cf748ee4e44a377426300b416efb3f99d |
Hashes for soxr-0.2.5a3-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6ac2f9db9cae2c536d630d21278d3c3fc16bcde747a902bf557eab6e4c66a66 |
|
MD5 | d0a9fadeedab9cb424ffb3c321ee394d |
|
BLAKE2b-256 | 5eb25340ed41cee510fbf4f005f26b4b8bdd9a1c9efbcfccf87275446b744d0a |
Hashes for soxr-0.2.5a3-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00fa759162582ad16cee5b566bc86a3d876e098f6d040d4a1376922d87468dd0 |
|
MD5 | bbae64ff4be1dfb063a703b38b561659 |
|
BLAKE2b-256 | 585e34bdf7159d9b6197347d4c465fe6e218ead5f3328a581ad6cc8df5f6b63a |
Hashes for soxr-0.2.5a3-cp39-cp39-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | efdb73c3e091162d765a2b21bf7d58a7ccfef41607f236a9910b7d31b3fec7f1 |
|
MD5 | 33dce4bf433d4a31a6fea29734e939fc |
|
BLAKE2b-256 | f233b8c5d0068bd7fac1c120c6cd10e44e595accf9098ab7c9427eaac141be09 |
Hashes for soxr-0.2.5a3-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 980eda9da9b8630f8e9239f2b6012e393a76e67efa7f3f6cc5aa5a0b4666c2c0 |
|
MD5 | 71f12fb86939ef0e09a96509fed98154 |
|
BLAKE2b-256 | 3cfcb3d6242ad8a2a1fe7c9d7ad380c3e3b3e47a7f7eef7cf73777927c1b85f6 |
Hashes for soxr-0.2.5a3-cp39-cp39-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65f6cd3197df746a30d8555049aec0bcb4f373f404d6486a8294437f4763905e |
|
MD5 | a56b58d3da64061d7cbe176c6058f49c |
|
BLAKE2b-256 | db1788cd557a9dcba7b1af5fec275e8debc8df1fa07825ce47976de55cc74e1d |
Hashes for soxr-0.2.5a3-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0e53db009619cfd8060c44ec8cb1d33c223063fd7b41573e9f6a3e92305ce47 |
|
MD5 | d848b41e0ce1c282565b53598c3bbf74 |
|
BLAKE2b-256 | 2aada598eb1caeb219f4b0e51bd2a54e2dd2db0ac17765013985dc74df4240da |
Hashes for soxr-0.2.5a3-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30351c8afd070fdc7663a6ff3d57c8cc487a346e17cd5781cb6ba6f4d3585d7c |
|
MD5 | dd0a3b629e1f08e02d979ee5c572131d |
|
BLAKE2b-256 | 6ea74d41930a73b2b3591ff431e9467c1f3e353b50880d4b5b80efa8cd8fab52 |
Hashes for soxr-0.2.5a3-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9eb16776fb16efaafde568b55ce674b194a1648daeff2e0427cb510bc28c8e81 |
|
MD5 | 3eef7a65c52fa465c7f103de05ab1b20 |
|
BLAKE2b-256 | 96a2d64b5320d2193e5f4104ecff57b391bc1d8be1fc5957abfcdaf207420652 |
Hashes for soxr-0.2.5a3-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8787969e5f9d85441056f3c42eecb5ca35607ee6bbcd68b1de1f250625cf2994 |
|
MD5 | 998f64b58ab3bf4a5a9df88e63ff8a75 |
|
BLAKE2b-256 | b09b55fafb1e276a2cb5e9ebe143759d59f5736f82fb8da608084290a7a3536c |
Hashes for soxr-0.2.5a3-cp38-cp38-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86c0a5012be978f636609e33e499cbae5c077c46b971a3de58fd8339bfed7033 |
|
MD5 | beb5e4eb46d78e3b588b8601905f6a8c |
|
BLAKE2b-256 | 12ed9aa142606f0eed2b4be171ad03a96927e3dc6deb7bb90075cd5e74a27f44 |
Hashes for soxr-0.2.5a3-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7410badecc7f6f62c54172980ebfbc93fa55e1f9e0dda268f79a0b73db1aee97 |
|
MD5 | e6b9d2a0f6fecdf1943fd9e2410016b7 |
|
BLAKE2b-256 | e2d2d317e459a81c013ed70f488a2fb8413270634afcfe21e7355415aa0ba8af |
Hashes for soxr-0.2.5a3-cp38-cp38-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc764bcb55409f1dd0ff0444c7337ce474f3d6aa2bc44ebb127538bec90ce63a |
|
MD5 | d743f450e3c7c66d00f924cc98756896 |
|
BLAKE2b-256 | b0b96184da7703618ef345ebff29c0f2d82c474a99911218bd81f8d67cfae8ce |
Hashes for soxr-0.2.5a3-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6d1573806d9c509dc2ac097124c3f944b2980c1a604198a4881dceb00d2e978 |
|
MD5 | 96eefd6c34eeaa854fc0cd3382859f05 |
|
BLAKE2b-256 | 06bdf889ba0c93898f5129e4a3bd4eb8a4f1ec6d38e6735fbd6eea22dec122f6 |
Hashes for soxr-0.2.5a3-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e44f8abb88dac115143811bd87ed931c42a31f9c95072a5fcc58bb590951630 |
|
MD5 | 68b61b29c528561b7205f56019388ccc |
|
BLAKE2b-256 | 6df07bcbc693212f2b360967497347b54605b5f18c75332ad1e02a42639a128a |
Hashes for soxr-0.2.5a3-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 371d1a54f1fb8f7f6cb2756b58e39b0e6cf8229084ed0ca380f1ff205760cc12 |
|
MD5 | 6c3c3b3b0738def11f58458fb82c167c |
|
BLAKE2b-256 | 0623bd13b574a2a6f673565c96c9cd00d3414ab67cc2018c8d34385e2dede88a |
Hashes for soxr-0.2.5a3-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fa1fd231b205a5d16d0f06618e1d390ccd3ef652658471c528e36f6fc810991 |
|
MD5 | 4420b15ad6a8fe0d2ba4c78bdf9dccdd |
|
BLAKE2b-256 | 7e5e53cc02f986f5a1140d2f5efb46e05794872b17d52194e42f21efbba39d28 |
Hashes for soxr-0.2.5a3-cp37-cp37m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | effbd84c0129c9e0d32738a39d2d499cade8e9681c974c7a39d5beceef885579 |
|
MD5 | bc2be240be67acf851ffaa9eb6bce615 |
|
BLAKE2b-256 | 06ee616a31102dc4baaf5bf822b5fe65fa38375100a20cb46ecb4a754d710721 |
Hashes for soxr-0.2.5a3-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 216b258e6ed0bbb1437b947c6aa47c30f35753d8c82bbd3c1dca47724e85f548 |
|
MD5 | 6af7dccf04d9662419e5881d3a39a7b0 |
|
BLAKE2b-256 | ec7d865bbc20175a55f488be5d9aca6364fe03efef9d2f5acf2a85a260773d41 |
Hashes for soxr-0.2.5a3-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25a8063c84df73c009e2f477fd29d910eedce83678ec66f3ef5d351facd5113d |
|
MD5 | 1ac3c746081e6baf28385f32664e5ce6 |
|
BLAKE2b-256 | b8f3fce541ce3bc674a86296116e94ef3054afa01834a127fc8f4b16601b6049 |
Hashes for soxr-0.2.5a3-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3badd32eb7ce5c0ad91f9b51e2dd725039c1a9a749531cf75c7664eaaa5784e2 |
|
MD5 | 238cd6d39fb5f691695d867677890bc5 |
|
BLAKE2b-256 | eae1277cff0475c476e246c2e15cb380ce3a00b27b63ed9c2e23a8a61c5daad9 |
Hashes for soxr-0.2.5a3-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d103b5c7e2f1ab1e7cc48b2c8ac7106a2d1faf284ef7726db8a8fdedffd617d |
|
MD5 | cd3baedacfc083d31f3cc22a65e5372d |
|
BLAKE2b-256 | fb6e80d4155056d16ceb0af9a79444f4dec086856424e950edb27c133b920d87 |
Hashes for soxr-0.2.5a3-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be5b635298e78511ceaa2191e7c2d29c1e9967eef19b303d1a31819dd305b038 |
|
MD5 | 9f4374b1aafa08546d1722ec79a1c9ff |
|
BLAKE2b-256 | 27109b4fb1174b020a1fa9cf5f671349f5891546f3bd21ee0229fe5894a3106b |
Hashes for soxr-0.2.5a3-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55d3f718628ed619dc782b1d5522f97684c2097f56befb1d9e0b178452eb9404 |
|
MD5 | 33ceb1b313a0e4efe7cd499206ec9401 |
|
BLAKE2b-256 | 531f16ffebf0e7e8fa1ab2a51c3df8ff342153a76a6bd855459a154bb8951b40 |
Hashes for soxr-0.2.5a3-cp36-cp36m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | caced858605e77985fe39e5e36a9ab670905004bf124e114089e3041fd45cece |
|
MD5 | dddfcbb794190c7b53fc02c71303f196 |
|
BLAKE2b-256 | dff1c8e2d4f3fb4396170fac174fffc05ba06326e4e28bce0894cf757be545dc |
Hashes for soxr-0.2.5a3-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8db7dad0dbdf2085f946fb783b0527a8bf16c60843a06e7e9dd060acd94cfb26 |
|
MD5 | 6a09e39f5fd9d15446d870f5a007d419 |
|
BLAKE2b-256 | b68168398dda6357f68cb678dd91ebe98cd867f07370f013c77a40bf04f7c6c8 |
Hashes for soxr-0.2.5a3-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86b4e3317d580cd873bbb23560520bf6f218cf0d39251ea2ba5392566ba516f8 |
|
MD5 | 62d47da78abf096b6d11a873cc965460 |
|
BLAKE2b-256 | 17df043f3f229b06e33942a7c6bcb0a92444fd8e91f4e045d399ce7cd9a3d461 |
Hashes for soxr-0.2.5a3-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2bd1374b72b02290ed64a7435b7894d32d83cd6524e382b35a61e3199ff21c3f |
|
MD5 | 3030bafaac2eaadbc0a04d327f3d4427 |
|
BLAKE2b-256 | 5aea411780883f1d32a1718bb824fdda32c12caac1ec9ba41ae482f8c60db382 |