python
import numpy as np
from browseraudio import play
sr = 44100
t = np.linspace(0, 1, sr, endpoint=False)
tone = 0.2 * np.sin(2*np.pi*440*t).astype(np.float32)
play(tone, sr)
Feature · Play
play(samples, sample_rate) hands a float32 array to a main-thread
AudioContext. No microphone needed — synthesize a buffer and hear it.
Runs the real browseraudio on an in-browser Python kernel
(thebe + Pyodide). Cells are editable; the first
Run downloads ~25 MB. Reload to reset.
A one-second 440 Hz sine, generated and played through your speakers.
import numpy as np
from browseraudio import play
sr = 44100
t = np.linspace(0, 1, sr, endpoint=False)
tone = 0.2 * np.sin(2*np.pi*440*t).astype(np.float32)
play(tone, sr)
Browsers block audio that starts on its own, so if it doesn't play automatically, click the Play button the widget shows.
play() accepts (n_frames, n_channels). Here the two ears differ by 2 Hz, so you hear a slow binaural beat.
left = np.sin(2*np.pi*440*t)
right = np.sin(2*np.pi*442*t) # 2 Hz apart
stereo = (0.2*np.stack([left, right], 1)).astype(np.float32)
play(stereo, sr)
Want to play your own voice? Record it first →, then pass rec.samples to play().