问题描述
在Urban Sound数据集的一个声音文件上使用以下代码时,
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)
我收到以下警告和 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?
推荐答案
我最近也遇到了这个问题.librosa软件包中的 utils.py
具有如下验证功能:
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
和 np.isfinite(y).all()
是验证之一.因此,如果numpy数组 y
不是到处都是有限的,这意味着 y
具有 INF
, NaN
或类似的东西,python将引发上面的异常.只需检查上面使用的numpy变量并修改其无限部分即可.
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.
这篇关于ParameterError:音频缓冲区不是到处都是有限的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!