Created
April 6, 2018 03:18
-
-
Save tamsanh/a658c1b29b8cba7d782a8b3aed685a24 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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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