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.5a1-pp37-pypy37_pp73-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eaae1b186280ee37dea62a5b582180801862a136449f95cbc70579681b6afbf9 |
|
MD5 | 32ef56843a90616e015afcbbff194bd3 |
|
BLAKE2b-256 | ecc25bff4ba221f2887b676e22808bb2fd159fc1c51afadac43398c0bcd557db |
Hashes for soxr-0.2.5a1-pp37-pypy37_pp73-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c906a68656c4df5915057455304ebd81d2d04f38ec39e6ed3765ba0bbd1b231c |
|
MD5 | 2dca4e143da49a50922395dc91d22641 |
|
BLAKE2b-256 | aa8d07116be4dfa439ae3870eee45438075e29c1687ed05d0fd8276bd8c76a7d |
Hashes for soxr-0.2.5a1-pp36-pypy36_pp73-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7787a0cce64cf04757833f65b7c7868709affec660211cf79ba3b7f6a4544ce |
|
MD5 | 0b001c4de20d72af9f97ef5b476ca212 |
|
BLAKE2b-256 | df4cf386f8e105d1c8d6324d8c78e9ddefec4875d53fbc78fd467bc2a222a1a0 |
Hashes for soxr-0.2.5a1-pp36-pypy36_pp73-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9d47f862f07a3cfd465fc19d2be93f862f5dfc56167cd2de14fb2da6b8272db |
|
MD5 | e0c708158dd83affbb2929a105214217 |
|
BLAKE2b-256 | 5cd3d28c26018571e0095a08d8c5be3699a0c8234cecdcaa23d2d2ec86e8fb15 |
Hashes for soxr-0.2.5a1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fbb14241fd9a12231693bb7f521a27c597fb23bd64ed790d36fefd58a59f5678 |
|
MD5 | 124db05ca927330626e40c7c9e8d5131 |
|
BLAKE2b-256 | 29dd5aa6f1de69efd5564b0f1e839abe941674a9fe051a77baede53ef4323acc |
Hashes for soxr-0.2.5a1-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ae85d4d19134e338b348bebc93c4ccb15bb01e3182cdd3febf002ee2db2071a |
|
MD5 | 17cc163c0528f6ac0db052a53856c55b |
|
BLAKE2b-256 | dc1e1c81945ca108e45ce75badd1026f30b373b74f4a2cbc6c0498c33104e130 |
Hashes for soxr-0.2.5a1-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b721d10748ae2a401b1ff0a93cd3df0f58e00cd4d933f307f4d965ca550f613b |
|
MD5 | 2000df4b293bb8f38008fac72771d28b |
|
BLAKE2b-256 | 88dff27941ae804b866606903e0a39c2fd58d7c1c034e4e194c00217335d5c84 |
Hashes for soxr-0.2.5a1-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4823e0d8940ec405bc111c913ef87fe87476e714f8355a0969f5a4c4642efec |
|
MD5 | d5f0facc202b02a47bc8d205aac5b223 |
|
BLAKE2b-256 | 995d20b24b342ebcd88f4863afe98e9f0d013d24a4ff46f86162c212c4545281 |
Hashes for soxr-0.2.5a1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95c63823ea60d37a84242165f009e37377812f8f98e96aff4aed45aae953877a |
|
MD5 | 79e79e407a080dfe70f1a85fb2694945 |
|
BLAKE2b-256 | 3070762c2cbb2a4043ef9e42940a997808682bd84fd7299bf746d1af5bc33584 |
Hashes for soxr-0.2.5a1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f41ba0073c55153eb355e1d02cbec5886a372a4be23a910cb6631fd86cc79b5 |
|
MD5 | d65083692448328812d7edb14abb69d3 |
|
BLAKE2b-256 | cd76521d30dd7f160bc01f1ec49b23b9cfc9e11b465d162788e27ff898e12241 |
Hashes for soxr-0.2.5a1-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37e90e6353c10446870faefd461f541dee8b95db08586110f62dd4abe79d7346 |
|
MD5 | 0d7e9aabe470654d091632b212af06e1 |
|
BLAKE2b-256 | 5ff84b546c69440a9d5f30f8fe9d8b76d074637e719a08cafa335b5aaf63894a |
Hashes for soxr-0.2.5a1-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70ffef28d074da11237943f138ee2dd9c2b6822b48dcdc5d56f0a4d28580b86d |
|
MD5 | 7cf3df41693ed8195b0ee4dec2adf5f1 |
|
BLAKE2b-256 | 1da60fad20bbe75b141ec125928256524314b9710834d7e74165af1a0681c32a |
Hashes for soxr-0.2.5a1-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93e88de14fcfff62e0f32f35396299d52eb36cf7c63eb2db8f30af97c64f57ef |
|
MD5 | e79dbd40e9213c05af2d977d53e65cb6 |
|
BLAKE2b-256 | 60606de96cf3ddc3e2cf526bd4782dab459aeafad7ee227b08672fb119959a0d |
Hashes for soxr-0.2.5a1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 877a534c4da269e41e5394cc08d8705869e3443a7514a5a9cd551327400e6817 |
|
MD5 | fb4d91fa73967949f11a22cd15883327 |
|
BLAKE2b-256 | e35211f022294106e95616a773c343ddbf6ead1ffda6c7375b1d4bd044c855db |
Hashes for soxr-0.2.5a1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d68049f3387ed32694ec72042ad0d38eb8c72d60e8ebee00105b1d992e2b8508 |
|
MD5 | 1eaafdafe2d625bc7e1dd7e49f018554 |
|
BLAKE2b-256 | 4d0294342c3532f5dc62a1747e11598cbedfe0bfbc40a42bdbb4358bea8710cd |
Hashes for soxr-0.2.5a1-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f25e6699548290fbb9584be518d7b85fdb7a8e4ff4efe7287f76bee8e7c84cc |
|
MD5 | 90112a92498a45d288dc651fa5478308 |
|
BLAKE2b-256 | 5e64d7d56dc897b39a48074235225538ed6162935d089e8879ab52e9ae343b65 |
Hashes for soxr-0.2.5a1-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7df46d6f2e6fc9a9d7c14fad4d118e5e8e803292648307f44aed5cdd00ff0cc0 |
|
MD5 | fdbc8fce9e74a90a1fcad832fb663ab8 |
|
BLAKE2b-256 | 2dc404407d8233d02448f10bd5bbbe010d8642834cee6a0b2edeb0096ec92c83 |
Hashes for soxr-0.2.5a1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a98e672f0150500e2b77c3cd59ccf76e41168d1809c359fcc25194d6042300f1 |
|
MD5 | ca12d0679bf08126503772351016e445 |
|
BLAKE2b-256 | 5f6d0fc04dd745be4d630efaa6a804085f06283bd435af69e3dc1c739479e7b2 |
Hashes for soxr-0.2.5a1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 122e0e76072b0e6f183650a3ed6a2aff84578ede72303124631eaa1ff0bd355f |
|
MD5 | f2be24dfa29fe2102662df02ab58c350 |
|
BLAKE2b-256 | 435927d30063e88d666aadefb54299c0d5fe95391173e3119a00cff6f81950a1 |
Hashes for soxr-0.2.5a1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5048462f768c7f671721fe036b027bb52abc28f8c582e0fc2dfff41a4c2398f8 |
|
MD5 | 16c8244f0e7d65d02c2431ccebe0de07 |
|
BLAKE2b-256 | b4988b4547818500af0c8acdb2cb2f315dfe1391de320428c24382a9aee49230 |
Hashes for soxr-0.2.5a1-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7f277695eabb95110750fab18b9c51ab110a01a7954c29a75f3d8a567f2fc62 |
|
MD5 | c7d8bc3cc1bbb26f380d92653b44cbb5 |
|
BLAKE2b-256 | 36617d1e85d03ae2ae787b6822f47d822068402ad867cc7156627ce38da1b476 |
Hashes for soxr-0.2.5a1-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbbb689139a33dc9027fcac84c70ab847d8e2780ac8e272f53ad717dd6876ad3 |
|
MD5 | eafbfd83f4212cefe0b0d8c637228ecf |
|
BLAKE2b-256 | e69745ffda2ea1fc3864631e45cf129ec4564c8154888d85dcd81fcbf44e557d |
Hashes for soxr-0.2.5a1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc3a505cb321d1e857da18ec3ed4001156b0bdb3b6a65773195a64e9ce227141 |
|
MD5 | 13bcc2b901a62f4774a566b3cea2989c |
|
BLAKE2b-256 | 0e07f11650c0723731ff22483307f43ea672ed0bb6618f0a73c8d164e0e52189 |
Hashes for soxr-0.2.5a1-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4e8618d4b79ef84ff54d8fbaed42babe2f62b06abbad4e9968d06507ac842b5 |
|
MD5 | 0fa22b8c9cd55c86d1e23772d981232c |
|
BLAKE2b-256 | 85ba9080fd1c1eb148450004d88cfb9b683df7d7fbc88c0a7a7bf785ff11a2ba |