Documentation
¶
Overview ¶
Example: fully in-process Voice Agent — no SpeechKit server in the path.
This is the in-process counterpart to examples/voice-agent/game-instructor (which drives a running speechkit-server over WebSocket). Here the realtime provider runs inside this binary: we construct a live.LiveProvider directly (Gemini Live), wrap it in a live.Session, and drive a text dialogue. The provider connects straight to the model's realtime API — STT, the LLM turn, and TTS all happen provider-side, so a host needs no separate STT/TTS wiring.
This is the reference an independent coding agent can adapt with one prompt: "Embed a SpeechKit Voice Agent in my Go app." Swap the stdin loop for a mic source and feed session.SendAudio(pcm) to go fully voice; the OnAudio callback already receives the model's 24 kHz PCM for playback.
Run:
GOOGLE_AI_API_KEY=... go run ./examples/voice-agent/in-process
Then type a line and press Enter. Empty input or EOF (Ctrl-D / Ctrl-Z) ends the session. Audio frames from the model are counted, not played, so the example stays portable (no audio device needed).