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 package comes with modified version of libsoxr. See changes here.
These changes do 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.0-cp312-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b932e1c9e1d292b2e53516cd87078e70be23cdd770747fd0e703407fd382c895 |
|
MD5 | 30644f65e7b4830478e0123b6166d896 |
|
BLAKE2b-256 | 2c00883331d3a0b7c0b339acc55c9105d6dfc03ef756266464d201e9628b1b6e |
Hashes for soxr-0.5.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ca1ef9316f57bd34ba259e494272c1a8b4f660c9e61c0b9c20e65d0771241c6 |
|
MD5 | 99bc66311a9b71b8aef6d52f205ace72 |
|
BLAKE2b-256 | 730ac022b61716f475e323d26c1d4c805ce14248eacad692705eebf032e80f85 |
Hashes for soxr-0.5.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 897670b5f6717de33055267f1c43dd6dd5e2091c0a583ce068ccba443629580c |
|
MD5 | 5bb0f26b63164611d3125ea89e837592 |
|
BLAKE2b-256 | 0aabbf61ff605fcf51c795838a4eee12383213eccb4ed4ed4cd625301e70b937 |
Hashes for soxr-0.5.0-cp312-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 056e12a7a894a941cb4c60a046921d8e1d67aae49c2cc43ffde17f40729b773a |
|
MD5 | f9fc04549472d59bcc7b6d65b7cf74d0 |
|
BLAKE2b-256 | 0be6011d0b9f4517d4b6b0e604adba8f3dbdffff04c8b1edce5202c8b4632cae |
Hashes for soxr-0.5.0-cp312-abi3-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9401a4c950504e7d64e848edeea8e0540a435a9ddae65f0936420d9a004cfd1c |
|
MD5 | 9e86fac8e5f9a022b272e85040b4f99a |
|
BLAKE2b-256 | ebe5f3cdc6beff1e395278e986de035a98eabc47a00a0076626faafa0c978996 |
Hashes for soxr-0.5.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07888300832c5879b52360660e593ccceb2c5a83936ffaf578c9f6af13ad5ee6 |
|
MD5 | db59d89e4667ee187b2851a7d86310dd |
|
BLAKE2b-256 | 3f0d03f9e4b8fc4d65c9f54ee29cd8768cdcaaebf71deb3273eea8e5734ac30a |
Hashes for soxr-0.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9eec55dd200b05906563f7a6cfd26dbebe90250bd8ea32cd985356ff723ea60d |
|
MD5 | 2ac4addaa7a312984137ed81d4d1a0c0 |
|
BLAKE2b-256 | 0cb556a922df925fb87bc79b470a8b2176f2b312b0ffb7fa7e54205044d986b4 |
Hashes for soxr-0.5.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5127ce98ef9b891ed54470fca2689effe1adc1591d525aae566282f306b467fe |
|
MD5 | deed8003a0ebe119c4aebdd87bb77c64 |
|
BLAKE2b-256 | 2382039a284fddd1d7a76dae004689d2fadb35584d25d5243467423cc5dfff9c |
Hashes for soxr-0.5.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13d5fcaf4f55901f8c2774b38ad703f1078412e9a1a6a576a089b71e0fd9cd80 |
|
MD5 | 97860bd38428c849dcf26b979b8458e9 |
|
BLAKE2b-256 | a545bc44265a7e902daee74db14d374242de86b4327ae73264230ab126dd9d7a |
Hashes for soxr-0.5.0-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6dede9d59b7dcc594df807d559a0442a3534063b90ed6810a14af89d8da32580 |
|
MD5 | 2eb9217a03cac6a30c8a063847cf59f3 |
|
BLAKE2b-256 | e16858469918bab551e7eb35d9b39887fe462fc68b135ba1b48e9ad241e4f8e0 |
Hashes for soxr-0.5.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a17bbc5b78e8b741b250a4b0d3ba69b3e689faec2e135c211c05e86ab5d99380 |
|
MD5 | 619aaf4f31e18337956393d06ec7857a |
|
BLAKE2b-256 | beb6c701d2806184ccbcb66ad44ab6cece57dad7be5f74d244b9f4b403430896 |
Hashes for soxr-0.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a25ebf13ca566b0e3861388172171c5151723fb7a25e02d2bb4cbfbb2f6faced |
|
MD5 | 9dab4f68f552aec11bba766903d1b97e |
|
BLAKE2b-256 | 2b708000e5af915991fa086ce1a7492e370e290c4abea3b42adf4d7f775eb255 |
Hashes for soxr-0.5.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9224265df015fe6957f92108da845f5091c154d8b98029f3385b682f4cb7d4bc |
|
MD5 | 7b032f876f4761f2d5218c74203327cd |
|
BLAKE2b-256 | acfd1e1b3b74f2b7ff4d6ef2158e60fc456fdd7f378ae78242463a03c1f60cd6 |
Hashes for soxr-0.5.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b50f54ec89f9c0d14321eac6c8b36b3aa0839b6c79c9daa35ff6de8ca00b0513 |
|
MD5 | 73bda2732caa57a9a8cd77596361ab9b |
|
BLAKE2b-256 | efefa6c92709d317dc556f8c13ebaae87ded5fd7ac90ee913cf3e0ec8b36ebe8 |
Hashes for soxr-0.5.0-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7ab4737974961fdd40bbba6ff0f3d230757c5f0db799191c4a9f2b139871a59 |
|
MD5 | 0fe09e8ac82b8b3866c6bcf5157d2647 |
|
BLAKE2b-256 | 8dfcac518212d1cfa4c00be8988933672cdc0f343c1451e96097f5605c379f4a |
Hashes for soxr-0.5.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e74d5ff751257fc221b468143fd61a8ea39eac2d8a4c34231c09604bd6ead1e5 |
|
MD5 | 22350a4a403a535c7c2bd51e1d6049fb |
|
BLAKE2b-256 | 4f57f3f9abe5e2c6450fb7996a2f688dd83ba4f65a431210b01d628589ab2ef2 |
Hashes for soxr-0.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb586a11ec8259ce79db9cc914a186e404a167eacf72b942c73556e45b6156ab |
|
MD5 | 516664bccc8a39214d99d7ddb759198a |
|
BLAKE2b-256 | 9f26bcc790c55ec24ccfc05ecb9c1fee5d99058ae408e0b9054fd75dc8472b67 |
Hashes for soxr-0.5.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a4abdf956f01538e092e5e411f455bfd72cc8a501a7626b632e89f44d251270 |
|
MD5 | e02bd8b46347c625fff1a80b78be13e7 |
|
BLAKE2b-256 | 3b75fe0bef0489e0f74fabd000f7526f6fd78732ec54a5cfe63973b18aecb423 |
Hashes for soxr-0.5.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d615e69b9399229dba572a7b2079493b88ee75df2607dc5ce851b158ef617341 |
|
MD5 | 97fef114b7148c297f7ab4908ba46f5c |
|
BLAKE2b-256 | 5e6c67bfb384b428a85a5d6121d76dac06b103bf29020d2b8be0d95cafe27aa5 |
Hashes for soxr-0.5.0-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5b4054126e97988167d50387224a1b61a8db2eec7e8cbaa4412614f53b3d82c |
|
MD5 | 0e8ff370b449d34c05201d545c6f9cdb |
|
BLAKE2b-256 | d52f9529fcff09b2d1d414eb504210f182328eb9a3955296404bec9edb332305 |