Skip to content

Instantly share code, notes, and snippets.

@alexlenail
Created October 23, 2024 17:34
Show Gist options
  • Save alexlenail/f3d8469b65ff28d04c9a3c1217711107 to your computer and use it in GitHub Desktop.
Save alexlenail/f3d8469b65ff28d04c9a3c1217711107 to your computer and use it in GitHub Desktop.
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