Skip to main content

Constraints

Quick setup (Vite)

Do not put your API key in a .env file the bundler reads (VITE_* variables are inlined into the page). Instead, add a backend route that returns a ticket from POST /ws-ticket; Secure browser setup has a complete one.

Audio pipeline

The SDK’s BrowserAudioManager handles everything:
  1. Capture mic at hardware rate
  2. Resample to 16 kHz Int16 PCM
  3. Send over WebSocket
  4. Receive 44.1 kHz Int16 PCM
  5. Convert to Float32 and schedule via Web Audio API

Start on button click

On phones, ask for the microphone inside the tap itself with requestMicrophone() and pass it to BrowserAudioManager; see Starting a call on a phone.

VU meter

Pitfalls

  1. Calling startManaged() on page load: browsers block microphone access without a user gesture
  2. Putting an API key in the page, including through bundler environment variables
  3. Not handling interrupted status: if you play audio yourself, clear your queue on interruption