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/
Keywords: Resampler, Audio resampling, Samplerate conversion, DSP(Digital Signal Processing)
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.
in Conda environment
conda install -c conda-forge soxr-python
Note: Conda packge name is soxr-python
, not python-soxr.
Basic usage
import soxr
y = soxr.resample(
x, # input array – mono(1D) or multi-channel(2D of [frame, channel])
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, # input aray – mono(1D) or multi-channel(2D of [frame, channel])
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 resamplers for Python.
https://colab.research.google.com/drive/1_xYUs00VWYOAXShB85W1MFWaUjGHfO4K?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) | 10.8 |
torchaudio | 13.8 |
soxr (VHQ) | 14.5 |
scipy.signal.resample | 21.3 |
lilfilter | 24.7 |
julius | 31 |
resampy (kaiser_fast) | 108 |
samplerate (sinc_medium) | 223 |
resampy (kaiser_best) | 310 |
samplerate (sinc_best) | 794 |
Technical detail
For technical details behind resampler, see libsoxr docs.
- https://sourceforge.net/p/soxr/wiki/Home/
- http://sox.sourceforge.net/SoX/Resampling (archive)
- https://sourceforge.net/p/soxr/code/ci/master/tree/src/soxr.h
Python-SoXR uses modified version of libsoxr. See changes here.
These changes does not apply to dynamic linked builds. (e.g. conda-forge build)
To check the version of libsoxr, use soxr.__libsoxr_version__
.
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.5.0rc1-cp312-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6c12be766afac563b94c4a48fbfb617be0bcbcc4f982f1e83894f34b74ebf47 |
|
MD5 | 4164367ac3f5795f3de9168558d0ec89 |
|
BLAKE2b-256 | 76350b62c7cb1f0b073e13bcbfa343176ad29d48162d5f7277a1f68a9564bf7f |
Hashes for soxr-0.5.0rc1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f51ff7f1ba89d798aac247687a6a883e30b83ec2e60329ae5a99c5f54b93475 |
|
MD5 | 8ac4d884332b20629e358f932cbea1f2 |
|
BLAKE2b-256 | 0f88bd831218efeb74967f429059a5d9cde8daea95d3631ae00c99acaad6f78e |
Hashes for soxr-0.5.0rc1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99cd589e73ff2308c44833c6d1900fdaf69774c81fa57259de2486d20f92be08 |
|
MD5 | 4c3f1a06bc09051c9039d6240bbe63bc |
|
BLAKE2b-256 | eaf36aef13ddf0fe5f071f22eea2c22e90e79001d55577d5712a040c483c750e |
Hashes for soxr-0.5.0rc1-cp312-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3bcfaafdb4919740985435aa2b6558837b12cb05e7a142094fa6df5463e03e62 |
|
MD5 | df6bb7815685fcc5721e10f6e8f34be8 |
|
BLAKE2b-256 | fea9a6e624e3558ff68e2e554b71abec1f3472cf5c34c1c3848eeb230b529a25 |
Hashes for soxr-0.5.0rc1-cp312-abi3-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b55a7c517eb24609fd650619ff17e7602000f73b84581b0893b1d058970e424e |
|
MD5 | 874e9122a47ede126f58e251a49c78b5 |
|
BLAKE2b-256 | 6feefb8318315d5c134bef2f03d83dce12ab4a1aca12ed722d2a2d1436d52a20 |
Hashes for soxr-0.5.0rc1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08f41ed05cf46998077458775dcbb05bd7940142a889ab25f6f8fb3216f08d56 |
|
MD5 | 277dd496a0325e41518cd7ba628ace31 |
|
BLAKE2b-256 | 3fceab6982f1d1573e1354010dc3df8afb7ca3f5eaaf090d45251bf257bd7e1a |
Hashes for soxr-0.5.0rc1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d81b0a7322fa6a226d2da8822e81993b1cd1cff2c8c172cea64a35ed7faccc2 |
|
MD5 | 8b52722cb0ad39b316530616a2a352bf |
|
BLAKE2b-256 | 9fd495a2635957a5b1be56ad084e05d89750c19ad8a2dab1a0cf1b5700299361 |
Hashes for soxr-0.5.0rc1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e52b0bdf4301b09f8ea8f084d3111b10ac6b9d1a7e0f89d080ef11ee9e47a7b |
|
MD5 | b6925a8c6739b78f4c5d084b10fc6e05 |
|
BLAKE2b-256 | fc05b04b333b03f8818e87a14ad4f917f96816e1ead0a0b22353951594a26fcd |
Hashes for soxr-0.5.0rc1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71b37f5002bd3fb78d0669df7851256b277f2024e349365304ccbc8d3316fff6 |
|
MD5 | 1e4e7cdce50a4e30ee7385f73dd8bafc |
|
BLAKE2b-256 | f027a8455b6e3fb6ff04eb61af3d29a52d6b2e0023473308de25ab39250ead68 |
Hashes for soxr-0.5.0rc1-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2835c038f7517e733abe4d2a508b877c24e5208def613022ddf728f0c71492f |
|
MD5 | 4a84b8497a020888efdce8957a6fac23 |
|
BLAKE2b-256 | 7004ae24e2674b6c34e04e498ee1631fd074c6af85ef74be6e5f94acb369fd11 |
Hashes for soxr-0.5.0rc1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7daedf7ac5a7b1f6d1f6289b251d52bc07b54fd898878a102e84735253795673 |
|
MD5 | 71de0d99414ff5a710ba74397ec543fa |
|
BLAKE2b-256 | 232669aba192bc9d8df031d298141824fed8fbd58f734ab7565567ddda22c63a |
Hashes for soxr-0.5.0rc1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1004705abc440f50b11faebe1939cc79e409bb04e89a242d8748db13eb6b1927 |
|
MD5 | 4a9e43b71e17ed1fee4b7076c3f74dbc |
|
BLAKE2b-256 | 83e42b04aca0c7ab6da977cb63cb17f36318114ab1a4827c6c5d43c0d793ea01 |
Hashes for soxr-0.5.0rc1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a9593669bb44c0c02eddcc3ad040ea44b0195f9cf5d039ea13bca0bfcda2a59 |
|
MD5 | ca73eb58662c3e8a3934eb4f221f4a99 |
|
BLAKE2b-256 | b9de346e59db3421f324ce91562e3106c88b3d3cf1b611d4bc4ca55f97613c02 |
Hashes for soxr-0.5.0rc1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0315e6d498003bf2716c11fbb98be26252d938439f63982b338671eb3c39ac10 |
|
MD5 | 7a8ccc3c0104483b64d00f0b4ae196b9 |
|
BLAKE2b-256 | b055159a517e6a72a95ffaf088eb37222cdc7865f8b5b9a33f9e5c09e822b5c8 |
Hashes for soxr-0.5.0rc1-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4a2d8c5201417b2f8eecd4af5113fc33f7ddf771f3110e068e714136c081c23 |
|
MD5 | 1a92bbe262a4b07ebe8b264dd4fa0f64 |
|
BLAKE2b-256 | b2bab1ed69203aac2cd1d825b4da47a42bf0b2600118371b37b205b23351a816 |
Hashes for soxr-0.5.0rc1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8e815558a468df2912c2b93afacd6620e47aeabf708f2a020fadb6cc0bdd736 |
|
MD5 | 4c896baba8ff2254e5ce3220b0dad6b5 |
|
BLAKE2b-256 | 783fb09ed389fc9cb95fe910df52e463d9b6645e905eac03e1819a5caf43185e |
Hashes for soxr-0.5.0rc1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d04665e68937f1f4855dfe5c84c36b8426b1a8d41145efc32f94ab850677c9bc |
|
MD5 | df10b2f4e2623dbd157d23df3b79350f |
|
BLAKE2b-256 | e4c941fff531bd2b955ef150fb39175391931fb346e54b31c2e4cb64435d1ef9 |
Hashes for soxr-0.5.0rc1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03f8008a187683fed7cc648b4e71c925009a23463282a5b653bba00dc57d5133 |
|
MD5 | 9e34e30c1fbd9ca1e7c6514dd0ea90ca |
|
BLAKE2b-256 | 0a4a0f6d59c364963efd8149b43be8295da642017dc52ae0faf48a7b57e236a4 |
Hashes for soxr-0.5.0rc1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0eed6a7adcc10c85946c4a2032a536b7193b46b49016cb438f6eaad53e088223 |
|
MD5 | 5ac3976692f495c1eb9ad0fea9cbbeff |
|
BLAKE2b-256 | fc8c48b7c3b96848421c477880170b72cca4f3e4cec83f9e8c806d1517ed33c7 |
Hashes for soxr-0.5.0rc1-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a83945587b8b72d566fdea879dcb9bec6ee4e9f22a91e5d19494edad216ae8ac |
|
MD5 | aa7fb607d44517caaa6aa7d678ff1c91 |
|
BLAKE2b-256 | a846ac6c643be3096c51b51763f9274be59c26fd9b5ae29c9536421d767549db |