Play those cute little Wave files (Python)

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
vegaseat vegaseat is offline Offline Feb 8th, 2005, 10:42 am |
0
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.
Quick reply to this message  
Python Syntax
  1. # play a wave sound on a Windows Box
  2. # Python23 tested vegaseat 2/8/2005
  3.  
  4. import winsound
  5. import time
  6.  
  7. # pick a wave file supplied by Windows XP or one of your own ...
  8. # soundfile = "c:\\Windows\\Media\\chimes.wav"
  9. # Python also accepts the forward slash
  10. soundfile = "c:/Windows/Media/chimes.wav"
  11. winsound.PlaySound(soundfile, winsound.SND_FILENAME|winsound.SND_ASYNC)
  12.  
  13. # wait one and a half seconds
  14. time.sleep(1.5)
  15. # play the system exit sound if set
  16. winsound.PlaySound("SystemExit", winsound.SND_ALIAS)
  17.  
0
tspyv tspyv is offline Offline | Jun 20th, 2006
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.
 
 

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC