Skip to main content

Overview

The Voice Agent orchestrates the complete voice interaction pipeline: VAD → STT → LLM → TTS. This enables full conversational AI with a single API.

Prerequisites

All three models (LLM + STT + TTS) must be loaded before starting a voice session:

VoiceSessionConfig

Stream Voice Session

The voice session takes a Flow<ByteArray> of audio data and returns a Flow<VoiceSessionEvent>:

VoiceSessionEvent

Providing Audio Input

The voice session expects a Flow<ByteArray> of 16kHz mono PCM 16-bit audio in ~100ms chunks. Use Kotlin’s callbackFlow with Android’s AudioRecord:

Example: Complete Voice Assistant

Component States

Check individual component readiness:

Performance Optimization

Minimize total latency: Use smaller models (whisper-tiny, 0.5B LLM), enable streaming for both LLM and TTS, and preload all models at app startup.

Typical Latencies (Pixel 7)

VAD

Voice Activity Detection

STT

Speech-to-Text

TTS

Text-to-Speech

LLM

Text Generation