Python Sound ("Bell") Python Sound ("Bell") python python

Python Sound ("Bell")


Have you tried :

import syssys.stdout.write('\a')sys.stdout.flush()

That works for me here on Mac OS 10.5

Actually, I think your original attempt works also with a little modification:

print('\a')

(You just need the single quotes around the character sequence).


If you have PyObjC (the Python - Objective-C bridge) installed or are running on OS X 10.5's system python (which ships with PyObjC), you can do

from AppKit import NSBeepNSBeep()

to play the system alert.


I tried the mixer from the pygame module, and it works fine. First install the module:

$ sudo apt-get install python-pygame

Then in the program, write this:

from pygame import mixermixer.init() #you must initialize the mixeralert=mixer.Sound('bell.wav')alert.play()

With pygame you have a lot of customization options, which you may additionally experiment with.