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.3-pp37-pypy37_pp73-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d8454435282b875ebcef130d1a52669e609cf935dd6a451480d204f63791367 |
|
MD5 | 260d19dfe14453c82644fb1a00b66fd8 |
|
BLAKE2b-256 | 6a07f0766d3603aa33f563d8cc9e99c602b93424a1091661bcce7b2e05aa1bb6 |
Hashes for soxr-0.2.3-pp37-pypy37_pp73-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8babb59e257b82d872622e411d9f7f1c46dc64c1f42ed5a9e510d88576379de |
|
MD5 | 85d103fcf3bd7b6f3aff15c189c6cc43 |
|
BLAKE2b-256 | 83c1e17012cd96f40d28918f59f5d256d6416cc4008b6118beb731b7d766dd85 |
Hashes for soxr-0.2.3-pp36-pypy36_pp73-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78bda6eadd08083f376604be218f77032495865a530fee042ddad66da22fe823 |
|
MD5 | 075d21b97195d331e29589da5fb121b9 |
|
BLAKE2b-256 | 5273ec767d2e51c034ca523bb80e433a647ecd61cce1f5ea7aff81ce1cd964b7 |
Hashes for soxr-0.2.3-pp36-pypy36_pp73-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be39fd3b66aefaccfe56aa0ad1f03076d435273f3bb110c62212b9c93b396bd8 |
|
MD5 | dd4b7c9edd0cd4a2612bf6e791e6e530 |
|
BLAKE2b-256 | aa9dad3d3ed53e3a4d847f7aeab1be9e196bb47de08eeebb85ab4b7b409c8002 |
Hashes for soxr-0.2.3-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89bcecc165c9d3152214a6dc95c28b9dc76448a8743b2c20d6aaad65f1f549a6 |
|
MD5 | 89919363cc604c4606abb43e89feabcc |
|
BLAKE2b-256 | 9b346c90a13e9f1c39186332d01b5313e575a88a00561b9a848a2a18a8d4baec |
Hashes for soxr-0.2.3-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f91f9165432e04d011e1a71b6b78b1762a2498d3aecc2d217c4c057b6856b478 |
|
MD5 | c94957dd7728200d49cc1f1d82359855 |
|
BLAKE2b-256 | 84e7eb8d98333f47199957bbcd292ef5de73bcee8c7df866cfa321c52456bb45 |
Hashes for soxr-0.2.3-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74495e694aec12766dc8b3320724e9cac4a9537f8bfa8562827c2377009c9602 |
|
MD5 | dd5a6b025b5399203331f23f92319ea3 |
|
BLAKE2b-256 | 630407347f38dadd2006d74f4a6241190449c70c7391bdbeddf32e8a3bae62a8 |
Hashes for soxr-0.2.3-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9706d394bb292a5b2cb995d143318e26092bd1e60e4cf58906f2743f8daa3e84 |
|
MD5 | 46426cf94caf251cc15f7600b1166430 |
|
BLAKE2b-256 | 2ec4b4a78e8df9a926837cb49e6860701ccc1ddce5603f5fbde823c9c66e247a |
Hashes for soxr-0.2.3-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15fdbf4180b86c775117c0f6c9f0fb59ceea37f3d77e8bf46cc5cf18384afa5d |
|
MD5 | a2724edf3c1ca205e085a03632e8f77e |
|
BLAKE2b-256 | 59072448d27227d42c04d2558c57532f04b03e492c45760eafed2ed27386d11e |
Hashes for soxr-0.2.3-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f322f257f43677a479d4677632dcc33586be24945add66266dbcd5aa045541df |
|
MD5 | 2edd4cc2e6bde180af898d71f458405d |
|
BLAKE2b-256 | 34e86014f56128db2a094aae0e3cc76f504ad283e8c4e18fb849fe3cb5c42650 |
Hashes for soxr-0.2.3-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e467bcaffc40d7f03437d436fd6c3f02c852be2131f77833ee8c31b02cc8e25a |
|
MD5 | 98fad5ff0b620c1faaed1d44d11db8fd |
|
BLAKE2b-256 | a6a6808093aefa13125c3bf9ba9d2f289ee7171c41239b2ea613ad614f3ec430 |
Hashes for soxr-0.2.3-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 262b399a4baa6e8c16b01b35b149532c1a1b2af33540630b34513cf4370dce32 |
|
MD5 | 24ad9a7b9ad2784b7715c2bb323ba5c7 |
|
BLAKE2b-256 | c6ee4d46ef7b390286363c3be2c9d242c4a571b4364370f1c0946e8d36d81afe |
Hashes for soxr-0.2.3-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f6062c57acb720d33095a4d57825a17f4fb57c6da8b15864031470efdd65aa4 |
|
MD5 | 8379a6acc09b16970bb74233bdc6b633 |
|
BLAKE2b-256 | 0ee01393db543d980eab7d9eb41bbc54044038c3c725879eb70d515c46bdfe3a |
Hashes for soxr-0.2.3-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf0b93d7fa01a6dc2db4333c0e94509db11701e5b99ac911f98389d53d2eb2a4 |
|
MD5 | a6fa2b29d169a90487ae7c878fc19dcd |
|
BLAKE2b-256 | 04473202533dd170ebe76733d34650b43815b7dde98d94463206f6eba0de08c3 |
Hashes for soxr-0.2.3-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06250a27749e7c58f4bcd780843829c1e989ed72fb4c2b6c09ff3becf184d3bd |
|
MD5 | 763dbfc0122cc8b3ee441e70010197bd |
|
BLAKE2b-256 | 181d3c4d000cc20b6f8de512227fb8d6ed691aa40627e55bf5f6c1dd26ccaaec |
Hashes for soxr-0.2.3-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81943fe569ea3fe14d3fbc3dcf09bad1948dd1e787a21dd4fe641c81257fb285 |
|
MD5 | 4e384c4d26169e7f3926d94dba8f1057 |
|
BLAKE2b-256 | 10adca1ab9da6c8071c1845c209c3a3d4d26b2e39ad7cdd15cb5bbeda5b41f70 |
Hashes for soxr-0.2.3-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e04edb1e6e92bbbb162933336b2158fdba767dd2cdeae7a058f073be5532f34 |
|
MD5 | 559c4d21f4308d93968f09354e361015 |
|
BLAKE2b-256 | fefcc1dba9def3c75639b2545550736e8cdca08ffeb9a7d6865a32fcdeb7b726 |
Hashes for soxr-0.2.3-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1e52b3c3143ad12eb956d0fbd971b7b08b84addbbf67d93967123062ceb8a99 |
|
MD5 | c020c48ae3c056511d3e79f015850c86 |
|
BLAKE2b-256 | 9abc5cfddfa0c6f16cba39814e5e5930edd2cc930a96cbdcc08d819e30599f59 |
Hashes for soxr-0.2.3-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0edaa4150d487ba2602a9022c738c13fc3491818ce314cbd21632d337934100 |
|
MD5 | e5e22041c2f9fc137d4c110e752c3672 |
|
BLAKE2b-256 | 91d5bd1c2691e5ffbca709081ca3bc9ad8fb293ebe4db820da09d1a1f5a0ae51 |
Hashes for soxr-0.2.3-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31ed7ab4f8be48c4c883228704f3bc9bcc647fcb9a92df2dc08f243aceaaa908 |
|
MD5 | f7b961b682f0678b093445c9eee7dedd |
|
BLAKE2b-256 | 4b485c9bc8a49bca44ace5e45390fa1f445a47bdc9bc4dcb3228d64adc40d8fc |