canberra-gtk-play
For simple bash scripts mplayer is probably a bit too heavy and too verbose in terms of output. A built-in option is canberra-gtk-play
which comes preinstalled on ubuntu:
canberra-gtk-play --file=/usr/share/sounds/gnome/default/alerts/drip.ogg
Note: it uses the alerts volume, and you must pass --file=
in order to play a file from a path.
It can also play a sound by id which represents the file name without extension of media files under /usr/share/sounds
(apparently this only works for sounds that are registered as part of a sound theme):
canberra-gtk-play --id="desktop-login"
canberra-gtk-play --id="message"
gst-launch-1.0/gst-launch-0.10
Another option is using the gstreamer command line tools which are present on most modern linux boxes:
gst-launch-1.0 playbin uri=file:///usr/share/sounds/ubuntu/stereo/message.ogg
To suppress all output redirect it to /dev/null
:
gst-launch-1.0 playbin uri=file:///usr/share/sounds/ubuntu/stereo/message.ogg > /dev/null 2>&1
Both gst-launch-1.0
and gst-launch-0.10
might be present on your system.
1Just in case you're looking for example files:
/usr/share/sounds
is a good place to look for them. – Martin Thoma – 2014-09-16T11:37:10.170