在 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
有谁知道我可以做什么来解决这个问题?
我最近也遇到了这个问题。这utils.py
librosa 包中有这样的验证函数:
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()
是验证之一。所以如果 numpy 数组y
并非处处有限,这意味着y
has INF
, NaN
或者类似的东西,python 会引发上面的异常。只需检查上面使用的 numpy 变量并修改它们的无限部分即可。
我希望这对您有帮助。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)