Code Monkey home page Code Monkey logo

resampy's People

Contributors

avalentino avatar bmcfee avatar chohner avatar endolith avatar karpp avatar nils-werner avatar polariton avatar waldyrious avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

resampy's Issues

Streaming API

Circling back on #52 , I want to start a separate thread to discuss API design for a streaming resampling interface.

Background

The current implementation resampy.resample (and its underlying interpn.resample_f function) assume that the entire signal is given up front as an ndarray. It then does a time-domain convolution with linear interpolation to estimate the filter response over the resampled time grid, and returns the resampled signal.

Streaming

If data is too large to fit in memory, or if it's streaming (say from a mic), the above resampling method doesn't work. Instead, we'd have to work on small buffers of data. In principle, this isn't too difficult to do, though we need to maintain some state across buffer calls. We'd also incur some latency in proportion to the length of the filter, and that's unavoidable unless we go to a causal filter. (More on that below.)

API design

I think the simplest API would iterate over a frame generator (eg from soundfile or portaudio), do resampling, and yield resampled frame buffers as they become available. The main question here is how the buffer length (and edge conditions) are specified by the user. The most direct interface would be in terms of samples at the new sampling rate, though I could imagine arguments for other interfaces.

Causal filtering

We could minimize latency by using a causal IIR filter (that only depends on past samples). This will incur some phase distortion, but AFAIK there aren't any off-the-shelf packages that provide low-latency sample rate conversion, so maybe it could be in scope for resampy as well.

[JOSS Review] Performance claims

How would I confirm the performance claims of the software? An example that demonstrates the speedup benefits would be a useful addition to the documentation, IMHO.

Complex-valued resampling

Cython's fused types should make this trivial, but for whatever reason, it didn't work out of the box.

We may have to handle complex-valued data explicitly.

Failing to build or install by pypi on linux - interp.c ?

I can see the similar issues being opened for OSX and Windows yet there is still an issue with interp.c.

Here is my output of sudo pip install resampy:

Requirement already satisfied (use --upgrade to upgrade): numpy>=1.10 in /usr/lib/python2.7/dist-packages (from resampy)
Requirement already satisfied (use --upgrade to upgrade): scipy>=0.13 in /usr/local/lib/python2.7/dist-packages (from resampy)
Requirement already satisfied (use --upgrade to upgrade): six>=1.3 in /usr/lib/python2.7/dist-packages (from resampy)
Requirement already satisfied (use --upgrade to upgrade): Cython>=0.23 in /usr/local/lib/python2.7/dist-packages (from resampy)
Installing collected packages: resampy
  Running setup.py install for resampy ... error
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-4m1Ait/resampy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-m9MyHv-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    creating build/lib.linux-x86_64-2.7/resampy
    copying resampy/version.py -> build/lib.linux-x86_64-2.7/resampy
    copying resampy/core.py -> build/lib.linux-x86_64-2.7/resampy
    copying resampy/filters.py -> build/lib.linux-x86_64-2.7/resampy
    copying resampy/__init__.py -> build/lib.linux-x86_64-2.7/resampy
    creating build/lib.linux-x86_64-2.7/resampy/data
    copying resampy/data/kaiser_fast.npz -> build/lib.linux-x86_64-2.7/resampy/data
    copying resampy/data/kaiser_best.npz -> build/lib.linux-x86_64-2.7/resampy/data
    running build_ext
    skipping 'resampy/interp.c' Cython extension (up-to-date)
    building 'resampy.interp' extension
    creating build/temp.linux-x86_64-2.7
    creating build/temp.linux-x86_64-2.7/resampy
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c resampy/interp.c -o build/temp.linux-x86_64-2.7/resampy/interp.o
    resampy/interp.c:4:20: fatal error: Python.h: No such file or directory
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-4m1Ait/resampy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-m9MyHv-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-4m1Ait/resampy/

I've tried to clone the repository run sudo python install.py build
Here is this output too:

running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/resampy
copying resampy/version.py -> build/lib.linux-x86_64-2.7/resampy
copying resampy/core.py -> build/lib.linux-x86_64-2.7/resampy
copying resampy/filters.py -> build/lib.linux-x86_64-2.7/resampy
copying resampy/__init__.py -> build/lib.linux-x86_64-2.7/resampy
creating build/lib.linux-x86_64-2.7/resampy/data
copying resampy/data/kaiser_fast.npz -> build/lib.linux-x86_64-2.7/resampy/data
copying resampy/data/kaiser_best.npz -> build/lib.linux-x86_64-2.7/resampy/data
running build_ext
cythoning resampy/interp.pyx to resampy/interp.c
building 'resampy.interp' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/resampy
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c resampy/interp.c -o build/temp.linux-x86_64-2.7/resampy/interp.o
resampy/interp.c:4:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Cython is installed with the latest version available on pypi.

Issue install with pip

I have trouble installing resampy with pip...

Exception:
Traceback (most recent call last):
  File "c:\users\tim\appdata\local\programs\python\python36\lib\site-packages\pip\compat\__init__.py", line 73, in console_to_str
    return s.decode(sys.__stdout__.encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb1 in position 44: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\tim\appdata\local\programs\python\python36\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "c:\users\tim\appdata\local\programs\python\python36\lib\site-packages\pip\commands\install.py", line 342, in run
    prefix=options.prefix_path,
  File "c:\users\tim\appdata\local\programs\python\python36\lib\site-packages\pip\req\req_set.py", line 784, in install
    **kwargs
  File "c:\users\tim\appdata\local\programs\python\python36\lib\site-packages\pip\req\req_install.py", line 878, in install
    spinner=spinner,
  File "c:\users\tim\appdata\local\programs\python\python36\lib\site-packages\pip\utils\__init__.py", line 676, in call_subprocess
    line = console_to_str(proc.stdout.readline())
  File "c:\users\tim\appdata\local\programs\python\python36\lib\site-packages\pip\compat\__init__.py", line 75, in console_to_str
    return s.decode('utf_8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb1 in position 44: invalid start byte

Different edge modes

The current implementation (implicitly) supports only one form of edge behavior: zero-padding.

With a bit of work, we could support the usual array of edge modes:

  • constant padding (non-zero)
  • edge
  • reflection/symmetric
  • wrap

This would help give users a bit more control to clean up some boundary cases reported in #62.

API documentation broken

If you have a look at https://resampy.readthedocs.io/en/stable/api.html, there is nothing documented at the moment. This is due to an error while running sphinx, which can be found on this page: https://readthedocs.org/projects/resampy/builds/7292423/. You have to click on the "python /home/docs/checkouts/readthedocs.org/user_builds/resampy/envs/0.2.1/bin/sphinx-build -T -b readthedocs -d _b" and you can see it. the important part is:

WARNING: autodoc: failed to import module 'resampy.core'; the following exception was raised:
No module named 'numba'
WARNING: autodoc: failed to import module 'resampy.filters'; the following exception was raised:
No module named 'numba'

It is not so easy to debug without having access to your readthedocs settings, but I guess you haven't ticked the following boxes under advanced settings?
rtfd-advanced

resample fails on axis >1

resampy version: 0.2.1
Python: 3.7.3
numpy version: 1.16.2
Windows 10

resampy.resample returns array of zeros of appropriate size when axis parameter is greater than 1 (tested for axis=2 and axis=3). See minimal working example below:

>>> rand_arr = np.random.rand(3,4,5,100)
>>> resampled_arr = resampy.resample(rand_arr, 100, 24, axis=3)
>>> resampled_t_arr = resampy.resample(np.transpose(rand_arr), 100, 24, axis=0)
>>> print(resampled_arr.sum())
0.0
>>> print(resampled_t_arr.sum())
718.0698928346849

Believe it's due to the lines:

    x_2d = x.swapaxes(0, axis).reshape((x.shape[axis], -1))
    y_2d = y.swapaxes(0, axis).reshape((y.shape[axis], -1))
    resample_f(x_2d, y_2d, sample_ratio, interp_win, interp_delta, precision)

I can look into submitting a PR if it's simple and desirable?

ImportError: DLL load failed

image

I had an issue trying to import Librosa, so I want through the requirements for it one by one and found that resampy seemed to be causing the error. I'm attaching a screen shot of the issue.

Any ideas? My goal is to use Librosa to reproduce the technique outlined in the recent voice anonymization publication, which seems like it should be straightforward but I have to get librosa importing fine first!

Weird effect at end of resampled signal

Hi,

when resampling a signal I get a weird effect at the end. It consists of a reduced amplitude plus a nasty noise. Is this normal, a bug or am I doing something wrong? Here are plots for a linear and a sine signal:

Linear Signal

Sine Signal

I'm using the current resampy master from GitHub (3e76335), all other packages are installed from conda / virtualenv.

Here's the code that produces the plots:

import matplotlib.pyplot as plt
import numpy as np

import resampy

factor = .5

a = np.arange(0, 50, .1, dtype=float)
b = resampy.resample(a, 1, factor, axis=0)
c = resampy.resample(b, 1, 1/factor, axis=0)

plt.figure()
plt.plot(a, label='Original')
plt.plot(b, label='Resampled %.2f' % factor)
plt.plot(c, label='Resampeld %.2f -> %.2f' % (factor, 1/factor))
plt.legend()

plt.show()

# Same with sin
plt.figure()
a = np.sin(np.arange(0, 50, .1, dtype=float))
b = resampy.resample(a, 1, factor, axis=0)
c = resampy.resample(b, 1, 1/factor, axis=0)

plt.figure()
plt.plot(a, label='Original')
plt.plot(b + 1.5, label='Resampled %.2f' % factor)
plt.plot(c + 3.0, label='Resampeld %.2f -> %.2f' % (factor, 1/factor))
plt.legend()

plt.show()

And here my environment (virtualenv freeze):

cycler==0.10.0
kiwisolver==1.0.1
llvmlite==0.23.2
matplotlib==2.2.2
numba==0.38.1
numpy==1.14.3
pyparsing==2.2.0
python-dateutil==2.7.3
pytz==2018.4
scipy==1.1.0
six==1.11.0

It would be great if you could have a look into this problem. Please let me know if I can do something to help you reproduce it.

Best, Boris

Issue when installing package as egg

hey,

I want to install this package as a depencency of an egg in a clean environment and I get the following error:

Collecting resampy>=0.1.2 (from librosa)
         Downloading resampy-0.1.4.tar.gz (442kB)
           Complete output from command python setup.py egg_info:
           Traceback (most recent call last):
             File "<string>", line 1, in <module>
             File "/tmp/pip-build-w3y6lhlm/resampy/setup.py", line 6, in <module>
               import numpy as np
           ImportError: No module named 'numpy'

           ----------------------------------------
       Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-w3y6lhlm/resampy/

It's because numpy is used in the setup.py to get the cython include stuff right.

Anything I am missing here?

Thx

Type-check and raise exception for unsupported input formats (int, complex, etc)

Hi,

I tried to find a Python resampling tool faster than scipy.resample, and I think that you're project is a nice solution, thanks for that ;)

But, after install it via pip, and when I test it, I got :

Traceback (most recent call last): [...]
    samples = resample(audio[offset:offset + n], sample_rate, 32000)
  File "/usr/local/lib/python2.7/dist-packages/resampy/core.py", line 109, in resample
    resample_f(x_2d, y_2d, sample_ratio, interp_win, interp_delta, precision)
  File "resampy/interp.pyx", line 15, in resampy.interp.__pyx_fused_cpdef (resampy/interp.c:2921)
TypeError: No matching signature found

This issue appears on a Debian jessie 64bits machine, thanks for future help !

Fix cython dependency

The current packaging configuration works for installing, but fails at runtime if cython is not installed.

Somehow, the cython dependency is not being enforced properly by the packager.

0.1.4rc breaks my CI

20 hours ago my continuous integration started to fail with this error:

Installed xxxxx/builds/ccbf14cd/0/algorithm/tools/.eggs/librosa-0.4.3-py2.7.egg
Searching for resampy>=0.1.0
Reading https://pypi.python.org/simple/resampy/
Best match: resampy 0.1.4rc0
Downloading https://pypi.python.org/packages/e9/93/da2deb7137fd12b679dfb8e20548b270b9602e03bc970d977134aa2d37bb/resampy-0.1.4rc0.tar.gz#md5=d584ea138ea085d83ea134992ca56607
Processing resampy-0.1.4rc0.tar.gz
Writing /var/folders/gg/zxfl0y1519q5p8g5vnbb6q980000gn/T/easy_install-qJ0PtN/resampy-0.1.4rc0/setup.cfg
Running resampy-0.1.4rc0/setup.py -q bdist_egg --dist-dir /var/folders/gg/zxfl0y1519q5p8g5vnbb6q980000gn/T/easy_install-qJ0PtN/resampy-0.1.4rc0/egg-dist-tmp-bl1P9J
Compiling resampy/interp.pyx because it depends on /usr/local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd.
[1/1] Cythonizing resampy/interp.pyx
warning: no files found matching '*.pxd' under directory 'resampy'
resampy/interp.c:280:10: fatal error: 'numpy/arrayobject.h' file not found
#include "numpy/arrayobject.h"
         ^
1 error generated.
error: Setup script exited with error: command 'clang' failed with exit status 1

This was the first build I attempted after your ac447c5 commit, 22 hours ago. That seems to be the culprit.

I'm not explicitly importing/using resampy, but I guess it is a dependency for librosa.

As a temporary solution for me, I forced it to use resampy==0.1.3 and my CI builds without errors. But that's obviously not the ideal solution.

Expose filter rolloff

The roll-off frequency for pre-computed filters should be programmatically accessible.

Installation error - interp.c

I've been trying to install librosa, as a result of which I had to get resampy. Whether I use pip to install librosa or resampy, or I use Cython after cloning resampy, I get the following error:

Error compiling Cython file:
------------------------------------------------------------
...
from cython cimport floating


@cython.boundscheck(False)
@cython.wraparound(False)
cpdef void resample_f(floating[:, :] x, floating[:, :] y,
     ^
------------------------------------------------------------

resampy\interp.pyx:15:6: Cannot convert 'void' to Python object

Error compiling Cython file:
------------------------------------------------------------
...
from cython cimport floating


@cython.boundscheck(False)
@cython.wraparound(False)
cpdef void resample_f(floating[:, :] x, floating[:, :] y,
     ^
------------------------------------------------------------

resampy\interp.pyx:15:6: Cannot convert 'void' to Python object
building 'resampy.interp' extension
creating build\temp.win-amd64-2.7
creating build\temp.win-amd64-2.7\Release
creating build\temp.win-amd64-2.7\Release\resampy
C:\Program Files\MinGW\bin\gcc.exe -DMS_WIN64 -mdll -O -Wall -IC:\Users\ORCHISAMA\Anaconda\lib\site-packages\numpy\core\include -IC:
\Users\ORCHISAMA\Anaconda\include -IC:\Users\ORCHISAMA\Anaconda\PC -c resampy\interp.c -o build\temp.win-amd64-2.7\Release\resampy\i
nterp.o
resampy\interp.c:1:2: error: #error Do not use this file, it is the result of a failed Cython compilation.
error: command 'C:\\Program Files\\MinGW\\bin\\gcc.exe' failed with exit status 1

Please help me out.

API, pre-computed filters

Issue #4 eventually led to the conclusion that we should aim to support pre-baked filter designs that lack closed-form definitions.

This will require some reworking of the API, which is currently integrated with the sinc+window method.

Ideally, I think we should support both.

What might this look like? The current resample API looks as follows:

resample(x, sr_orig, sr_new, num_zeros=69, precision=9, window=None, rolloff=0.95, axis=-1)

Of these parameters, x, sr_orig, sr_new, axis, precision refer to the resampling, and num_zeros, precision, window, rollofff refer to the filter construction. precision is the only common point here, as it determines the over-sampling rate of the filter construction (ie, the number of samples between zero-crossings in the sinc). precision should be a property of the filter that gets consumed by the resampler though.

If we pre-compute filters, then we need to store both h (the right wing of the filter) and 2**precision -- the rest can be reconstructed at runtime. Pre-built filters can be stored npz files, indexed by name, and distributed with the module. For instance, we could have something like

resample(x, sr_orig, sr_new, axis=-1, filter='sinc_nz13_prec9_hann')

which then retrieves the filter coefficients from the referenced file on disk.

We could also define an API for filter construction that returns the tuple (h, 2**precision). We could then also support a callback-style interface:

resample(x, sr_orig, sr_new, axis=-1, filter=resampy.filters.sinc, num_zeros=13, precision=9, window=scipy.signal.hann)

where the remaining parameters are absorbed via **kwargs.

build wheels

This will be a non-trivial undertaking, but should resolve many of the packaging issues we currently have outstanding.

  • linux wheels via circle-ci (or travis, maybe)
  • osx wheels via travis
  • windows wheels via appveyor

Now that #55 is merged, the cython extension building should at least be sane.

how to implement resampy for live microphone

I want to convert sample rate of live microphone from pyaudio at 44100hz to 16000hz and use it with pocketsphinx can anyone please help to convert samplerate of live recording with resampy.
Thank you

Resampling does not preserve array byte ordering

The title says it all: if you give a multidimensional array x as input, the output may have a different (ie c-contiguous) ordering.

The culprit is this line:

y = np.zeros(shape, dtype=x.dtype)
which does not propagate the ordering information.

Fixing this is a bit delicate, but it should be doable.

Q: Comparison to / inclusion in SciPy?

@choldgraf just pointed me to this repo. I haven't had much time to dig into it, but it looks like a promising method for resampling. Have you by chance looked at how it compares to the polyphase resampling recently added to SciPy scipy.signal.resample_poly? I imagine this might be faster (argument from authority since it's based on one of Julius O Smith's documents), but from the little bit I read they seem to share some ideas so I'm curious to what extent it is faster.

Any interest in eventually moving the functionality to scipy.signal at some point?

Issue when installing

C:\Windows\system32>pip install resampy
Collecting resampy
Using cached resampy-0.1.5.tar.gz
Requirement already satisfied: numpy>=1.10 in c:\users\ady\appdata\local\program
s\python\python35\lib\site-packages (from resampy)
Requirement already satisfied: scipy>=0.13 in c:\users\ady\appdata\local\program
s\python\python35\lib\site-packages (from resampy)
Requirement already satisfied: six>=1.3 in c:\users\ady\appdata\local\programs\p
ython\python35\lib\site-packages (from resampy)
Requirement already satisfied: Cython>=0.23 in c:\users\ady\appdata\local\progra
ms\python\python35\lib\site-packages (from resampy)
Building wheels for collected packages: resampy
Running setup.py bdist_wheel for resampy ... error
Complete output from command c:\users\ady\appdata\local\programs\python\python
35\python.exe -u -c "import setuptools, tokenize;file='C:\Users\Ady\AppDa
ta\Local\Temp\pip-build-ak_l9n7g\resampy\setup.py';f=getattr(tokenize, 'ope
n', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(c
ode, file, 'exec'))" bdist_wheel -d C:\Users\Ady\AppData\Local\Temp\tmpx9udi
l_epip-wheel- --python-tag cp35:
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.5
creating build\lib.win-amd64-3.5\resampy
copying resampy\core.py -> build\lib.win-amd64-3.5\resampy
copying resampy\filters.py -> build\lib.win-amd64-3.5\resampy
copying resampy\version.py -> build\lib.win-amd64-3.5\resampy
copying resampy_init_.py -> build\lib.win-amd64-3.5\resampy
creating build\lib.win-amd64-3.5\resampy\data
copying resampy\data\kaiser_best.npz -> build\lib.win-amd64-3.5\resampy\data
copying resampy\data\kaiser_fast.npz -> build\lib.win-amd64-3.5\resampy\data
running build_ext
building 'resampy.interp' extension
error: [WinError 3] The system cannot find the path specified: 'C:\Program Fi
les (x86)\Microsoft Visual Studio 14.0\VC\PlatformSDK\lib'


Failed building wheel for resampy
Running setup.py clean for resampy
Failed to build resampy
Installing collected packages: resampy
Running setup.py install for resampy ... error
Complete output from command c:\users\ady\appdata\local\programs\python\pyth
on35\python.exe -u -c "import setuptools, tokenize;file='C:\Users\Ady\App
Data\Local\Temp\pip-build-ak_l9n7g\resampy\setup.py';f=getattr(tokenize, 'o
pen', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile
(code, file, 'exec'))" install --record C:\Users\Ady\AppData\Local\Temp\pip-
a625b11n-record\install-record.txt --single-version-externally-managed --compile
:
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.5
creating build\lib.win-amd64-3.5\resampy
copying resampy\core.py -> build\lib.win-amd64-3.5\resampy
copying resampy\filters.py -> build\lib.win-amd64-3.5\resampy
copying resampy\version.py -> build\lib.win-amd64-3.5\resampy
copying resampy_init_.py -> build\lib.win-amd64-3.5\resampy
creating build\lib.win-amd64-3.5\resampy\data
copying resampy\data\kaiser_best.npz -> build\lib.win-amd64-3.5\resampy\data

copying resampy\data\kaiser_fast.npz -> build\lib.win-amd64-3.5\resampy\data

running build_ext
building 'resampy.interp' extension
error: [WinError 3] The system cannot find the path specified: 'C:\\Program

Files (x86)\Microsoft Visual Studio 14.0\VC\PlatformSDK\lib'

----------------------------------------

Command "c:\users\ady\appdata\local\programs\python\python35\python.exe -u -c "i
mport setuptools, tokenize;file='C:\Users\Ady\AppData\Local\Temp\pip-b
uild-ak_l9n7g\resampy\setup.py';f=getattr(tokenize, 'open', open)(file);co
de=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec')
)" install --record C:\Users\Ady\AppData\Local\Temp\pip-a625b11n-record\install-
record.txt --single-version-externally-managed --compile" failed with error code
1 in C:\Users\Ady\AppData\Local\Temp\pip-build-ak_l9n7g\resampy\

Support multiple dtypes

The current implementation only supports float32. We should add support for double-precision, as well as complex variables.

Faster resampling?

(I originally mistakenly posted this on librosa, I got the names mixed up... intended to post here.)

Guys,
I just wrote a utility for resampling audio data based on convolution from Torch, and it was about 8 times faster than librosa when using the same configuration (num_zeros and so on). This is on CPU.
You can see it at this repo
https://github.com/danpovey/filtering
e.g. you can check it out and do
cd tests; python3 ./test_resampler_speed.py
to see.

I know you probably don't want a torch dependency but I don't think that was, likely, the key part, I think it was more about precomputing the coefficients as a tensor that can be applied directly without interpolation.

Just something to bear in mind in the future in case any of your developers have the bandwidth. I.e. that it's possible to do resampling significantly faster than what's there now.

mac:tests: python3 ./test_resampler_speed.py
our torch-filter filter size = {} torch.Size([1, 1, 274])
T:b.shape = torch.Size([2, 5000]), c.shape = torch.Size([2, 10000])
T:b.shape = torch.Size([2, 5000]), c.shape = torch.Size([2, 10000])
T:b.shape = torch.Size([2, 5000]), c.shape = torch.Size([2, 10000])
T:b.shape = torch.Size([2, 5000]), c.shape = torch.Size([2, 10000])
T:b.shape = torch.Size([2, 5000]), c.shape = torch.Size([2, 10000])
T:b.shape = torch.Size([2, 5000]), c.shape = torch.Size([2, 10000])
T:b.shape = torch.Size([2, 5000]), c.shape = torch.Size([2, 10000])
T:b.shape = torch.Size([2, 5000]), c.shape = torch.Size([2, 10000])
T:b.shape = torch.Size([2, 5000]), c.shape = torch.Size([2, 10000])
T:b.shape = torch.Size([2, 5000]), c.shape = torch.Size([2, 10000])
Elapsed time for our torch-based resampler: 0.12666641599999995
R:b.shape = (2, 5000), c.shape = (2, 10000)
R:b.shape = (2, 5000), c.shape = (2, 10000)
R:b.shape = (2, 5000), c.shape = (2, 10000)
R:b.shape = (2, 5000), c.shape = (2, 10000)
R:b.shape = (2, 5000), c.shape = (2, 10000)
R:b.shape = (2, 5000), c.shape = (2, 10000)
R:b.shape = (2, 5000), c.shape = (2, 10000)
R:b.shape = (2, 5000), c.shape = (2, 10000)
R:b.shape = (2, 5000), c.shape = (2, 10000)
R:b.shape = (2, 5000), c.shape = (2, 10000)
Elapsed time for librosa resampler: 1.0655667419999997
.

undefined symbol: PyFPE_jbuf

$ python --version
Python 2.7.13 :: Continuum Analytics, Inc.

$python -c "import librosa; print(librosa.__version__)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/arpitb/anaconda3/envs/speaker-id/lib/python2.7/site-packages/librosa/__init__.py", line 11, in <module>
    from . import core
  File "/home/arpitb/anaconda3/envs/speaker-id/lib/python2.7/site-packages/librosa/core/__init__.py", line 109, in <module>
    from .audio import *  # pylint: disable=wildcard-import
  File "/home/arpitb/anaconda3/envs/speaker-id/lib/python2.7/site-packages/librosa/core/audio.py", line 12, in <module>
    import resampy
  File "/home/arpitb/anaconda3/envs/speaker-id/lib/python2.7/site-packages/resampy/__init__.py", line 7, in <module>
    from .core import *
  File "/home/arpitb/anaconda3/envs/speaker-id/lib/python2.7/site-packages/resampy/core.py", line 8, in <module>
    from .interp import resample_f
ImportError: /home/arpitb/anaconda3/envs/speaker-id/lib/python2.7/site-packages/resampy/interp.so: undefined symbol: PyFPE_jbuf

Installation: vcvarsall.bat not found

Hello.

I'm attempting to install resampy on a windows 10 machine running python 3.5.2 64bit and pip 9.0.1.

When I try to use pip install, I get an error indicating that it failed to build the .whl file because it could not find "vcvarsall.bat."

I was wondering if you knew what the issue might be/how to proceed?

Thanks!

PS C:\Users\Sam\downloads> pip install resampy
Collecting resampy
  Using cached resampy-0.1.5.tar.gz
Requirement already satisfied: numpy>=1.10 in c:\users\sam\appdata\local\programs\python\python35\lib\site-packages (fro
m resampy)
Requirement already satisfied: scipy>=0.13 in c:\users\sam\appdata\local\programs\python\python35\lib\site-packages (fro
m resampy)
Requirement already satisfied: six>=1.3 in c:\users\sam\appdata\local\programs\python\python35\lib\site-packages (from r
esampy)
Requirement already satisfied: Cython>=0.23 in c:\users\sam\appdata\local\programs\python\python35\lib\site-packages (fr
om resampy)
Building wheels for collected packages: resampy
  Running setup.py bdist_wheel for resampy ... error
  Complete output from command c:\users\sam\appdata\local\programs\python\python35\python.exe -u -c "import setuptools,
tokenize;__file__='C:\\Users\\Sam\\AppData\\Local\\Temp\\pip-build-u5pafzmp\\resampy\\setup.py';f=getattr(tokenize, 'ope
n', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d
C:\Users\Sam\AppData\Local\Temp\tmpabkfy3bupip-wheel- --python-tag cp35:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.5
  creating build\lib.win-amd64-3.5\resampy
  copying resampy\core.py -> build\lib.win-amd64-3.5\resampy
  copying resampy\filters.py -> build\lib.win-amd64-3.5\resampy
  copying resampy\version.py -> build\lib.win-amd64-3.5\resampy
  copying resampy\__init__.py -> build\lib.win-amd64-3.5\resampy
  creating build\lib.win-amd64-3.5\resampy\data
  copying resampy\data\kaiser_best.npz -> build\lib.win-amd64-3.5\resampy\data
  copying resampy\data\kaiser_fast.npz -> build\lib.win-amd64-3.5\resampy\data
  running build_ext
  building 'resampy.interp' extension
  error: Unable to find vcvarsall.bat

  ----------------------------------------
  Failed building wheel for resampy
  Running setup.py clean for resampy
Failed to build resampy
Installing collected packages: resampy
  Running setup.py install for resampy ... error
    Complete output from command c:\users\sam\appdata\local\programs\python\python35\python.exe -u -c "import setuptools
, tokenize;__file__='C:\\Users\\Sam\\AppData\\Local\\Temp\\pip-build-u5pafzmp\\resampy\\setup.py';f=getattr(tokenize, 'o
pen', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --rec
ord C:\Users\Sam\AppData\Local\Temp\pip-a9n4j6tj-record\install-record.txt --single-version-externally-managed --compile
:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.5
    creating build\lib.win-amd64-3.5\resampy
    copying resampy\core.py -> build\lib.win-amd64-3.5\resampy
    copying resampy\filters.py -> build\lib.win-amd64-3.5\resampy
    copying resampy\version.py -> build\lib.win-amd64-3.5\resampy
    copying resampy\__init__.py -> build\lib.win-amd64-3.5\resampy
    creating build\lib.win-amd64-3.5\resampy\data
    copying resampy\data\kaiser_best.npz -> build\lib.win-amd64-3.5\resampy\data
    copying resampy\data\kaiser_fast.npz -> build\lib.win-amd64-3.5\resampy\data
    running build_ext
    building 'resampy.interp' extension
    error: Unable to find vcvarsall.bat

    ----------------------------------------
Command "c:\users\sam\appdata\local\programs\python\python35\python.exe -u -c "import setuptools, tokenize;__file__='C:\
\Users\\Sam\\AppData\\Local\\Temp\\pip-build-u5pafzmp\\resampy\\setup.py';f=getattr(tokenize, 'open', open)(__file__);co
de=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Sam\AppData
\Local\Temp\pip-a9n4j6tj-record\install-record.txt --single-version-externally-managed --compile" failed with error code
 1 in C:\Users\Sam\AppData\Local\Temp\pip-build-u5pafzmp\resampy\
PS C:\Users\Sam\downloads>


Fix the roll-off calculation

We're currently getting a bit of aliasing at the high end of the frequency range when down-sampling. (Up-sampling appears to be clean.) This is most likely due to either a bad specification of the roll-off frequency, or something slightly off in the sinc window computation.

Installation via bdist_wheel and bdist_egg can't find resampy/interp.c

I've had a couple of issues installing resampy when trying to install librosa, with errors similar to the following:

Searching for resampy>=0.1.0
Reading https://pypi.python.org/simple/resampy/
Best match: resampy 0.1.0
Downloading https://pypi.python.org/packages/e1/8d/9fbc8e1dba8a83e4be47cc4a906dcb3ca5959bc7e4da1d388e64c2d20a5e/resampy-0.1.0.tar.gz#md5=3fec740b9dcc40397efd4d1b4e4ad532
Processing resampy-0.1.0.tar.gz
Writing /tmp/easy_install-_2lda2x_/resampy-0.1.0/setup.cfg
Running resampy-0.1.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-_2lda2x_/resampy-0.1.0/egg-dist-tmp-14darseq
warning: no files found matching '*.pxd' under directory 'resampy'
gcc: error: resampy/interp.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.

In general, this can be worked around by doing pip install resampy which gives similar errors about missing resampy/interp.c during bdist_wheel, but then falls back on installing via setup.py install, something like (on windows):

>pip install resampy
Collecting resampy
  Downloading resampy-0.1.0.tar.gz (320kB)
    100% |████████████████████████████████| 327kB 101kB/s 
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.10 in c:\miniconda3\envs\sct\lib\site-packages (from resampy)
Requirement already satisfied (use --upgrade to upgrade): scipy>=0.13 in c:\miniconda3\envs\sct\lib\site-packages (from resampy)
Requirement already satisfied (use --upgrade to upgrade): six>=1.3 in c:\miniconda3\envs\sct\lib\site-packages (from resampy)
Collecting Cython>=0.21 (from resampy)
  Downloading Cython-0.24-cp35-none-win_amd64.whl (1.9MB)
    100% |████████████████████████████████| 1.9MB 433kB/s 
Building wheels for collected packages: resampy
  Running setup.py bdist_wheel for resampy ... error
  Complete output from command C:\Miniconda3\envs\sct\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\michael\\AppData\\Local\\Temp\\pip-build-7wr0ovfk\\resampy\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d C:\Users\michael\AppData\Local\Temp\tmpmu8ren92pip-wheel- --python-tag cp35:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.5
  creating build\lib.win-amd64-3.5\resampy
  copying resampy\core.py -> build\lib.win-amd64-3.5\resampy
  copying resampy\filters.py -> build\lib.win-amd64-3.5\resampy
  copying resampy\version.py -> build\lib.win-amd64-3.5\resampy
  copying resampy\__init__.py -> build\lib.win-amd64-3.5\resampy
  creating build\lib.win-amd64-3.5\resampy\data
  copying resampy\data\kaiser_best.npz -> build\lib.win-amd64-3.5\resampy\data
  copying resampy\data\kaiser_fast.npz -> build\lib.win-amd64-3.5\resampy\data
  running build_ext
  building 'resampy.interp' extension
  creating build\temp.win-amd64-3.5
  creating build\temp.win-amd64-3.5\Release
  creating build\temp.win-amd64-3.5\Release\resampy
  D:\Dev\VS\VC\BIN\amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Miniconda3\envs\sct\lib\site-packages\numpy\core\include -IC:\Miniconda3\envs\sct\include -IC:\Miniconda3\envs\sct\include -ID:\Dev\VS\VC\INCLUDE -ID:\Dev\VS\VC\ATLMFC\INCLUDE "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\winrt" -ID:\Dev\VS\VC\include "-IC:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\um" "-IC:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\ucrt" /Tcresampy/interp.c /Fobuild\temp.win-amd64-3.5\Release\resampy/interp.obj
  interp.c
  c1: fatal error C1083: Cannot open source file: 'resampy/interp.c': No such file or directory
  error: command 'D:\\Dev\\VS\\VC\\BIN\\amd64\\cl.exe' failed with exit status 2

  ----------------------------------------
  Failed building wheel for resampy
  Running setup.py clean for resampy
Failed to build resampy
Installing collected packages: Cython, resampy
  Running setup.py install for resampy ... done
Successfully installed Cython-0.24 resampy-0.1.0

Let me know if you need any further info from me.

Coverage.py warning: No data was collected.

Hi, when I try to run tests, they do not pass. I get this warning.

+ py.test-2
========================================== test session starts ==========================================
platform linux2 -- Python 2.7.12, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
rootdir: /home/user/rpmbuild/BUILD/resampy-0.1.4, inifile: setup.cfg
plugins: mock-1.2, faulthandler-1.3.0, cov-2.2.1
collected 0 items 
Coverage.py warning: No data was collected.

--------------------------- coverage: platform linux2, python 2.7.12-final-0 ----------------------------
Name                  Stmts   Miss  Cover   Missing
---------------------------------------------------
resampy/__init__.py       4      4     0%   3-7
resampy/core.py          25     25     0%   3-111
resampy/filters.py       39     39     0%   3-195
resampy/version.py        3      3     0%   3-6
---------------------------------------------------
TOTAL                    71     71     0%
===================================== no tests ran in 0.02 seconds ======================================
error: Bad exit status from /var/tmp/rpm-tmp.fXGZ33 (%check)

Could you give me a hint where is the problem?

Maximum and Minimum Amplitude

Following using resamply with default arguments, the signal amplitude is sometimes larger than the maximum energy. For a waveform, the amplitude sometimes is smaller / larger than [-1, 1].

What is a safe way of dealing with this without messing up the quality of the audio?

I'm new to DSP. Forgive any naivete.

Don't know how to compile resampy/interp.pyx

Hi! pip install resampy gives me:

building 'resampy.interp' extension
error: Don't know how to compile resampy/interp.pyx

The problem is that I can't get librosa installed anymore because librosa needs resampy...

Help with prior solution (Installation error - interp.c #22)

About a year ago Orchidas posted on Github a solution for #22 Librosa Resampy problem.

The solution posted by Orchidas was:
Thanks so much. So MinGW-64 just does not work. I downloaded MS Visual Studio for Python 2.7 from thislink. Then, I had to use
python setup.py build_ext --inplace --compiler=msvc python setup.py install
That worked. So now I have resampy, and hence librosa! Thanks for your support.

End of solution.

I am on Windows 10 and Python 3.5.3 and have been using pip.

I am a bit of a novice in this area and would ask for your guidance.

The solution appears to be running two python scripts.

What else do I need to do, for example do I have to have a certain current directory and path statement.
There are allot of setup.py on the system. Which one do I need. As you can see I am a novice.

If you could guide me I would really appreciate it. My objective is to have resampy and librosa.
Thanks for any help

multi-channel support

The current cython implementation only supports 1d-input. We should fix this to arbitrary dimensional input, possibly via reshaping to/from 2d.

Quality issues?

Out of curiosity I did a test similar to this on the various resampling methods available in librosa. The test resamples an exponentially swept sine from 96kHz down to 44.1kHz. The test signal is 8 seconds long, and at around 7.2 seconds the swept sine passes the Nyquist frequency of the downsampled rate.

Considering that the resampy algorithm has a sound theoretical background straight from a JOS publication and is librosa's default I expected it to be very high quality. However what I got was somewhat surprising:

resampy_best

resampy_fast

scipy signal resample

scipy signal resample_poly

samplerate converters resample_sinc_best

samplerate converters resample_sinc_medium

samplerate converters resample_sinc_fastest

samplerate converters resample_linear

samplerate converters resample_zero_order_hold

full reproduction code
import time

import numpy as np
import matplotlib.pyplot as plt

import librosa
import librosa.display


def exp_swept_sine(f1, f2, sr, amp=1.0, t=1.0):
    num_samples = int(t * sr)
    ts = np.arange(num_samples) / sr
    L = t / np.log(f2 / f1)
    wave = amp * np.sin(2.0 * np.pi * f1 * L * (np.exp(ts / L) - 1))
    return wave


def analyze_and_plot(wave, sr, method_name, runtime):
    hop_length = 256
    S = librosa.stft(wave, hop_length=hop_length)

    fig, ax = plt.subplots(1, 1, figsize=(20, 10))
    img = librosa.display.specshow(
        librosa.amplitude_to_db(np.abs(S), ref=np.max, amin=1e-10, top_db=180.0),
        y_axis='log',
        x_axis='time',
        sr=sr,
        ax=ax,
        hop_length=hop_length,
    )
    plt.colorbar(img, ax=ax)
    fig.suptitle("{} ({:.1f} ms)".format(method_name, runtime * 1000))
    fig.tight_layout()
    fig.savefig("/tmp/{}.png".format(method_name))
    plt.show()


def multi_check():
    sr1 = 96000
    sr2 = 44100
    wave1 = exp_swept_sine(f1=20, f2=sr1/2, sr=sr1, amp=0.5, t=8.0)

    methods = [(
        "resampy_best",
        lambda: librosa.resample(wave1, sr1, sr2, res_type="kaiser_best")
    ), (
        "resampy_fast",
        lambda: librosa.resample(wave1, sr1, sr2, res_type="kaiser_fast")
    ), (
        "scipy.signal.resample",
        lambda: librosa.resample(wave1, sr1, sr2, res_type="scipy")
    ), (
        "scipy.signal.resample_poly",
        lambda: librosa.resample(wave1, sr1, sr2, res_type="polyphase")
    ), (
        "samplerate.converters.resample_sinc_best",
        lambda: librosa.resample(wave1, sr1, sr2, res_type="sinc_best")
    ), (
        "samplerate.converters.resample_sinc_medium",
        lambda: librosa.resample(wave1, sr1, sr2, res_type="sinc_medium")
    ), (
        "samplerate.converters.resample_sinc_fastest",
        lambda: librosa.resample(wave1, sr1, sr2, res_type="sinc_fastest")
    ), (
        "samplerate.converters.resample_linear",
        lambda: librosa.resample(wave1, sr1, sr2, res_type="linear")
    ), (
        "samplerate.converters.resample_zero_order_hold",
        lambda: librosa.resample(wave1, sr1, sr2, res_type="zero_order_hold")
    )]

    for method_name, func in methods:
        t1 = time.time()
        wave2 = func()
        t2 = time.time()
        runtime = t2 - t1
        print("{:<50s} runtime: {:.1f} ms".format(method_name, runtime * 1000))
        analyze_and_plot(wave2, sr2, method_name, runtime)


if __name__ == "__main__":
    multi_check()

Any ideas why resampy shows such strong distortion?

Non-uniform sample positions

One of the benefits of sinc interpolation is that it directly allows us to query at arbitrary time-steps. Right now, we only support uniformly spaced samples, but it would be pretty easy to extend the API to support arbitrary sampling.

Having this would allow us to easily implement various audio effects like tape-speed wobble.

[JOSS review] Tests

A couple of sub-issues here:

  • Why are tests in the top-level directory, rather than under the package? If tests are installed, users can easily verify that the software is properly installed, for example by running nosetests resampy. As it stands, users will need to download the source, build the extensions and then run the tests from the source tree.

  • Having said that, even after building the package, I get the following test errors (maybe I'm doing it wrong?):

D-173-250-236-94:resampy (master) $nosetests
EEEEEEEE.E.EEE
======================================================================
ERROR: test_core.test_shape
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/arokem/anaconda/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
TypeError: test_shape() missing 1 required positional argument: 'axis'

======================================================================
ERROR: test_core.test_bad_sr
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/arokem/anaconda/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
TypeError: test_bad_sr() missing 2 required positional arguments: 'sr_orig' and 'sr_new'

======================================================================
ERROR: test_core.test_bad_rolloff
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/arokem/anaconda/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
TypeError: test_bad_rolloff() missing 1 required positional argument: 'rolloff'

======================================================================
ERROR: test_core.test_bad_precision
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/arokem/anaconda/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/Users/arokem/source/resampy/tests/test_core.py", line 41, in test_bad_precision
    resampy.resample(x, 100, 50, filter='sinc_window', precision=-1)
  File "/Users/arokem/source/resampy/resampy/core.py", line 98, in resample
    interp_win, precision, _ = get_filter(filter, **kwargs)
  File "/Users/arokem/source/resampy/resampy/filters.py", line 159, in get_filter
    return getattr(sys.modules[__name__], name_or_function)(**kwargs)
  File "/Users/arokem/source/resampy/resampy/filters.py", line 108, in sinc_window
    raise ValueError('Invalid precision: precision={}'.format(precision))
ValueError: Invalid precision: precision=-1

======================================================================
ERROR: test_core.test_bad_num_zeros
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/arokem/anaconda/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/Users/arokem/source/resampy/tests/test_core.py", line 47, in test_bad_num_zeros
    resampy.resample(x, 100, 50, filter='sinc_window', num_zeros=0)
  File "/Users/arokem/source/resampy/resampy/core.py", line 98, in resample
    interp_win, precision, _ = get_filter(filter, **kwargs)
  File "/Users/arokem/source/resampy/resampy/filters.py", line 159, in get_filter
    return getattr(sys.modules[__name__], name_or_function)(**kwargs)
  File "/Users/arokem/source/resampy/resampy/filters.py", line 105, in sinc_window
    raise ValueError('Invalid num_zeros: num_zeros={}'.format(num_zeros))
ValueError: Invalid num_zeros: num_zeros=0

======================================================================
ERROR: test_core.test_dtype
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/arokem/anaconda/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
TypeError: test_dtype() missing 1 required positional argument: 'dtype'

======================================================================
ERROR: test_core.test_bad_window
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/arokem/anaconda/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/Users/arokem/source/resampy/tests/test_core.py", line 62, in test_bad_window
    resampy.resample(x, 100, 200, filter='sinc_window', window=np.ones(50))
  File "/Users/arokem/source/resampy/resampy/core.py", line 98, in resample
    interp_win, precision, _ = get_filter(filter, **kwargs)
  File "/Users/arokem/source/resampy/resampy/filters.py", line 159, in get_filter
    return getattr(sys.modules[__name__], name_or_function)(**kwargs)
  File "/Users/arokem/source/resampy/resampy/filters.py", line 99, in sinc_window
    raise TypeError('window must be callable, not type(window)={}'.format(type(window)))
TypeError: window must be callable, not type(window)=<class 'numpy.ndarray'>

======================================================================
ERROR: test_core.test_short_signal
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/arokem/anaconda/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/Users/arokem/source/resampy/tests/test_core.py", line 69, in test_short_signal
    resampy.resample(x, 4, 1)
  File "/Users/arokem/source/resampy/resampy/core.py", line 94, in resample
    'resample from {}->{}'.format(x.shape[axis], sr_orig, sr_new))
ValueError: Input signal length=2 is too small to resample from 4->1

======================================================================
ERROR: test_filters.test_filter_sinc
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/arokem/anaconda/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
TypeError: test_filter_sinc() missing 5 required positional arguments: 'filt', 'window', 'num_zeros', 'precision', and 'rolloff'

======================================================================
ERROR: test_filters.test_filter_missing
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/arokem/source/resampy/resampy/filters.py", line 164, in get_filter
    return load_filter(name_or_function)
  File "/Users/arokem/source/resampy/resampy/filters.py", line 193, in load_filter
    data = np.load(pkg_resources.resource_filename(__name__, fname))
  File "/Users/arokem/anaconda/lib/python3.5/site-packages/numpy/lib/npyio.py", line 362, in load
    fid = open(file, "rb")
FileNotFoundError: [Errno 2] No such file or directory: '/Users/arokem/source/resampy/resampy/data/bad name.npz'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/arokem/anaconda/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/Users/arokem/source/resampy/tests/test_filters.py", line 41, in test_filter_missing
    resampy.filters.get_filter('bad name')
  File "/Users/arokem/source/resampy/resampy/filters.py", line 167, in get_filter
    '{}'.format(name_or_function))
NotImplementedError: Cannot load filter definition for bad name

======================================================================
ERROR: test_quality.test_quality_sine
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/arokem/anaconda/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
TypeError: test_quality_sine() missing 4 required positional arguments: 'sr_orig', 'sr_new', 'fil', and 'rms'

======================================================================
ERROR: test_quality.test_quality_sweep
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/arokem/anaconda/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
TypeError: test_quality_sweep() missing 4 required positional arguments: 'sr_orig', 'sr_new', 'fil', and 'rms'

----------------------------------------------------------------------
Ran 14 tests in 0.348s

FAILED (errors=12)

GCC failure with pip, virtualenv - solved by installing python-devel

tl;dr - don't forget to install python-devel on a new system when trying to get resampy installed!

Not a bug, just an oversight leading to confusion. Posting this for posterity, I'm sure someone else will run into this issue at some point.

Librosa bought me here. My issue is pretty close to this issue.

System: Fedora 25, python 3.5.2, pip 9.0.1, virtualenv 15.1.0
gcc (GCC) 6.2.1 20160916 (Red Hat 6.2.1-2)

pip install resampy fails with

creating build/temp.linux-x86_64-3.5/resampy
    gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/home/mike/ve/ml/lib/python3.5/site-packages/numpy/core/include -I/usr/include/python3.5m -c resampy/interp.c -o build/temp.linux-x86_64-3.5/resampy/interp.o
    resampy/interp.c:24:20: fatal error: Python.h: No such file or directory
     #include "Python.h"
                        ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1

I cloned the git repo and ran python setup.py install and got

running build_ext
building 'resampy.interp' extension
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/home/mike/ve/ml/lib/python3.5/site-packages/numpy/core/include -I/usr/include/python3.5m -c resampy/interp.c -o build/temp.linux-x86_64-3.5/resampy/interp.o
gcc: error: resampy/interp.c: No such file or directory

pip install -e resampy gives the identical error, pip install . likewise.

And then I'm like, wait a minute, did I install python-devel?

sudo dnf install python-devel
pip install resampy

success

D'oh!

error: unknown file type '.pyx' (from 'resampy/interp.pyx')

Hi @bmcfee, I'm trying to install librosa with Travis CI, e.g.

install: 
  - pip install .

where setup.py contains

    install_requires=['librosa'])

per usual, but the build fails when it gets to resampy which I guess means there are unlisted dependencies (perhaps something included with miniconda?). Could you share any insight?

Running setup.py install for resampy
    building 'resampy.interp' extension
    error: unknown file type '.pyx' (from 'resampy/interp.pyx')
    Complete output from command /home/travis/virtualenv/python3.5.0/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-ahgqzlpm/resampy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-21d2vxi7-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/travis/virtualenv/python3.5.0/include/site/python3.5:

issue install with both conda and pip

hi,
i'm using Python 3.6.1 :: Anaconda 4.4.0 (64-bit) on Windows 8.1 with pip 9.0.1.
i tried conda install -c conda-forge resampy and got this:

Fetching package metadata ..............
Solving package specifications:  .
UnsatisfiableError: The following specifications were found to be in conflict: \n
 - python 3.6*
 - resampy -> numpy 1.10* -> python 2.7*
Use "conda info<package>" to see the dependencies for each package.

how should i proceed?
thank you in advance.

when using pip install resamply i get the error below:
error: [WinError 2] impossible to find specified file.

C:\Users\Niccolò>pip install resampy
Collecting resampy
  Using cached resampy-0.1.5.tar.gz
Requirement already satisfied: numpy>=1.10 in c:\users\niccolò\anaconda3\lib\sit
e-packages (from resampy)
Requirement already satisfied: scipy>=0.13 in c:\users\niccolò\anaconda3\lib\sit
e-packages (from resampy)
Requirement already satisfied: six>=1.3 in c:\users\niccolò\anaconda3\lib\site-p
ackages (from resampy)
Requirement already satisfied: Cython>=0.23 in c:\users\niccolò\anaconda3\lib\si
te-packages (from resampy)
Building wheels for collected packages: resampy
  Running setup.py bdist_wheel for resampy ... error
  Complete output from command C:\Users\Niccolò\Anaconda3\python.exe -u -c "impo
rt setuptools, tokenize;__file__='C:\\Users\\NICCOL~1\\AppData\\Local\\Temp\\pip
-build-u82okf0h\\resampy\\setup.py';f=getattr(tokenize, 'open', open)(__file__);
code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec
'))" bdist_wheel -d C:\Users\NICCOL~1\AppData\Local\Temp\tmp3d4m0sydpip-wheel- -
-python-tag cp36:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.6
  creating build\lib.win-amd64-3.6\resampy
  copying resampy\core.py -> build\lib.win-amd64-3.6\resampy
  copying resampy\filters.py -> build\lib.win-amd64-3.6\resampy
  copying resampy\version.py -> build\lib.win-amd64-3.6\resampy
  copying resampy\__init__.py -> build\lib.win-amd64-3.6\resampy
  creating build\lib.win-amd64-3.6\resampy\data
  copying resampy\data\kaiser_best.npz -> build\lib.win-amd64-3.6\resampy\data
  copying resampy\data\kaiser_fast.npz -> build\lib.win-amd64-3.6\resampy\data
  running build_ext
  error: [WinError 2] Impossibile trovare il file specificato
  ----------------------------------------
  Failed building wheel for resampy
  Running setup.py clean for resampy
Failed to build resampy
Installing collected packages: resampy
  Running setup.py install for resampy ... error
    Complete output from command C:\Users\Niccolò\Anaconda3\python.exe -u -c "im
port setuptools, tokenize;__file__='C:\\Users\\NICCOL~1\\AppData\\Local\\Temp\\p
ip-build-u82okf0h\\resampy\\setup.py';f=getattr(tokenize, 'open', open)(__file__
);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'ex
ec'))" install --record C:\Users\NICCOL~1\AppData\Local\Temp\pip-8hjcgalk-record
\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.6
    creating build\lib.win-amd64-3.6\resampy
    copying resampy\core.py -> build\lib.win-amd64-3.6\resampy
    copying resampy\filters.py -> build\lib.win-amd64-3.6\resampy
    copying resampy\version.py -> build\lib.win-amd64-3.6\resampy
    copying resampy\__init__.py -> build\lib.win-amd64-3.6\resampy
    creating build\lib.win-amd64-3.6\resampy\data
    copying resampy\data\kaiser_best.npz -> build\lib.win-amd64-3.6\resampy\data
    copying resampy\data\kaiser_fast.npz -> build\lib.win-amd64-3.6\resampy\data
    running build_ext
    error: [WinError 2] Impossibile trovare il file specificato
    ----------------------------------------
Command "C:\Users\Niccolò\Anaconda3\python.exe -u -c "import setuptools, tokeniz
e;__file__='C:\\Users\\NICCOL~1\\AppData\\Local\\Temp\\pip-build-u82okf0h\\resam
py\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace(
'\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record
C:\Users\NICCOL~1\AppData\Local\Temp\pip-8hjcgalk-record\install-record.txt --si
ngle-version-externally-managed --compile" failed with error code 1 in C:\Users\
NICCOL~1\AppData\Local\Temp\pip-build-u82okf0h\resampy\
C:\Users\Niccolò>pip install resampy
Collecting resampy
  Using cached resampy-0.1.5.tar.gz
Requirement already satisfied: numpy>=1.10 in c:\users\niccolò\anaconda3\lib\sit
e-packages (from resampy)
Requirement already satisfied: scipy>=0.13 in c:\users\niccolò\anaconda3\lib\sit
e-packages (from resampy)
Requirement already satisfied: six>=1.3 in c:\users\niccolò\anaconda3\lib\site-p
ackages (from resampy)
Requirement already satisfied: Cython>=0.23 in c:\users\niccolò\anaconda3\lib\si
te-packages (from resampy)
Building wheels for collected packages: resampy
  Running setup.py bdist_wheel for resampy ... error
  Complete output from command C:\Users\Niccolò\Anaconda3\python.exe -u -c "impo
rt setuptools, tokenize;__file__='C:\\Users\\NICCOL~1\\AppData\\Local\\Temp\\pip
-build-iv7m1bg5\\resampy\\setup.py';f=getattr(tokenize, 'open', open)(__file__);
code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec
'))" bdist_wheel -d C:\Users\NICCOL~1\AppData\Local\Temp\tmphb69ebiupip-wheel- -
-python-tag cp36:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.6
  creating build\lib.win-amd64-3.6\resampy
  copying resampy\core.py -> build\lib.win-amd64-3.6\resampy
  copying resampy\filters.py -> build\lib.win-amd64-3.6\resampy
  copying resampy\version.py -> build\lib.win-amd64-3.6\resampy
  copying resampy\__init__.py -> build\lib.win-amd64-3.6\resampy
  creating build\lib.win-amd64-3.6\resampy\data
  copying resampy\data\kaiser_best.npz -> build\lib.win-amd64-3.6\resampy\data
  copying resampy\data\kaiser_fast.npz -> build\lib.win-amd64-3.6\resampy\data
  running build_ext
  error: [WinError 2] Impossibile trovare il file specificato
  ----------------------------------------
  Failed building wheel for resampy
  Running setup.py clean for resampy
Failed to build resampy
Installing collected packages: resampy
  Running setup.py install for resampy ... error
    Complete output from command C:\Users\Niccolò\Anaconda3\python.exe -u -c "im
port setuptools, tokenize;__file__='C:\\Users\\NICCOL~1\\AppData\\Local\\Temp\\p
ip-build-iv7m1bg5\\resampy\\setup.py';f=getattr(tokenize, 'open', open)(__file__
);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'ex
ec'))" install --record C:\Users\NICCOL~1\AppData\Local\Temp\pip-e9g4enf4-record
\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.6
    creating build\lib.win-amd64-3.6\resampy
    copying resampy\core.py -> build\lib.win-amd64-3.6\resampy
    copying resampy\filters.py -> build\lib.win-amd64-3.6\resampy
    copying resampy\version.py -> build\lib.win-amd64-3.6\resampy
    copying resampy\__init__.py -> build\lib.win-amd64-3.6\resampy
    creating build\lib.win-amd64-3.6\resampy\data
    copying resampy\data\kaiser_best.npz -> build\lib.win-amd64-3.6\resampy\data
    copying resampy\data\kaiser_fast.npz -> build\lib.win-amd64-3.6\resampy\data
    running build_ext
    error: [WinError 2] Impossibile trovare il file specificato
    ----------------------------------------
Command "C:\Users\Niccolò\Anaconda3\python.exe -u -c "import setuptools, tokeniz
e;__file__='C:\\Users\\NICCOL~1\\AppData\\Local\\Temp\\pip-build-iv7m1bg5\\resam
py\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace(
'\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record
C:\Users\NICCOL~1\AppData\Local\Temp\pip-e9g4enf4-record\install-record.txt --si
ngle-version-externally-managed --compile" failed with error code 1 in C:\Users\
NICCOL~1\AppData\Local\Temp\pip-build-iv7m1bg5\resampy\

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.