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.4-pp37-pypy37_pp73-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e02105dd843f757c0d87e30191fa82efd11d630f2fa8e845ad5927cd9208b12d |
|
MD5 | 53457cd8ba848c1a9fb7e964cc0e9be1 |
|
BLAKE2b-256 | c2d1d91637a6758c9d669a9a1df2420bfc028b2e911d297b860d4e381a92956f |
Hashes for soxr-0.2.4-pp37-pypy37_pp73-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f6470afbfe8148d8bee22adc4f5446b2d42ea45b1528dfd9d3e1d98df89cc42 |
|
MD5 | 6ffe489dbafac3ee1e8c98b22834eccc |
|
BLAKE2b-256 | 73c29fb7784543cf4c11782a89ec9c28c5028bdc823ce44af9665dcfaf71ebb4 |
Hashes for soxr-0.2.4-pp36-pypy36_pp73-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fc4368ad93ffa6062c1298d50477ca48566aabab74a876c829bbbaf79ad984d |
|
MD5 | 9e61db2088fadafd67bbe755c42a8de4 |
|
BLAKE2b-256 | 303d68f8804e2c61e7086c88006d42c06b56ea2e12a94e2b4b9104d2b52a881f |
Hashes for soxr-0.2.4-pp36-pypy36_pp73-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c30ef13f11383ba8b7633ce7c93b9f93fd3626a4048a4aba92adf6dfc30ab2a |
|
MD5 | 7e6fde2f4116c5bcde1127c2e610dc0a |
|
BLAKE2b-256 | 990c2d44404d91abd170eb3cbfb615071db34ad8dccd3326936fb95edecf6f46 |
Hashes for soxr-0.2.4-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9151c275553318596d0c103a44096071a21bc8b6ca59dbd588e911c92d855cc |
|
MD5 | 5d925bd90a6bc09a5dfaa54f129330b2 |
|
BLAKE2b-256 | 8d3ca52e79d80914f86d7b4da396a283b3604855f507a2779b279b6a585c2e3d |
Hashes for soxr-0.2.4-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 669dcf329bc1853952f3c20aac9460474b119749f81f36b7eeb47111140ba510 |
|
MD5 | 121bcecda52f058a4cd916298277fd22 |
|
BLAKE2b-256 | 27dccdd0d29b05000db7915e3fd094487a13b0becb8643cee5d030546f45f2e2 |
Hashes for soxr-0.2.4-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3caeaef98a52556733d81ee2a44d5ef5695f2b9356ca3bc91d67ac32ffa1b46 |
|
MD5 | a85ea5aa84c10cf083d02876607a2552 |
|
BLAKE2b-256 | 45e1cdeca7b184a30b3e72bcc0c67c7b9eeb840446eff4ac861b738db1c04b68 |
Hashes for soxr-0.2.4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 403d88b4637884308424971dd02fcc776301e978ccda1774a08ebb88e0cc8189 |
|
MD5 | d1bd23b5c276abf941dfdb2f4f52ef59 |
|
BLAKE2b-256 | c5661cdab52abb376f6ef59b8f26f074b95a5956a87c74b8a43404b2cede8dfe |
Hashes for soxr-0.2.4-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fcaa1b5028c94b0f5ba76bde95ccdfa38e2bd494ec975bb9ce16b1b3a17be601 |
|
MD5 | 77fcc4fb1e4ec2512d67dab128edafd4 |
|
BLAKE2b-256 | 6f434e20cb36cc3d451411d01b03b53dbbd6eb9a536ed30f2359f4104813d8f9 |
Hashes for soxr-0.2.4-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85fee99afafeb6f2dd2d77d7debf35ab54a967134ebc4a6bb1bf4735ac2a070b |
|
MD5 | 10b57dc69e62b21dd3052d9ac5702be0 |
|
BLAKE2b-256 | b34e7c857f8ad6d92916fb62a5d01bd110792be0f4b83e5d05da39cabc1014da |
Hashes for soxr-0.2.4-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4d23ae7a54bb8c56f13b6162d6395e77de2d7da46923fed2c03a14891816b7e |
|
MD5 | b07fe296d8e5dfba7c77577a6ffeb285 |
|
BLAKE2b-256 | 479142a276a1d064e93d1ee5d6224e5eab30390555375eadbf5ccbf969560c42 |
Hashes for soxr-0.2.4-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f042b2d4be32268d6bd41e757d76fa09e3558c4fdeddf31a86b7811c7e4820a0 |
|
MD5 | e8d45107bc90dcab82f1623a96616d60 |
|
BLAKE2b-256 | ca345966420b04958ab07c5be8891cee4199863054faf6e903de94813ea1b543 |
Hashes for soxr-0.2.4-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04e329db530536eae51544f0e9e8d85663cca382e0218250ba84aedb89fd784b |
|
MD5 | c2f1cae7e8162e16dd6691fe65ec63c1 |
|
BLAKE2b-256 | bb037ef13b0436444d49923ebefa35db5739f203d28f9e4d4d2eb1f549f596e0 |
Hashes for soxr-0.2.4-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18155b5e7215bdfef3d01405b6a3a3d607a775dd3657c4abd27da4cc2b96f907 |
|
MD5 | 997eae5137e4293b7f1f64922530cd40 |
|
BLAKE2b-256 | 79c7b2a243dc2945879ce3a1da31488719bdeff1c80ab4d0ca857c36a00da55b |
Hashes for soxr-0.2.4-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bedd3245415caab5c15e0fddcface468c3cdc0005bceebf12743aa0af7de2912 |
|
MD5 | 73d79b9a4a060b632d63607d53deec6b |
|
BLAKE2b-256 | 0b88b8c5b7fc7d171652c04d52a11204bcf604f4b456bed835c622d2c5eb474f |
Hashes for soxr-0.2.4-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb38ed30dd6f2522c433ef7fbaf1c7d517083da0a142ce8d379ae63c8f73ae84 |
|
MD5 | df305cf26017eec320682a5c7fcb0f61 |
|
BLAKE2b-256 | 4c791dbebeca1763d77eea6eee1b17389ee85d80ab09170e3b756120582a39f3 |
Hashes for soxr-0.2.4-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b90ec93be7ec5085eceb4defef117b4b4b0b8d34512927341bd9eec0843384b |
|
MD5 | 257594dde77d214ea7a5d9fe1f22b888 |
|
BLAKE2b-256 | ee6cfbe4b5510713aa26fc5759f39bede19d7de813eb8e2e9af44c42a2a60e63 |
Hashes for soxr-0.2.4-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ac459024604b82c14f7cccd968b131c84fd338dcca9c9104dbd5556fa221ef9 |
|
MD5 | 925408cff451a6220acecb7832080529 |
|
BLAKE2b-256 | 28337cf45b3e73937105b279648974d3280055ce4a5e3fb325e571061b7c626f |
Hashes for soxr-0.2.4-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 865d97157a176b38d8c61cc95ef5cb8c8719a10c03e7f6f9606093bce3458e3a |
|
MD5 | c9f364be079b681917fea47ce0004a71 |
|
BLAKE2b-256 | 5cf06cf317f73d0a75c0f6d0d1686252ca018cb39a92e2bdd8f9c4cfb94ccd7c |
Hashes for soxr-0.2.4-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d742ea189a299d14584cb0793b4333396297d8ef8d4d2fcb3c32f70c53eb8ed |
|
MD5 | 331a35efc0041e9ac9419238b255f134 |
|
BLAKE2b-256 | 47d1b8b746a9847321e8481ad6a505ccc04ff7a2e073a7a026260712b36ca835 |