4

While using the following code on one of the sound files of Urban Sound Dataset,

s, r = librosa.load(train_filename[7543])
tonnetz = librosa.feature.tonnetz(y = librosa.effects.harmonic(s), sr = r)

I get the following warnings and ParameterError,

E:\installed_python_anaconda\lib\site-packages\librosa\util\utils.py:1467: RuntimeWarning: invalid value encountered in less if np.any(X < 0) or np.any(X_ref < 0):
E:\installed_python_anaconda\lib\site-packages\librosa\util\utils.py:1479: RuntimeWarning: invalid value encountered in maximum Z = np.maximum(X, X_ref).astype(dtype)
E:\installed_python_anaconda\lib\site-packages\librosa\util\utils.py:1480: RuntimeWarning: invalid value encountered in less bad_idx = (Z < np.finfo(dtype).tiny)


ParameterError: Audio buffer is not finite everywhere

Does anyone know what I can do to resolve the issue?

1
  • Feels like you're getting NaN or inf in your data. Check s and harmonics of it. Aug 18, 2018 at 15:25

1 Answer 1

3

I recently encountered with this problem as well. The utils.py in librosa package has validation functions like this:

Returns
-------
valid : bool
    True if all tests pass

Raises
------
ParameterError
    If `y` fails to meet the following criteria:
        - `type(y)` is `np.ndarray`
        - `y.dtype` is floating-point
        - `mono == True` and `y.ndim` is not 1
        - `mono == False` and `y.ndim` is not 1 or 2
        - `np.isfinite(y).all()` is not True

and np.isfinite(y).all() is one of the validations. So if the numpy array y is not finite everywhere, which means y has INF, NaN or something similar, python will raise the exception above. Just check the numpy variables you used above and modify their infinite parts.

I hope this will be helpful to you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.