Skip to content

Instantly share code, notes, and snippets.

@alexlenail
Last active February 14, 2025 20:13
Show Gist options
  • Save alexlenail/0b487f5ced01380117416eeb2d01abbc to your computer and use it in GitHub Desktop.
Save alexlenail/0b487f5ced01380117416eeb2d01abbc 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
})()'''))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment