High quality, one-dimensional sample-rate conversion library
Project description
Python-SoXR
High quality, one-dimensional sample-rate conversion library for Python.
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=np.float32).
dtype should be one of float32, float64, int16, int32.
Output is numpy.ndarray with same ndim and dtype with 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 = np.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 |
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.2-pp37-pypy37_pp73-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4379b2b52586be8b56bfa932e79a189e6bb46362f8f4e10ce0d8ec49d01fe8bc |
|
MD5 | 408d982ca3919c70d620f0c9a2b9696d |
|
BLAKE2b-256 | 5da7ef5ae6f915d12acfc68a5a61dde9a2589067e6961fccb873efd522e69a7b |
Hashes for soxr-0.2.2-pp37-pypy37_pp73-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 485ba048f2ec3de37e746c088f225cb671944aa1e6ef4a490912ffb2a575168c |
|
MD5 | 2cef9e5b3afd1d09d5d5e17f5bbcfe42 |
|
BLAKE2b-256 | f9a8d8ca308358e6bcb7252bb99b968d7d9625e0e5f2bf4256926549d5455c39 |
Hashes for soxr-0.2.2-pp36-pypy36_pp73-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7bd194945f7ea6d751aa8bbc6da28c996b9281051429184169a51fcc590e82f3 |
|
MD5 | 8b9a04b32ea698836b488188abdb85df |
|
BLAKE2b-256 | 080d5da0232d6337a83aacdd9ac14d518d4fc11a44d4dd93c640dfb5a4c9e694 |
Hashes for soxr-0.2.2-pp36-pypy36_pp73-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2cecf478ef7535a7d6d0ee92c2167fcc3187dc32e1bbdb6d23f3d8616e1a7a28 |
|
MD5 | bd53c0f2a4fba8fb49f080032326d0a8 |
|
BLAKE2b-256 | 59c197bb543cb337ca40bc98e04db769b25ed85ff015244db116daf08ad6f6fd |
Hashes for soxr-0.2.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e70d6bfe88bd4e903a5f371b8920bddb840c796cb32070c5d60bff292c36c492 |
|
MD5 | 3c8fd1f331d6d194037c2326923e88cb |
|
BLAKE2b-256 | a5c4b0e56a20724030c3fd9147f3c9830d2e5e85d96a39aa7cfad7f425ae9217 |
Hashes for soxr-0.2.2-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2efa84d4013e1894721c4fb90b7a2381671195a01c9898d90c78df485e8fa1b4 |
|
MD5 | ae0f059b37e5b90e235bae1476505c14 |
|
BLAKE2b-256 | cd1e2ba635fa4cf9422aa915100a683f8c4855bf2c12d4c4ab5d071b2e7f09b8 |
Hashes for soxr-0.2.2-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cecff590a3fc3a952dbcdc8a4e5522ca887a83f14d954f25c741a6210b7dea5 |
|
MD5 | ff553b3b4b438e0aac92194294299edb |
|
BLAKE2b-256 | 0b6a7cbede600a4f1d67de27c64555b8e02d3c2438f2e9a6d1a3faed77c06046 |
Hashes for soxr-0.2.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b071934bc9027d86c873e8079fde8b0becc959177ca8f6d6930fd5f31715d897 |
|
MD5 | f987d6477eadfe79bd16668c10461866 |
|
BLAKE2b-256 | 91fe65810fafec924bbb3932bbf15ef85e51ab5c1530f655827ac1bf3d9c9dcf |
Hashes for soxr-0.2.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7685749a21aab7f23aa27fe509db0069e855c51dce4a8a53fbef5aad4fb834ea |
|
MD5 | 058556ef8ae5cbaa4b1e7e1568630906 |
|
BLAKE2b-256 | cf73aae1848579fc493875662e570c607567e2cae0e15ca39a544cb6ed493fc9 |
Hashes for soxr-0.2.2-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb635e83ff655317a74f68bff76a7c3d9d5a4682a3283f64548bbaa05eae4d12 |
|
MD5 | ecf18e25d8a8d9ee5abddc53773fb0a7 |
|
BLAKE2b-256 | 34f79954907569f1fd8ad1dd6a4e2c58afb80553d56e0cce2d6af4a6b9d4d160 |
Hashes for soxr-0.2.2-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c975af988c80574eb26ef0c8112a63dfa3c7541065d8a49b88e55b7d3bc2ebcb |
|
MD5 | c7264725ad3a5e3a248e6daa0eac7928 |
|
BLAKE2b-256 | 9d3a271f8a70dc42b3358db8163457d26a37a54cf9e03d8b58326367b43544ec |
Hashes for soxr-0.2.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8f613de4a6fa6adc0d113fd953a5abe1887f79bde4b2fd1df905ba88b62c84b |
|
MD5 | ac1fd9977c98089d932321848b995a59 |
|
BLAKE2b-256 | c0dd3dfab4b76b82e81d0febf91cf4bbb2247c8108947bda846c974cb113f559 |
Hashes for soxr-0.2.2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4ca28086ac4ed536dd9eb6892c06dcf9dcff923fad202dcc03c4911fff84e36 |
|
MD5 | 8f40260f2ca7a0c1545d01aaa0ffcb3b |
|
BLAKE2b-256 | 20d9409ce5918e3719caa8f9b41b3d5c03fdf098e22733260b33bc74c32d50ec |
Hashes for soxr-0.2.2-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4bb422eb27b21b8b596b1ddae6f50343c00b0601761515320290ce866bad242 |
|
MD5 | 3c3066ec1f2ccb3639712c8808bf49b3 |
|
BLAKE2b-256 | 3f1a9e315d1e95483276a9cb5f5f38602d03274357db70f3b4574c986c7ce305 |
Hashes for soxr-0.2.2-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 575e77843ba638e5dd1df105bfc3b0ee3ed91e8652e4efca7ae892d043b91232 |
|
MD5 | 977332585e53e5577e463f9d1213975e |
|
BLAKE2b-256 | fa937218234a50dfe743fb620949d202ccb04c621e0736a068b9197b8287a572 |
Hashes for soxr-0.2.2-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6107f5d8fa10c73fe1b13e26c7b70bc0c16b21f15bb66e7814ed90363986f33 |
|
MD5 | 2a8bd8a021fc0be8bccdc584862ab39b |
|
BLAKE2b-256 | 7f469b5fb99e053fdbfa3b7389aa9a283ef4fd220e8cb02eaec06381b9a55c24 |
Hashes for soxr-0.2.2-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb51e605947da0e504ac95e2adc8e4c8ad68fe8c476b9c0725ced6474f3d0d39 |
|
MD5 | f8fe098803dffa397199c83c84d92e16 |
|
BLAKE2b-256 | 7645a0f6068d5b5077c79ab6134b3ec2ee4024214a06cb526e1305b903f55704 |
Hashes for soxr-0.2.2-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5500b2f8b5f3d3bb7134849d1999876ee8b3e12a0c6e7c812c8bb4208ff5977 |
|
MD5 | ad7647667701fbccc7342f18a2a8bfdc |
|
BLAKE2b-256 | 6f07fd1d2de947711b232d894989d46a9b07a182cf7381d0114238e43523ae92 |
Hashes for soxr-0.2.2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd7f64757bdab9700f4bf511b8ccf24c220dc51c732e91f97b532a1929f49e66 |
|
MD5 | aeb6d43ae1d3c331c57b4a09c66584b2 |
|
BLAKE2b-256 | c4a25f8a11959f7ffddd1143c3b16016e2020e5b17b39535836385293482252f |
Hashes for soxr-0.2.2-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b80ccb53427fced9f66f350277f28a498875218a32446588b3a2bdbbb36ff84d |
|
MD5 | b43c414e1d706b8acdc99c0ef2ac4136 |
|
BLAKE2b-256 | 30843c6987784adc00b991119875ed30fb931daf7bfd9e03234f3693d40e611b |