How can I play a system sound with Python?

I am writing a small reminder-app and want to play a system sound once the timer has reached 0. What is the easiest way to play that sound, and which sound would you recommend?

Asked By: Ingo

||

The easiest way would probably be to shell out:

system("/usr/bin/canberra-gtk-play --id='bell'")

This will work in other programming languages as well.

/usr/bin/canberra-gtk-play will play a sound from the current sound theme. See the freedesktop.org sound naming spec for a list of available sounds and their meanings. Beware that (as far as I know) there isn’t a sound theme that provides all of these sounds.

Use ls /usr/share/sounds/ubuntu/stereo to see what sounds are supported by the ‘ubuntu’ sound theme which is default, and rarely changed (due to no easy way to install sound themes) on Ubuntu.

Answered By: dv3500ea

The following works in Linux and MacOS (haven’t tried Windows):

print('a')
Answered By: Nuts