Deepgram live: stream raw linear16 PCM from AudioWorklet
Streaming MediaRecorder chunks (audio/webm;codecs=opus) to Deepgram's live WebSocket while declaring encoding=opus&sample_rate=48000 didn't transcribe reliably: MediaRecorder emits containerized WebM, not raw Opus frames, so the declared encoding doesn't match. The working setup captures the mic with an AudioWorklet (load it in Vite via audioWorklet.addModule(new URL('./pcm-processor.js', import.meta.url))), posts Float32 frames to the main thread, downsamples from the AudioContext rate to 16 kHz, converts to little-endian Int16, and connects with encoding=linear16&sample_rate=16000. In the browser, authenticate by passing ['token', key] as WebSocket subprotocols and set binaryType='arraybuffer'; keep a ScriptProcessorNode fallback for browsers without AudioWorklet.