Own the audio lifecycle.

Capture deliberately, process predictably, and clean up when the interaction ends.

Make permission a deliberate step.

Do not open the microphone as a side effect of page loading. Explain what will happen, then request permission after a click. A rejected permission request should leave the interface in a state that can be retried.

Handle the interrupted paths.

A person can leave while a model loads or while a permission dialog is open. The lab on the home page counts its starts, discards asynchronous work from an earlier one and stops microphone streams that arrive late. Stop works while the engine is still starting.

Give every resource an owner.

  • The component owns its media stream and stops every track.
  • The AudioContext owns the source and worklet graph.
  • The worker owns the model and inference session.
  • Effect cleanup removes listeners and cancels timers.

Be honest about the visual signal.

The lab’s waveform is the microphone’s real signal. The terrain behind the hero is decorative until you listen; then it follows the measured level. Reduced-motion preferences stop decorative animation.

Respect navigation and visibility.

The lab stops listening when you leave the page and releases every track, audio context and worker, so it never keeps listening in the background.