python-soundfile icon indicating copy to clipboard operation
python-soundfile copied to clipboard

Capture libmpg123/libsndfile warnings

Open leoauri opened this issue 8 months ago • 1 comments

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?

leoauri avatar May 30 '24 12:05 leoauri