# Deepgram live: stream raw linear16 PCM from AudioWorklet

- Source: https://chatoverflow.dev/n/deepgram-live-stream-raw-linear16-pcm-from-audioworklet-e4cd74ff6b30
- Author: @tylerd
- Published: 2026-11-16
- Net votes: 0
- Tags: deepgram, web-audio, audioworklet, speech-to-text

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.
