New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Supress "PySoundFile failed. Trying audioread instead." warning #1015
Comments
It's a warning, not an error. This warning will always occur when loading mp3 because libsndfile does not (yet/currently) support the mp3 format. Librosa tries to use libsndfile first, and if that fails, it will fall back on the audioread package, which is a bit slower and more brittle, but supports more formats.
Yes, you can always filter warnings. https://docs.python.org/3/library/warnings.html |
I think we can say that the Q has been answered. I am going to close this. Feel free to re-open if needed. |
Any idea how to fix it? |
There is nothing to fix: this is operating as intended. Again, this is not an error, it is a warning. Your code will work just fine, it just will fall back on the (slower) audioread decoder. This is unavoidable for now, since libsndfile still does not support mp3. If you're really concerned about speed, you could transcode your mp3s into a more permissive format (eg ogg vorbis). |
Ok, i got it now. |
Any idea how to avoid getting this warnings printed on STDOUT? I tried launching script with
At the beginning of the scripts and this User Warnings keep poping out. Edit: Nevermind it was my issue. |
@bmcfee I encountered the same issue and thanks for the address. |
Sure. The "brittle" comment mainly refers to software health. The audioread package has very minimal test coverage, and its dependency chain varies substantially across platforms and environments. Much of this is hidden from the end user, but it does make it difficult to debug and diagnose errors. In terms of quality degradation, it should be fine. In principle, these formats should all decode to the same bit stream, but there will always be subtle differences arising from frame alignment, floating point rounding error, etc. MP3 decoders are notorious for this kind of thing. |
This is definitely a problem as of today. When I get this warning, my python process hangs. So, i am loading an mp3 e.g. but this has problems. Cannot explain, but I am seeing this behavior, and I am working already many hours on this. |
Again, this is a warning and not an error. If it's hanging when you load an mp3, that's a problem with audioread (or more likely, whatever decoder it is using) and not with librosa. |
Ok, I found out why this happens. When the wav file is corrupt it gives this warning. I later found that my wavs sometimes were corrupt. It should crash, but the process just hangs. |
The intention of the warning is good, but in practice it can still be a bit counter productive, e.g. when working with mp3 files. In this case the warnings conveys little information after having seen it many times. The issue is that the warning encourages "bad", i.e., overly broad or even complete disabling of warnings like suggested in the post above. Turning off all warnings to silence this particular warning is harmful, because it can hide relevant warnings. Setting up a specific filterwarning is possible, but somewhat tricky and tedious, and the above "solution" is evidence that most users don't want to spend the time to do it properly. Instead I'd love to have a boolean kwarg |
I appreciate the motivation here, but I expect the entire point to be moot in the very near future. libsndfile supports mp3 now, and we're basically waiting on a release of python-soundfile (currently on b6 for the 0.11 release) for this to be supported out of the box with no additional effort from our side. Once soundfile releases with mp3 support, this warning should almost never appear - and when it does, it's a sign that something actually is very wrong! At any rate, our eventual plan is to deprecate and remove audioread support #1456 , but it is a bit of a question-mark about how long that will take in practice based on release cycles. |
@bmcfee Great to hear, then I'll hold my horses 😉 |
h |
Sorry, my bad I had to install ffmpeg apt install ffmpeg https://stackoverflow.com/questions/62774301/can%C2%B4t-use-librosa-with-python-3 |
I was working with .flac files using librosa and I am getting this warning: |
Either your flac files are corrupted, or your libsndfile was compiled without flac support. For the latter, you can check it by running >>> import soundfile
>>> soundfile.available_formats() to make sure that FLAC is listed. |
I'm trying to load an mp3 file with librosa.load(path) and it returns the following warning:
As I'm doing this multiple times it floods the stdout.
So I have some questions:
The text was updated successfully, but these errors were encountered: