【问题标题】:ParameterError: Audio buffer is not finite everywhereParameterError:音频缓冲区并非到处都是有限的
【发布时间】:2019-01-25 04:19:30
【问题描述】:

在 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

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

【问题讨论】:

  • 感觉你的数据中出现了 NaN 或 inf。检查s 及其谐波。

标签: python-3.x machine-learning librosa


【解决方案1】:

我最近也遇到了这个问题。 librosa 包中的utils.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 并非处处有限,这意味着 y 具有 INFNaN 或类似的东西,python 将引发上述异常。只需检查您在上面使用的 numpy 变量并修改它们的无限部分。

希望对你有帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多