Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python library to beep motherboard speaker

Tags:

python

speaker

I need a python way to beep the system/motherboard speaker independent of the speakers attached to my computer. I don't always have the speakers turned on, so i need to beep the motherboard speaker.

All the libraries i've seen (winsound especially), just play a sound through the speakers attached to my computer. I'd like to beep the system/motherboard speaker.

Is there a way to beep the system speaker? I'm okay with Windows dependent libraries.

like image 623
user208145 Avatar asked Nov 28 '13 02:11

user208145


2 Answers

just print '\a' to stdout

print '\a'   # for python3, print('\a')

if you don't want a newline be printed

print '\a\b', # for python3. print('\a\b', end='')
sys.stdout.flush()
like image 174
d2207197 Avatar answered Nov 19 '22 02:11

d2207197


Use a call to the command line:

>>> from subprocess import call
>>> call(["echo", u'\x07'])

As $ echo ^G - ^G is the character for motherboard beep - will produce that sound, to do it with python you only have to execute the comand.

like image 1
aIKid Avatar answered Nov 19 '22 03:11

aIKid