3

在 Urban Sound Dataset 的声音文件之一上使用以下代码时,

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

我收到以下警告,并且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

有谁知道我可以做些什么来解决这个问题?

4

1 回答 1

1

我最近也遇到了这个问题。in librosautils.py包具有如下验证功能:

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

并且np.isfinite(y).all()是验证之一。因此,如果 numpy 数组y在任何地方都不是有限的,这意味着hasy或类似的东西,python 将引发上述异常。只需检查您在上面使用的 numpy 变量并修改它们的无限部分。INFNaN

我希望这对你有帮助。

于 2019-08-26T06:51:01.117 回答