python-soundfile
python-soundfile copied to clipboard
Capture libmpg123/libsndfile warnings
Hi there, in #421 suppressing warnings from underlying libraries is discussed.
In my case I would like to capture the errors, in order to discard mp3s which trigger warnings.
I tried something like:
import librosa
import io
from contextlib import redirect_stderr
f = io.StringIO()
with redirect_stderr(f):
librosa.load('file.mp3')
But the errors go straight to stderr and are not captured by the context manager. Presumably something going on in a subprocess or something.
Any ideas on picking up libmpg123 warnings?