The code is shamefully short, but here it is. Now you can listen to the many sound files in wave (.wav) format and boing, chirp, chime, bark, booh, laugh and mooh at the people around you.

# play a wave sound on a Windows Box
# Python23 tested   vegaseat   2/8/2005

import winsound
import time

# pick a wave file supplied by Windows XP or one of your own ...
# soundfile = "c:\\Windows\\Media\\chimes.wav"
# Python also accepts the forward slash
soundfile = "c:/Windows/Media/chimes.wav"
winsound.PlaySound(soundfile, winsound.SND_FILENAME|winsound.SND_ASYNC)

# wait one and a half seconds
# play the system exit sound if set
winsound.PlaySound("SystemExit", winsound.SND_ALIAS)

Its so short that it doesn't exist? At least in my browser (Firefox), the box where the code should be is coming up as empty, and looking at the html source doesn't seem to yield the snippet.

Hey, thanks a lot for this code; it's been a huge help. I have one question though: is there any way to determine/modify the volume of the .wav files being played? Do you know of any way to make the program I wrote using your code louder?