Closed albertz closed 5 years ago
Ok, after updating to librosa 0.6.2, this issue seems to be gone. So maybe this can be closed. But I guess it's useful to have this as a reference for others who stumble upon this exception.
Hello. Glad to find out that you sorted out the issue by updating.
For completeness, what was the shape
of the audio
array?
audio.shape == (22912,)
. You can see that also in the stacktrace output.
I'm glad that this is now fixed, but I'm a bit confused about where it came from. As far as I can tell, nothing has changed in the mel filter construction code between 0.5.1 and now (0.6.2/3). Did anything else change in the dependencies when you upgraded to 0.6.2?
I also wondered about that. I briefly went through the librosa code and did not really understand how this could happen. I was guessing that it maybe was due to the caching mechanism somehow, or maybe multi-threading related, but instead of debugging further, I was just trying the latest version (also because I knew that it has worked in the past, so for some reason I somehow got the older version installed). When upgrading librosa again, as far as I remember, no other package was updated.
I dug into this a bit, and I think the only thing that could have caused this was a change we made in hz_to_mel
to support arbitrary array shape inputs (including scalars) #628. The old (0.5.1) implementation always cast to 1d, while post-#628 code preserves the shape of the input.
I don't quite see how exactly this would cause the problem we're seeing here, unless there's some gross incompatibility with the frequency ranges in the filter bank construction, but seeing as the current behavior is correct, I feel okay closing this out.
I am also having same kind of issue. Can anyone help me pls..?
I am also having same kind of issue. Can anyone help me pls..?
Just update to librosa 0.6.2.
Ok thanks 😊
For documentation.
In numpy 1.16 numpy changed linspace
to consider the input shape.
This causes in the old hz_to_mel
this bug, because it returned always an array with at least 1d.
Numpy 1.16: https://docs.scipy.org/doc/numpy/release.html
Start and stop arrays for linspace, logspace and geomspace These functions used to be limited to scalar stop and start values, but can now take arrays, which will be properly broadcast and result in an output which has one axis prepended. This can be used, e.g., to obtain linearly interpolated points between sets of points.
Thanks @boeddeker for tracking that down! I would never have figured that out.
Seeing as it's far too late to retroactively add a version pin on old librosa packages, I think there's nothing to be done here.
Same issue, which numpy version is compatible with '0.5.1'?
import librosa
librosa.filters.mel(22050, 2048, 80, 0, 8000.0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/data/Anaconda/lib/python3.6/site-packages/librosa/filters.py", line 247, in mel
lower = -ramps[i] / fdiff[i]
ValueError: operands could not be broadcast together with shapes (1,1025) (0,)
librosa.__version__
'0.5.1'
np.__version__
'1.16.1'
At least I was able to run it with numpy==1.14.3
https://github.com/mozilla/TTS/blob/master/requirements.txt
@mrgloom I'm glad that you got it working, but your librosa version is several years out of date. I'd strongly recommend upgrading.
At least I was able to run it with
numpy==1.14.3
https://github.com/mozilla/TTS/blob/master/requirements.txt
Thank you so much. You saved our project.
Description
I get an exception in
filters.mel
:ValueError: operands could not be broadcast together with shapes (1,201) (0,)
. In linelower = -ramps[i] / fdiff[i]
, wherefdiff = array([], shape=(130, 0), dtype=float64)
.The same problem was also reported here:
Steps/Code to Reproduce
Example:
Expected Results
It works. It has also worked in the past.
Actual Results
Exception:
Versions