Voice input for construction site reports, grounded in the project's own master data
A Japanese speech pipeline (VAD, Deepgram, Gemini, TTS) that fills daily site reports and matches every spoken value to master data with pgvector retrieval.
- Context
- Voice input for a construction daily-report SaaS in Japan (client under NDA)
- Role
- Backend / AI Engineer
- Key point
- Measured RAG on/off before shipping it
- Python
- FastAPI
- WebSocket
- gRPC
- Deepgram nova-3
- Gemini 2.5 Flash
- pgvector
- multilingual-e5-small
- Silero VAD
- React
- Redis
The problem
Site supervisors fill a daily report at the end of the day: for each subcontractor the work type, task, workers, machines, materials and quantities. They wanted to say it out loud instead of typing it.
Every value has to land on a row in the project's master data. Japanese makes that hard: kanji homophones, site slang (ユンボ for a backhoe, 生コン for ready-mix concrete), half-width katakana in imported masters, and speech-to-text that guesses the kanji.
The AI may never invent a value or create a master row. A wrong auto-match in a legal site record is worse than no match.
Architecture: before → after
- Supervisor types the report
- Picks each value from long master lists
- Slang and readings don't match
- Speech → VAD → Deepgram (master keyterms)
- Gemini sorts the transcript per company
- Plain match on name / reading / alias
- Miss → pgvector top-k + catalog hints → Gemini picks an id
- Exact / confirm / new → review screen
What I did
- Built the speech pipeline over one WebSocket: client VAD ends an utterance after 2 s of quiet, PCM16 audio goes to Deepgram nova-3 with the project's master names as keyterms, and a server-side Silero VAD check drops pauses with no speech before they reach STT.
- Used Gemini only as a classifier: it sorts the transcript per company and picks master ids from a list. It never writes text, and a post-filter keeps a value only if its words are actually in the transcript.
- Matching runs plain match first (name, reading, alias). Only a miss goes to retrieval: multilingual-e5-small embeddings in pgvector return the field's nearest project rows, plus hints from a 1,562-term standard catalog, and Gemini chooses among them.
- Every value ends as an exact match, a suggestion the user must confirm, or new. Voice never writes a master row, and any retrieval failure falls back silently to the full list behind a circuit breaker.
- Short spoken cues come from a self-hosted Supertonic TTS on a gRPC inference service, cached for fixed lines; the text is always shown, so read-aloud is optional.
- Built golden-sample evals for both extraction and master matching, offline in CI and live against the real models, and ran RAG off vs on before deciding its settings.
Outcome
- Extraction eval: 23 of 26 golden recordings fully right, 119 of 123 fields exact or near, about 1.9 s and $0.0005 per extraction call.
- Retrieval eval on 43 samples: no accuracy gain from top-k alone (33/35 top-1 with and without), and it cut correct rows the embeddings ranked low. The real gain came from the catalog hints. RAG shipped as 'whole pool + catalog hints', with zero wrong auto-matches in every run.
- Spoken-cue time to first audio of 0.77–1.4 s in smoke tests.
Still in development: real-device testing and cost per session over real use are open, so there are no production numbers yet. Figures above come from the project's own eval scripts.
More case studies
- Scaling a high-traffic microservices backend on AWS
- Making cache synchronisation resilient with SQS, retries and a DLQ
- A realtime social platform that scales horizontally
- Removing a webhook race condition with database-level idempotency
- Protecting SMS OTP endpoints from automated abuse
- Leading delivery decisions under deadline pressure