Is there a way to make Colab give an Audio Notification when cell has finished running

Adding an audio notification when a cell completes is a two-liner. For example,

# Play an audio beep. Any audio URL will do.
from google.colab import output
output.eval_js('new Audio("https://upload.wikimedia.org/wikipedia/commons/0/05/Beep-09.ogg").play()')

Here's an example notebook: https://colab.research.google.com/drive/1jrEy5V7FjzAq8Ydg22E1L72xZYsEQWlM

Edit: Colab now includes a setting that will deliver a browser notification when execution completes in the background. You can enable it in the settings like so:

enter image description here

The announcement is here: https://twitter.com/GoogleColab/status/1291775273692614659


Google Colab is built on top of Jupyter Notebook, so this code will work:

import IPython.display as display
display.Audio(url="https://yoursound.com/sound.mp3", autoplay=True)

A bug that I've found is that if my web browser (Chrome) window is minimized into the dock on my Mac OS computer, the sound does not play. However, it will play in other circumstances, such as when the window is open but not in the foreground.

You can find useful audio of English words like "done" or "complete" for alerts. Use an online dictionary that has audible pronunciations (e.g. Google or Dictionary.com), search for the word you want, use your web browser's "Inspect" tool to look at the HTML source, and then search in the HTML for "mp3".

Here are some that I like:

https://static.sfdict.com/audio/C07/C0702600.mp3

https://ssl.gstatic.com/dictionary/static/pronunciation/2019-10-21/audio/do/done_en_us_1.mp3

https://ssl.gstatic.com/dictionary/static/sounds/20180430/complete--_us_1.mp3

You can also download the audio file to your Google Colab file system with !wget URL and then play the sound from Colab by using the local filename.