Created
October 23, 2024 17:34
-
-
Save alexlenail/f3d8469b65ff28d04c9a3c1217711107 to your computer and use it in GitHub Desktop.
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.display import display, Javascript | |
def beep(): | |
display(Javascript('''(function() { | |
var context = new (window.AudioContext || window.webkitAudioContext)(); | |
var oscillator = context.createOscillator(); | |
oscillator.type = 'sine'; | |
oscillator.frequency.setValueAtTime(440, context.currentTime); // Frequency in Hz (440 is a standard 'A' note) | |
oscillator.connect(context.destination); | |
oscillator.start(); | |
oscillator.stop(context.currentTime + 0.2); // Beep duration: 0.2 seconds | |
})()''')) | |
# Call the beep function when your cell is done executing | |
beep() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment