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 Distribution
Built Distributions
Hashes for soxr-0.2.5a2-pp37-pypy37_pp73-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 694261ab5816352697b209fbdaea848956bbaef6adbee4f771fd7e146d306276 |
|
MD5 | 66203ed54b401688bbb8da9d1ce7fb67 |
|
BLAKE2b-256 | 0eb8692bffe5a9627e3865eadcf90d6edc863c19b191934a374c281b93a29df6 |
Hashes for soxr-0.2.5a2-pp37-pypy37_pp73-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | debe960cf5e7f4e029197329fd14c039d2375729f938f34780db8bbbbcd208a4 |
|
MD5 | 0349399f8966df7042d21234ca0d291a |
|
BLAKE2b-256 | 00ac6c60377433d264d35f9698509b5bf5cee4f5bff70cdbd6d897740b5b1305 |
Hashes for soxr-0.2.5a2-pp36-pypy36_pp73-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fbf66d3bcc03b877f63f15380cfc791282c3121cd7b4436104d790484160c1b |
|
MD5 | a116e06cb7f646f85bda1e2cc2bd1dbd |
|
BLAKE2b-256 | 187dadd058b16b4020b5b7fe63bd6df4b41c3c58696591bc1852f500d4ebe6ac |
Hashes for soxr-0.2.5a2-pp36-pypy36_pp73-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 933a42b2ca6ff18c70d8e467473771cbe2e8dad232e3ede27fa46b02c73b3459 |
|
MD5 | 420499599d1f526c04ec7adecf8d51d6 |
|
BLAKE2b-256 | 0aa06af79c8b9003759c2fe21a68b9a16a86d53c86a618ecf3aead3c70d41320 |
Hashes for soxr-0.2.5a2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | efb9cca241fdcdf45836a012e50a78f58e4250391d28f1c354e43d2d2a7f3c0d |
|
MD5 | cfbf4e7e5d6fc477d61d358330816d95 |
|
BLAKE2b-256 | f1cc9e4adea8abb985af7426cbbe618110f6b292c111decdf6932d2073b0296c |
Hashes for soxr-0.2.5a2-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc383fa2d41eda04917066d0a5efc9e50d01bd283bb2a0a4ee52c96e4f910eee |
|
MD5 | 668d4a62eafc909853c00a374f2a3471 |
|
BLAKE2b-256 | 524c953e9f523700653e6a459457a3059b7e01e9e389b5fda61bb2cbff110a19 |
Hashes for soxr-0.2.5a2-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 125882f61155f6927b5c1a0bdacc2694b9f19aa1b0c05daed93de100f2f4f902 |
|
MD5 | 0528b91d2ddd993e5943e6e40ccebd23 |
|
BLAKE2b-256 | 65d412adf55cd0f4e7297d1b905775b2ec70623583c654e14c079804ed980994 |
Hashes for soxr-0.2.5a2-cp39-cp39-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5000b676b2c0c18a904fc11183f2cce1ca94ce1749deefeb91ccc567755e58a2 |
|
MD5 | e8f1c63d2c037c4a6c04510372cb402e |
|
BLAKE2b-256 | b5eba7bb7b07baf4082542cc4a7c59304a5d4b928f6661ff9e76121a6efa8943 |
Hashes for soxr-0.2.5a2-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a38421f1137157cc16341a5bf5189969a1e3a6fe5ca58b909b43dede36f0ab89 |
|
MD5 | 1208a0805e5947c02f5f9cca44acede6 |
|
BLAKE2b-256 | c0dad22d9a9403099dd209d302bae9666dacf302a84c35da34fa7f4cc1189c92 |
Hashes for soxr-0.2.5a2-cp39-cp39-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5576bbc5ea4482ccb7a9a8f6db6a2ebbdd592774973c2e8d1c821ec3a9c3a753 |
|
MD5 | f22046d351b7af2bca00cb562874e517 |
|
BLAKE2b-256 | e633c7e362b0c4e81393ac2aa636a7433ebd9ff1c79da95a625374bfedf303f1 |
Hashes for soxr-0.2.5a2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c415e63296b85bf2982a6736e63c64a615c2f8e2deffc6f757946c60e81893dd |
|
MD5 | b5e3da11d464af7e61eb9aba45bada73 |
|
BLAKE2b-256 | 1b3db3baee1c4cc649cb8652676a25c1e3d6cb3c5906f27f3f94d76b2685d780 |
Hashes for soxr-0.2.5a2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbb4edbe6eb2c131aa4cb5a046a86833e5dc81cc4ab2b3b0602031a2f64763f7 |
|
MD5 | 4e6d63de5e4e9774c75cf3130e347e39 |
|
BLAKE2b-256 | 36d93ccab5d0c6060d323e58bae05ff18b66af89aa29949634e710c21e34bfd5 |
Hashes for soxr-0.2.5a2-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca43f3a954b8164a9985d516263a9295a8c9c99dab83aeab0d9cf4910cec4712 |
|
MD5 | 25851ef5636b5475c1685ce24ae7038f |
|
BLAKE2b-256 | 880134e44f19689167b743686093e86368b1706c6aff54ecb9e65e1b9eb3a3e8 |
Hashes for soxr-0.2.5a2-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | efda3dfc0a20ca92f0aa65e531923845fee31b2d332070a1a4f1c4edbc8b7f29 |
|
MD5 | b867e76dcb451c3e67cf9582e253ef9d |
|
BLAKE2b-256 | b0a564b7b3a50830a2501631feb689569ef466aea3dd83f58181074342936ca3 |
Hashes for soxr-0.2.5a2-cp38-cp38-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf37e5eca9107b5fe7ff8cc2892ae6e5859fefab4b6226b45715062730b77c4a |
|
MD5 | 1f0bdcb5ffa3d0ecd1cae1e41d0674fd |
|
BLAKE2b-256 | 31ae0d4c77e7f0746fa9881f55c8d8ce60e2374256275f55950cc66f576e9ea2 |
Hashes for soxr-0.2.5a2-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72053da9f35053f88051dba0a9d92b74eedb3d00b3bfa466aa1646ed69854856 |
|
MD5 | eaf112bc18ea3a4697176fdd04faaee8 |
|
BLAKE2b-256 | 8dba771e537bbc505ba797d3d32a5238dc676c7e04bafe425eb73b648c28d10d |
Hashes for soxr-0.2.5a2-cp38-cp38-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09427a668272e48d69746899e9938aefe92b7e8e18336252e2e7eac454064415 |
|
MD5 | 99a1bf8e11923f22889b9157b2004183 |
|
BLAKE2b-256 | 61674f93a8fc89691089b23a707fd6ca3d37343facd81c34aa58a528ddb53977 |
Hashes for soxr-0.2.5a2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f855b0f810f393988fd821cb78ad5b01587d1bb9ee16a04a3f7df0bb43e1753c |
|
MD5 | 70de8f28473381198c4d9b779996fce8 |
|
BLAKE2b-256 | c7f393c9218eaa9a4253d921defa50ba587b0e5dd7cac8481dbbcf19c7a6b2ec |
Hashes for soxr-0.2.5a2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca81bc2203269b172e324ae1f7103dc35725f9ed65c62f718b2404f43b12a1b5 |
|
MD5 | c533cf1ef7b49fdbcb3e703576188026 |
|
BLAKE2b-256 | 64312c893c5e4f1f094f3ca5b48ccfdd87316091a0448187d15ee1b8caf5be6c |
Hashes for soxr-0.2.5a2-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5383e9c58e85b837162de296c6d75be85b7a7014c7c438de1c815f2b5a954bff |
|
MD5 | c6959113b89c012b8c8611e96c6c13d8 |
|
BLAKE2b-256 | ebec78c8fe2ad8284285fef89e728df8cb2847e1f64e486825910babc8cd03e3 |
Hashes for soxr-0.2.5a2-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b5c64e0d589c155a005ba7bf728d31424bf81b7bb4ab6c8518072294b4dfa66 |
|
MD5 | eb91a8bce4b83aeec87ce052a89d1233 |
|
BLAKE2b-256 | 7ad1bb0c8363d0e9c2bad02a3fbb3d7899755f0c593c566298b79a52bcc5a9ba |
Hashes for soxr-0.2.5a2-cp37-cp37m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 359c20416e306a1a12fc21b7530877239b58ad26d47c6f0d541caee8a74afcf0 |
|
MD5 | 36c73d64176d33e602761dfe4a1f8a45 |
|
BLAKE2b-256 | 1bf780200819e215821c46614659ac8cc8678444011fdaa99aaf12e383e198c1 |
Hashes for soxr-0.2.5a2-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e811b384fe282e4391db2da64e520fb10ec210fe93890fbd090f1183a5d9ea6d |
|
MD5 | bbcee5cb318498d48ea9e7615d4c5e04 |
|
BLAKE2b-256 | e118eed8f1a80a4de3b37905fc9a3c2cf7a26ba47ee18a67b90fc7eab2d7bbd5 |
Hashes for soxr-0.2.5a2-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fa1d0e45f8f63ae1ca9b1ba332275acaac8285b1347eb986acba872d39fa02a |
|
MD5 | 7c60749414a3c700768249c88357ac33 |
|
BLAKE2b-256 | 8d334ecca04a58192c5d646189faf8ad80dedba39b6cc847ddad9e5812bea460 |
Hashes for soxr-0.2.5a2-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2d51076708f0c082a5cdbeb90eae344aee2a15720c615a2e841ab457d176eaf |
|
MD5 | c5ceadf216bba271f667c09a9a1a48e9 |
|
BLAKE2b-256 | 686406e7e0a0ed8109eaa4f9db8ee1054208e3f88d6688147259aa363bf3997c |
Hashes for soxr-0.2.5a2-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cfd80f5b610f1eb55b277f63f49387f7b2561b9fdfbd4b5c5e9adaad72e7d82f |
|
MD5 | 1085f5ab707d273fab3ba7ebdc9f6b14 |
|
BLAKE2b-256 | 983efc5cfc2f1dfee2032677d16f6b20ab6ca576d7c3264248a15919fd3c30ed |
Hashes for soxr-0.2.5a2-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff407aca8633b4d0bec69f2e5b042377f752a807072397d17d5e732d166b58b9 |
|
MD5 | d590583a76662e76382f127bd43ff275 |
|
BLAKE2b-256 | 981a0b7c5a1a4c6edcd4f6691d07b629bdf42ad84ef5c69c44d1012dab2c7d32 |
Hashes for soxr-0.2.5a2-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 616858e99431f63c3352f0cbe219b76ea690bb8b3db328031052ad5cb82713ef |
|
MD5 | 719f01a6d16449733055393dbaf4d306 |
|
BLAKE2b-256 | f6ac7c56abd4ddb000eeb490b50ad166d541e9c76d016cde20ff1208613085a7 |
Hashes for soxr-0.2.5a2-cp36-cp36m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ba931276a87f44edf2cad4ce57686e45fc4e38d8480ea09aaba8e0151843a31 |
|
MD5 | c6e0e353b1f4a16a0c5fc451416392c6 |
|
BLAKE2b-256 | 6616f873cd520a59a8cb0349963930e993867a58686e8d7ee3f08c21d189f91a |
Hashes for soxr-0.2.5a2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cefbe9e0305c46dc7853883752351a89af8c90014cf4e32670a457530e714f4a |
|
MD5 | 0d9b42a49d44663d21bd0752fb6e7341 |
|
BLAKE2b-256 | e0de856f4bb1f37926f9b9a383e725deba4f5315c086f5ad03b160c3b6dae592 |
Hashes for soxr-0.2.5a2-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f0874b5b0bfe16ce3dbe5563db80b04dae954ab7ae08a7ba8dcd32f04fe39ca |
|
MD5 | dd70e2f7d32915aba0f122673887d225 |
|
BLAKE2b-256 | f834ec27585e5c8d8fac5c2b6ab3477290623f6c5d3572c600bd9fb9c87fce45 |
Hashes for soxr-0.2.5a2-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80a16e4d173d492a6cb0242bb1b256d2a45977406e9ed34262751724b334385d |
|
MD5 | 8800df553d8d1c623c53e393825f6f20 |
|
BLAKE2b-256 | f2784353db4ce52a06003d593d008ad766bdde3dccd195987849d54d99966f7a |