Real-time speech-to-text: architecture of a live transcription feature

Presenting KrishGyan, farming advice in your voice and language
Presenting KrishGyan, farming advice in your voice and language

Originally published at https://pranjulrathour.scult.in/blog/speech-to-text-real-time-architecture. That copy is the canonical version and gets updates first.

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.

Taking questions during a session
Taking questions during a session

The data flow

  1. The browser captures microphone audio, resamples to the rate the model expects, and sends small chunks — a few hundred milliseconds each — over a WebSocket.
  2. The server buffers chunks into windows, runs the streaming model, and sends back partial transcripts as they stabilise.
  3. 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.

Partial versus final

Streaming models revise their guesses as more audio arrives. Show partial text in a lighter style and lock segments once they are final; users tolerate words changing for a second, not paragraphs rewriting themselves. Mark segment boundaries with silence detection so the refinement pass has clean units to work with.

Latency budget

  • Chunk size sets the floor: 300 ms chunks mean nothing appears for at least 300 ms.
  • Network round trip and model time add to it; keep the model warm and the connection persistent.
  • Aim for under a second to the first partial; beyond two seconds, users start repeating themselves.

The refinement pass is not optional

Live transcripts are optimised for speed, not accuracy. A post-recording pass with a stronger model, punctuation restoration and speaker-aware formatting turns a stream of words into a document someone will actually read. In the workspace, that final transcript is what gets indexed for document-scoped chat.

Pranjul Rathour
Pranjul Rathour

Details that matter

Ask for microphone permission at the moment of need with an explanation, show a live level meter so the user knows audio is flowing, handle reconnects without losing the buffer, and let people edit the final text. Speech features live or die on these details, not on the model.

From my carousels
5 Production AI Apps, All Open Source
5 Production AI Apps, All Open Source, slide 15 Production AI Apps, All Open Source, slide 2
5 Production AI Apps, All Open Source, slide 35 Production AI Apps, All Open Source, slide 4
Full carousel on Instagram and LinkedIn.
Pranjul Rathour
Pranjul Rathour
GenAI engineer, Kanpur · 3x first-prize hackathon winner · campus mentor
I ship production RAG pipelines, fine-tune LLMs and build agentic AI products end to end. I lead engineering at SCULT INDIA for a 14-member team and have mentored 200+ students through TechVerse Enclave.
Open to: GenAI roles, hackathon judging, mentorship sessions and guest talks at colleges.
On stage, at hackathons and on campus
Presenting Annapurna on stage
Presenting Annapurna on stage
Presenting to a room
Presenting to a room
Requirements gathering and user flows, on stage
Requirements gathering and user flows, on stage

Comments

Popular posts from this blog

Forming a hackathon team: roles, skills and the mistake most teams make

I built 15 free tools, 1,211 prompts and a 50,000-skill library — here's what's inside tools.scult.in

Building in public as a student: a 30-day plan