Feature · Record

Capture the microphone

record(seconds) shows a button; click it, allow the mic, and the samples come back to Python as a float32 NumPy array.

Runs the real browseraudio on an in-browser Python kernel (thebe + Pyodide). Cells are editable; the first Run downloads ~25 MB. Reload to reset.

ready
01

Record three seconds

Click Record and allow the mic; Stop early keeps the take. Hum one steady note: cell 03 turns it into an instrument.

python
from browseraudio import record

rec = record(3.0)   # shows a Record button — click it
02

Inspect the array

Float32, shape (n_frames, 1). Read it in a later cell than the recorder (why).

python
rec.samples.shape, rec.sample_rate
03

Your voice as an instrument

Each key plays your take faster or slower (it counts as middle C). Play a chord of yourself, or switch to Genie.

python
import numpy as np
from browseraudio import keyboard

sr = 16000                                         # plenty for a voice, light to ship
take = rec.samples[:, 0]
take = np.interp(np.arange(0, len(take), rec.sample_rate / sr),   # resample to `sr`
                 np.arange(len(take)), take)
take = take / (np.abs(take).max() + 1e-9)          # normalize

def voice(freq):
    # Read the take faster for higher notes, slower for lower (it was "middle C").
    pos = np.arange(0, len(take) - 1, freq / 261.63)[: sr]   # at most 1 s per note
    i = pos.astype(int)
    y = take[i] + (pos - i) * (take[i + 1] - take[i])
    return 0.5 * y * np.minimum(1, np.arange(len(y)) / (0.01 * sr))  # 10 ms fade-in

kb = keyboard(voice, sr, release=0.15)

Got audio? Head to the Play page → to push a buffer back to the speakers.