Listen to simple beep with python without external library

Using only the modules that come with the standard python 2.6 installation, could a simple beep sound be reproduced?

+19
python playback noise
Dec 17 '10 at 2:44
source share
2 answers

If you are using a Unix terminal, you can print "\ a" to get the terminal:

>>> def beep(): ... print "\a" >>> beep() 

Of course, this will print a new line too ... So sys.stdout.write("\a") could be better. But you have an idea.

+27
Dec 17 '10 at 3:01
source share

In the windows:

 import winsound # for sound import time # for sleep winsound.Beep(440, 250) # frequency, duration time.sleep(0.25) # in seconds (0.25 is 250ms) winsound.Beep(600, 250) time.sleep(0.25) 

34.4. winsound - Sound Interface for Windows:

http://docs.python.org/2.6/search.html?q=sound&check_keywords=yes&area=default

See also: Clean screen and beep for different platforms. (Python Recipe) http://code.activestate.com/recipes/577588-clear-screen-and-beep-for-various-platforms/

+15
Mar 08 '14 at 2:14
source share



All Articles