Live speech-to-text is the one feature where I use WebSockets instead of Server-Sent Events, because audio flows up while text flows down. The OCR & Speech Workspace does live microphone transcription with a post-recording refinement pass, and the architecture below is what made it feel instant rather than laggy.

The data flow

The browser captures microphone audio, resamples to the rate the model expects, and sends small chunks — a few hundred milliseconds each — over a WebSocket.

The server buffers chunks into windows, runs the streaming model, and sends back partial transcripts as they stabilise.

When the user stops, the server runs a second, slower pass over the whole recording and replaces the live text with a refined final transcript.