Skip to content

Instantly share code, notes, and snippets.

@rogeriopradoj
Forked from tamsanh/jupyter_cell_notify.py
Last active September 30, 2020 19:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogeriopradoj/78934fde4911558cbdfa89428c5e1280 to your computer and use it in GitHub Desktop.
Save rogeriopradoj/78934fde4911558cbdfa89428c5e1280 to your computer and use it in GitHub Desktop.
Generate and play a sound in Jupyter Notebook when then cell is run. Useful as notification when a long-running cell is done.
from IPython.lib.display import Audio
import numpy as np
framerate = 4410
play_time_seconds = 3
t = np.linspace(0, play_time_seconds, framerate*play_time_seconds)
audio_data = np.sin(2*np.pi*300*t) + np.sin(2*np.pi*240*t)
Audio(audio_data, rate=framerate, autoplay=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment