Ask Your Question

Is there a way to make an audible noise when a computation is complete?

asked 2010-08-21 10:40:34 +0200

ccanonc gravatar image

I tried printing the alert bell ("\a") and didn't hear anything. Tips?

edit retag flag offensive close merge delete


I suppose sending an email is another option, though as we saw with this site, SMTP can be a pain, especially for a home user.

ccanonc gravatar imageccanonc ( 2010-08-21 11:56:06 +0200 )edit

3 Answers

Sort by ยป oldest newest most voted

answered 2010-08-21 12:36:43 +0200

William Stein gravatar image
  1. Are you using a remote notebook or a local server. If it is local, just run some local command that makes a noise using os.system. How you do this depends entirely one what operating system you are using.

  2. Regarding email (see ccanonc's remark above), it is trivial to use with Sage, irregardless of SMTP. There is a command (I wrote) called "email" that is builtin to Sage, which uses that Sage includes its own mail server (which is part of Twisted). Just do sage: email? for more details.

edit flag offensive delete link more


Can sage act as a POP or IMAP client?

ccanonc gravatar imageccanonc ( 2010-08-23 00:42:52 +0200 )edit

Yes: Twisted, which Sage contains implements "high-level, efficient protocol implementations for both clients and servers of SMTP, POP3, and IMAP4. " See

William Stein gravatar imageWilliam Stein ( 2010-08-24 18:04:49 +0200 )edit

Nice, that's convenient for lazy/home users like me. :-) Maybe I'll dig into those hooks (for the email client code).

ccanonc gravatar imageccanonc ( 2010-08-24 18:47:58 +0200 )edit

Sorry, here with Sage 4.7.1 and Ubuntu 10.04: os.system('mplayer /usr/share/sounds/ubuntu/stereo/phone-incoming-call.ogg') gives

Rafael gravatar imageRafael ( 2011-09-27 14:39:58 +0200 )edit

answered 2010-08-21 19:32:09 +0200

radokirov gravatar image

You can try this on any new browser.

def done():
    return html('!audio src="" autoplay> Your browser does not support the audio element. !/audio>')

for i in range(10**6):

Replace ! with < . I could not make the code display otherwise.

In the future a function "done()" along with a sound file can be a part of the notebook. I will remove the .ogg file from my server in the future to prevent too much hotlinking (so don't freak out if this doesn't work).

edit flag offensive delete link more


I like it. =)

ccanonc gravatar imageccanonc ( 2010-08-21 19:34:02 +0200 )edit

That is a *fantastic* "I'm finished" sound. Way better than some lame old beep. :)

Dan Drake gravatar imageDan Drake ( 2010-08-22 23:32:52 +0200 )edit

Also, if you are not working with the notebook, you can use Python's subprocess module and any command-line sound player: just define the done() function as above as something like['ogg123', 'path/to/file'])

Dan Drake gravatar imageDan Drake ( 2010-08-22 23:39:18 +0200 )edit
William Stein gravatar imageWilliam Stein ( 2010-08-24 18:07:31 +0200 )edit

radokirov: I opened gong.ogg in Audacity, and it's silence after about 2.25 seconds. You can either truncate that, or slowly taper (ramp-down if I'm remembering the term correctly). Audacity is fun to play with...especially if you want a long gong. =)

ccanonc gravatar imageccanonc ( 2010-08-24 19:17:05 +0200 )edit

answered 2010-08-24 12:24:15 +0200

TeamTeamUSA gravatar image

updated 2010-08-24 19:47:42 +0200

I added gong.ogg to my notebook, so I can serve it locally. It took a while, but I finally determined the path to the image files:


The URI to the file is:


The file plays fine in Firefox; guess Safari doesn't know how to play an ogg file.

edit flag offensive delete link more


This also works fine in chrome.

William Stein gravatar imageWilliam Stein ( 2010-08-24 18:07:51 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2010-08-21 10:40:34 +0200

Seen: 1,220 times

Last updated: Aug 24 '10