Play sound
In Python, for playing sound there are several options (see http://stackoverflow.com/search?q=python+play+sound). However, under Ubuntu I didn’t have much success with portable solutions :( I got most luck with wx.Sound('sound.wav')
which used to work for a while but then it stopped… So I’ve decided to just call mplayer to do the job.
#!/usr/bin/env python import os SOUND = 'Gong.wav' command = 'mplayer %s 1>/dev/null 2>&1' % SOUND os.system(command)
Not too elegant but at least it works…
Notes
If you want to launch mplayer in the background without any verbosity, here is how to do that:
mplayer music.mp3 &>/dev/null </dev/null &
Update (20101016): I forgot to mention that with the help of mplayer, you can play videos too. Just pass an AVI instead of an MP3, for instance.
Here is a Linux/Windows solution that should do the trick:
Tested with “Ozone – Dragostea din tei (original romanian).mp3” … ;-)