Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Sound alerts in Jupyter for code completion and exceptions

""" jupyter addin shows starttime, elapsedtime; sounds alert on cell finish
"""
import time
from IPython.core.magics.execution import _format_time
from IPython.display import display as d
from IPython.display import Audio
from IPython.core.display import HTML
import numpy as np
import logging as log

def alert():
    """ makes sound on client using javascript (works with remote server) """      
    framerate = 44100
    duration=.05
    freq=300
    t = np.linspace(0,duration,framerate*duration)
    data = np.sin(2*np.pi*freq*t)
    d(Audio(data,rate=framerate, autoplay=True))
    hide_audio()
Source by forums.fast.ai #
 
PREVIOUS NEXT
Tagged: #Sound #alerts #Jupyter #code #completion #exceptions
ADD COMMENT
Topic
Name
6+6 =