jiaaro / pydub

Manipulate audio with a simple and easy high level interface
http://pydub.com
MIT License
8.98k stars 1.05k forks source link

Disable pydub RuntimeWarning if not applicable to deployment #795

Closed chasemcdo closed 5 months ago

chasemcdo commented 5 months ago

Steps to reproduce

Expected behavior

An option to disable the pydub RuntimeWarning if it isn't applicable:

RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)

Our specific use case only needs access to .wav files which means these executables are not required and would simply be extra bloat in our system. It would be great if pydub could be configured to suppress this specific warning for similar use cases.

I am aware that this can be set on a python wide scope, but would rather not suppress all other RuntimeWarnings.

Actual behavior

Warning is displayed despite it not impacting our functionality.

Thanks for any help!

chasemcdo commented 5 months ago

Quickest fix for this was to simply catch the runtime warning on import. ie:

from warnings import catch_warnings
with catch_warnings(action="ignore", category=RuntimeWarning):
    from pydub import AudioSegment