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.5a4-pp37-pypy37_pp73-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9599bfb635fac99ced37f4ba37c85c62b54bfda4019159fc8482c6c72cc29450 |
|
MD5 | bb1988326a06ed42f415e17bf8c155ae |
|
BLAKE2b-256 | 48a96fc5aaa61ad167bb71687d82be3ba9bfbdefdc4b36e1b52baa9cc540e4d1 |
Hashes for soxr-0.2.5a4-pp37-pypy37_pp73-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 278f3362daa674eff5143e399b3498be53eb62856b09e0e872fc0f9fe930bfc5 |
|
MD5 | f4f47244c62b498e296fd7ee4cb9413e |
|
BLAKE2b-256 | 346a7475f84dc83ddab0defaf8709afda0a4968e360f122d596d7781e85c4b53 |
Hashes for soxr-0.2.5a4-pp36-pypy36_pp73-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 858694559efd8cb6b509c560434da912d4878d41629f7203ab79e18f6f6e80f9 |
|
MD5 | 40a53c796c8edcb473141b0c8dad0a22 |
|
BLAKE2b-256 | b878f18f553934909b2a8364083dd2755a5f9cf6de5efda3aeafd47f40f512ef |
Hashes for soxr-0.2.5a4-pp36-pypy36_pp73-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb0c3c0d1f1f97ff0b1fb973de29180cfc7afab7b7654e677d83e997ad82ea6f |
|
MD5 | 52f78920e161cc5301182786b264a9ac |
|
BLAKE2b-256 | 9bdc72d7fd04a750eb41f342e5c2d119cb6c73b4db01b283a5ce7ebfacb9eb3b |
Hashes for soxr-0.2.5a4-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8248dd96d1242f241c027cba8c38815c97dfa705d1b04d352caf26432f2ccf03 |
|
MD5 | 68f6788f991129ab22633d8053ed0e20 |
|
BLAKE2b-256 | 5ce1dd2f77f3a0c890a0d056d6817b83236cf7f624781471e8e5da8d58867200 |
Hashes for soxr-0.2.5a4-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe80998e890d72222aa061b69f17e3f1723c90f75c98388779917579ab7f4f67 |
|
MD5 | 97d4a10d374793ae665d3b6b769d5359 |
|
BLAKE2b-256 | 41bf7ca73ab616edabb76cf1f62da287d2778bfeb35e4c49f9356034df68c2e6 |
Hashes for soxr-0.2.5a4-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 640b5f2a618e05733c91f47b52a7a9b5ebe18dd329efdd9237f337acdb7c1f91 |
|
MD5 | d8e85f2a84d0333025999de4bc41e7e1 |
|
BLAKE2b-256 | bc2b92d330ea9d6a5efd88b0d6c46435641bd55a31fe17da69b423ce76385afd |
Hashes for soxr-0.2.5a4-cp39-cp39-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28ae3c67e4782573007466d9cae1c0bb4d7b05efef4bcdb2eb769d0096dee7eb |
|
MD5 | 50cf8db3a10b9ca183e6057e74cf85f3 |
|
BLAKE2b-256 | c2906f02bee2c985ec79cc73c283f49ed4bb95fbefe1c664e8eaee5ea7659c5f |
Hashes for soxr-0.2.5a4-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 620559008222e3370c94e5689826ee1e37871e9f544750d4226de4c9b2608fcb |
|
MD5 | cfa790931de2d3ae6940b13da0fbd541 |
|
BLAKE2b-256 | e3ac7c1ee1682653974d3a80eaa248265351901256db8bd0a08950c2111cc243 |
Hashes for soxr-0.2.5a4-cp39-cp39-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9d93e7fc7dc696e8ed5ac9bfd0a01d88e716c86e0d37d984178b13266d9cd0a |
|
MD5 | 8563b15562e5bdcc9e7efcb2145f8ef9 |
|
BLAKE2b-256 | 0ab3c1a5c57f3c690cbd72e763322fe44357d538a9136fa72b55f3a4b1df71ff |
Hashes for soxr-0.2.5a4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8166c6fb3edd4359ca836dbb0052e24247ba87a81bdf540b8e8b77d375da194 |
|
MD5 | 38bfaee1c9ba5cf95e7df68b8c3d25cc |
|
BLAKE2b-256 | d09aec3fd94fb2876e4ddd7e0e66b3625132b4aab82d9cf2b29864fd0a157dff |
Hashes for soxr-0.2.5a4-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70858cb3b882b0821706d0f5cfd1968f5c0aee616a96e5c7491c280fc1e744d3 |
|
MD5 | bdca7738926ec715a24873881da1a1a7 |
|
BLAKE2b-256 | 7877de1476d106566a2d30ea525b7f0d0282c8753dd98aed6b664591e6868f7f |
Hashes for soxr-0.2.5a4-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90800d7ee8f831f57958edf9e6095966cd5532b77f669c3805c74f94d17459ce |
|
MD5 | ace2b2e27d4257298f8b0501b39d34c2 |
|
BLAKE2b-256 | 549fcbb8eb273c488e6aa519c59e0e8053992cb5a6f30ee077f1ece2e8175659 |
Hashes for soxr-0.2.5a4-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37f7106517530f33114e1130d9960300d98dbae2fcdba78fbab69f0bbe6ad7c2 |
|
MD5 | 007dfb4920e954f013451079604ca87a |
|
BLAKE2b-256 | ab9b2d1521551d222615774a1d73076e16370b32a76a08d24da6f5b333ec2e86 |
Hashes for soxr-0.2.5a4-cp38-cp38-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85b13f5006e3a388514aa4bfe2b5f47b9a2022b52974d72b6ebd1133b24c3155 |
|
MD5 | 53acb3efd358564c731da01e504d22fd |
|
BLAKE2b-256 | 23f399fcf283f634c4490bf448a0d2b849841b3c7a1dd524e43dc6e759107700 |
Hashes for soxr-0.2.5a4-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30a8c32ef117236021a4fb20d5a8a81471bfb1422db415d3ebac1c082048a882 |
|
MD5 | 1119deb7c8719abd8e8c66cd105f28be |
|
BLAKE2b-256 | 6ccefa0cd1ac153ad0edd0a5caa5ab458704390839d6876c47b5cc88c9bb9664 |
Hashes for soxr-0.2.5a4-cp38-cp38-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9edad3dfad550ca6ca6d9bec7835643b7fa5b3bfeea3d2ee094a6009381ec28c |
|
MD5 | ad0ddaacb5730f71cef9c016c723da98 |
|
BLAKE2b-256 | f22231256300c1f0d06811f55c14c005a9a9fe5caedfd537fcf05ef49ca55947 |
Hashes for soxr-0.2.5a4-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82809644cba1599de97e6ddfa5c9c01309beb29f575e893730262aba63f40d8c |
|
MD5 | 98bb0d3505ba326316efea9573d5b472 |
|
BLAKE2b-256 | d9d14e73b9abaa6f7d8754a96c8ae673ec6e978cddb644cd570523595495d573 |
Hashes for soxr-0.2.5a4-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b11df0d31d8a58d6ca85941dd9eea5e0187ae4fe7ebb5441320d5b59b5636a17 |
|
MD5 | 7964cee1379562801fd25d0d0e2929d8 |
|
BLAKE2b-256 | 73e8c9f42b3f0354b6846567dace9fdabb7187e0d05cc101dd0109c32d6bbffb |
Hashes for soxr-0.2.5a4-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd2cd04c2ad39c12247ecae9183c4b1c533e7c6f7b8fc4b97a28188e9386d33c |
|
MD5 | ac0e283ee1c95929f36faf4272a09887 |
|
BLAKE2b-256 | 06992b0737524ad0bd995efa48b5d32500a09c2056317c906383a3deba0f6fbd |
Hashes for soxr-0.2.5a4-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b836ad2f88217c707e4b9c5a3ca0e0b5953a23d26208225625b5cc685f2771d8 |
|
MD5 | 99b36624c989cd5f35381918b7079d75 |
|
BLAKE2b-256 | 0bc780038d80fe317db3c5aab391b7a4bc5ebc4363d0b0b063410e359f06bef7 |
Hashes for soxr-0.2.5a4-cp37-cp37m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a045f3611c4917da8f6bd45409cb40cc66caef24e654473975aac5e0133921cd |
|
MD5 | f1e85b5bc68705601a04629c87bc2dda |
|
BLAKE2b-256 | e699774aa5ec4f8bbbcf0732e086789e842e0378443104735318e345724ec6d7 |
Hashes for soxr-0.2.5a4-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba1b06aa4824367c71bdca7be76a31faaef7f3a9a25513b7f9cb3e559c5b6ab1 |
|
MD5 | 3b30826779a0d44973da5e5c76a0793b |
|
BLAKE2b-256 | 324b8d1a3ba08b2e5a534b69d60badda59e8123f86da84f68cc8ddf6936e754a |
Hashes for soxr-0.2.5a4-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19d602670ee2ce5ef026931eec6154284fcd3d0c40e3d98b3690595ebcd4c514 |
|
MD5 | 72f01818773c0d3b9c3b2d71c7e14901 |
|
BLAKE2b-256 | 3df1c802c9b7cd2191c30760374e54db69719d374663420a43d275752453c4cf |
Hashes for soxr-0.2.5a4-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 170e794fd2ee70f72321e7da2d9b9f44170c807fb524c90a51fa14e795e33ab1 |
|
MD5 | 1a6dfbb0d6d5336ea25cf0a40102597f |
|
BLAKE2b-256 | fbf4d8e6fb90bbf36ade4515e726b02fa85fb9540ec5c5347fe4bf1e3496d50d |
Hashes for soxr-0.2.5a4-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f61d06ac8b04117cc83455d813d2528924c594b4a5f396ab839470bae1d006c4 |
|
MD5 | dff7323f9402cd875d34f1d45e7ad977 |
|
BLAKE2b-256 | e3bc79c0ac0088c7b85e3ac1718386770e5b41fe4193e5f22102ed5c11c4d8eb |
Hashes for soxr-0.2.5a4-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1803f6bf0e414d9ec9d4de764096dfdc516504bb936446c3b98f5baeaaf7f618 |
|
MD5 | 06b231e9a30d00a45a35f273712af63a |
|
BLAKE2b-256 | b12541d37b9f237ae6d4a3cf15fc415f504389d769c3a5e4f5078cd239bec122 |
Hashes for soxr-0.2.5a4-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cab0be3e8a7bbad88e4b1f953b8ea0fe8dfcd99ed64b893418aa8a08b8ebb57 |
|
MD5 | 8e8159b4e0d9c73cc0a3b27c61519930 |
|
BLAKE2b-256 | c3d157f87e2e8468e5ac58edc666649a522a938d487d49ec784b2aeb436f57d2 |
Hashes for soxr-0.2.5a4-cp36-cp36m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55a864f10258d7b06ce71150a1c75eca66eda24a6882b51d079d34662bfa7b14 |
|
MD5 | f0ea080ddea2fed0e06c3421ba8177ce |
|
BLAKE2b-256 | b79090d28c58b221e8802b824586d56b05b5fb6da7104d652eb35d076c218335 |
Hashes for soxr-0.2.5a4-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 200f92fdd649e5517941d7145912e32d19cdf7be5c68d1d401d17dac0531cb46 |
|
MD5 | 01990710f345c5c9fa9dc0b9f442d7d9 |
|
BLAKE2b-256 | b229106b524097b666448df8038fd424f9456d2f9c5b08b1490ad530c8b9df44 |
Hashes for soxr-0.2.5a4-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d58f6eeaa98470450eef9dea8121b255cf2ebe378a239eb8ee346e5c86cb32c |
|
MD5 | 9899f7609bf6a2693af1ec90fe8c1060 |
|
BLAKE2b-256 | 49a410897845b80c62626e517a7ecb65b0de0c460e798725bbc18a640324a61a |
Hashes for soxr-0.2.5a4-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37e0c6bef6e3979bd86db624765d26890e183933ed44db294642c8212c0b0eb0 |
|
MD5 | 7df1ae1465561ff6de718277ca4a535d |
|
BLAKE2b-256 | e3d3c5748e0b90a1543f2472c8859390435106e7a1ba98f25bde6e14733cc763 |