The pipeline
Most voice bots chain three stages:
- Speech-to-text (STT) turns audio into text, ideally streaming partial results.
- Dialogue logic: rules, a state machine or an LLM decides the reply. See AI chatbots and agents.
- Text-to-speech (TTS) turns the reply into audio, ideally streaming the first audio chunk before the whole sentence is generated.
Some providers offer speech-to-speech models that merge the stages. They cut latency but give you less control over what is said, which matters for compliance.
Latency
People expect a reply roughly as fast as another person would answer, often within about a second. Measure each stage separately: end-of-speech detection, STT finalization, first token from the model, first audio byte from TTS and network time. Common techniques:
- Stream everything and start TTS on the first complete sentence.
- Keep prompts short and use smaller models for simple turns.
- Play a short acknowledgment if a tool call will take long.
- Host services close to each other and to the telephony provider.
Turn-taking
- Voice activity detection (VAD) decides when the person has finished. Too eager and you interrupt; too slow and the bot feels laggy.
- Barge-in lets the caller interrupt: stop playback immediately when speech is detected and discard the rest of the reply.
- Confirm critical values back ("I heard 4 5 1 2, is that right?") because STT errors on numbers and names are common.
Channels
- Phone: telephony providers connect calls to your service via SIP or a media WebSocket that streams audio frames (often 8 kHz mu-law). Handle DTMF key presses as a fallback.
- Web and apps: WebRTC gives low-latency audio with echo cancellation built in.
- Chat apps: Telegram, WhatsApp and Discord deliver voice messages as audio files (commonly Ogg/Opus). Download, transcribe and reply in text or audio. Discord voice channels need a gateway voice connection, which libraries such as discord.js voice support.
Consent and disclosure
- Tell callers they are talking to an automated system, and offer a human.
- Recording and transcribing calls is regulated differently by jurisdiction; some require consent from every party. Announce recording and get legal advice for your markets. See legal, terms and privacy.
- Do not clone a real person's voice without explicit permission.
- Keep audio only as long as needed; transcripts are personal data too.
Testing
Build a set of recorded utterances with accents, background noise and numbers, and track word error rate and end-to-end latency over time. See testing bots.
Related comparisons and tools
Check your understanding
Frequently asked questions
What matters most for a voice bot?
Latency. Stream speech recognition and synthesis, keep replies short, and let the caller interrupt.
Do I need consent to record calls?
Often yes, and the rules vary by country and state. Announce recording at the start of the call and check the law where your callers are.