Skip to content
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

Capture libmpg123/libsndfile warnings #435

Open
leoauri opened this issue May 30, 2024 · 1 comment
Open

Capture libmpg123/libsndfile warnings #435

leoauri opened this issue May 30, 2024 · 1 comment

Comments

@leoauri
Copy link

leoauri commented May 30, 2024

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?

@bastibe
Copy link
Owner

bastibe commented May 31, 2024

Presumably, libsndfile is writing straight to STDERR. It seems a bit odd that redirect_stderr doesn't catch that, but perhaps it only operates on the python level?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants