Constraints
Quick setup (Vite)
.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’sBrowserAudioManager handles everything:
- Capture mic at hardware rate
- Resample to 16 kHz Int16 PCM
- Send over WebSocket
- Receive 44.1 kHz Int16 PCM
- Convert to Float32 and schedule via Web Audio API
Start on button click
requestMicrophone() and pass it to BrowserAudioManager; see Starting a call on a phone.
VU meter
Pitfalls
- Calling
startManaged()on page load: browsers block microphone access without a user gesture - Putting an API key in the page, including through bundler environment variables
- Not handling
interruptedstatus: if you play audio yourself, clear your queue on interruption