Question

I could not find a suitable music player for my text-based python program, as they were all based off of pygame. Thus, I resorted to use my sox program from python with an os.system. However, whenever I play a file with play mymusic.wav, it prints this:

flap.wav:
 File Size: 11.3k     Bit Rate: 257k
  Encoding: Signed PCM    
  Channels: 1 @ 16-bit   
Samplerate: 16000Hz      
Replaygain: off         
  Duration: 00:00:00.35  
In:100%  00:00:00.35 [00:00:00.00] Out:15.6k [      |      ]        Clip:0    
Done.

How can I stop it from printing this?

Was it helpful?

Solution

So the output can just be redirected to /dev/null like:

import subprocess
import os

devnull = open(os.devnull,"w")
subprocess.call(['play', 'flap.wav'], stdout=devnull)
devnull.close()

That will just pipe anything your call sends to stdout into /dev/null.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top