Recipe 10.11. Checking Your Windows Sound SystemCredit: Anand Pillai ProblemYou need to check whether the sound subsystem on your Windows PC is properly configured. SolutionThe winsound module of the Python Standard Library makes this check really simple: import winsound try: winsound.PlaySound("*", winsound.SND_ALIAS) except RuntimeError, e: print 'Sound system has problems,', e else: print 'Sound system is OK' DiscussionThe sound system might pass this test and still be unable to produce sound correctly, due to a variety of possible problemsstarting from simple ones such as powered loudspeakers being turned off (there's no sensible way you can check for that in your program!), all the way to extremely subtle and complicated ones. When sound is a problem in your applications, using this recipe at least you know whether you should be digging into a subtle issue of device driver configuration or start by checking whether the loudspeakers are on! See AlsoDocumentation on the Python Standard Library winsound module. |