pydub
pydub copied to clipboard
How can I hide 'pydub' output information?
My code:
from pydub import generators
from pydub.playback import play
play(generators.Sine(440).to_audio_segment(duration=1500))
In the console output:
Input #0, wav, from '/var/folders/_7/0q83l2vn4zjd7zgqpy3v97840000gn/T/tmphlm6i9s_.wav':
Duration: 00:00:01.50, bitrate: 705 kb/s
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 1 channels, s16, 705 kb/s
Same question
If you install simpleaudio (e.g. run pip install simpleaudio
),
it should play audio without emitting any text.
N.B. This output is coming from ffplay, which is a used because simpleaudio is not installed.
We don't currently have any way to suppress output from ffplay.
We would need to pass the arguments -loglevel -8
to the ffplay call.
Arguably, this should be the default.
simpleaudio is not available on my device.
I find none of the answers mentioned above work.
I finally managed to hide the pydub playback output by using a subprocess.
If you are interested, I implemented at:
https://github.com/eliranwong/UniqueBible/blob/main/util/RemoteCliMainWindow.py#L287