Python Sound ("Bell")

I would certainly such as to have a python program sharp me when it has actually finished its job by making a beep sound. Presently, I make use of import os and afterwards make use of a command line speech program to claim "Process complete." I a lot instead it be a straightforward "bell."

I recognize that there is a function that can be made use of in Cocoa applications, NSBeep, yet I do not assume that has a lot anything to do with this.

I've additionally attempted


yet that really did not function.

I'm making use of a Mac, if you could not inform by my Cocoa comment, to make sure that might aid.

2019-12-02 02:50:47
Source Share
Answers: 2

Have you attempted :

import sys

That benefits me below on Mac OS 10.5

Actually, I assume your initial effort jobs additionally with a little alteration :


(You simply require the solitary quotes around the personality series).

2019-12-03 04:16:44

I needed to switch off the "Silence terminal bell" alternative in my energetic Terminal Profile in iTerm for print('\a') to function. It appeared to function great by default in Terminal.

You can additionally make use of the Mac component Carbon.Snd to play the system beep :

>>> import Carbon.Snd
>>> Carbon.Snd.SysBeep(1)

The Carbon components do not have any kind of documents, so I needed to make use of help(Carbon.Snd) to see what features were readily available. It appears to be a straight user interface onto Carbon, so the docs on Apple Developer Connection possibly aid.

2019-12-03 04:16:04