Open louisfh opened 1 year ago
https://sourceforge.net/p/mpg123/bugs/275/ This discussion suggests it is an issue that libmpg123 encounters if the LAME/Xing header for an mp3 file does not match the file contents. e.g. if a Variable bitrate file has constant bit rate information in the Xing header.
Reproducible example with an audio file, and specific version numbers for librosa, libmpg123 (if used by librosa), or whatever underlying package is relevant
Mp3 file from here: https://xeno-canto.org/157067
Warning is being raised by librosa (or something under the hood that librosa uses, like audioread). Using librosa 0.10.1
:
import librosa
broke_file = "/path/to/157067.mp3"
librosa.load(broke_file)
raises the warning. We could filter warnings at the point of loading audio.
It's not really an us problem, but it is an annoying thing for users to see flooding their stdout. Hiding warnings (or some subset of them? If that's possible) might be helpful for helping new users not to be overwhelmed.
let's find a way to filter it out as specifically as possible
I have tried wrapping the librosa.load
call in our Audio module with a warnings filter, e.g.:
## Load samples ##
# ignore the Xing warnings from librosa here
with warnings.catch_warnings():
warnings.simplefilter("ignore")
samples, sr = librosa.load(
path,
sr=sample_rate,
res_type=resample_type,
mono=True,
offset=offset,
duration=duration,
dtype=None,
)
But I still can't silence the warning. @sammlapp I don't think I understand how Warnings are handled well enough to fix this issue.
I also tried wrapping the import statements with the warning filter, e.g.
with warnings.catch_warnings():
# ignore all warnings
warnings.simplefilter("ignore")
import librosa
import librosa.core.audio
import soundfile
OK it looks like the problem might be that libmpg123 is printing directly to stderr. It's a C library, not a python package, so I assume the Python warnings system is not going to catch these. You should be able to catch this with redirect_stderr, but apparently that doesn't work either. https://github.com/bastibe/python-soundfile/issues/435
These warnings/errors are being raised on reading some mp3 files.
I tried converting some mp3 files that raise this warning to WAV by doing:
And they still raise the warning.