in-process

command
v0.67.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

README

voice-agent/in-process

Fully in-process Voice Agent: no SpeechKit server in the path. The realtime provider runs inside the binary — a live.LiveProvider (Gemini Live) wrapped in a live.Session drives a text dialogue, with STT, the LLM turn, and TTS all happening provider-side. It is the in-process counterpart to examples/voice-agent/game-instructor, which drives a running speechkit-server over WebSocket.

Requirements

  • GOOGLE_AI_API_KEY (a Google AI Studio key with Gemini Live access) — required. No audio device is needed; agent audio frames are counted, not played.

Run

GOOGLE_AI_API_KEY=... go run ./examples/voice-agent/in-process

Expected output

After connecting, an interactive stdin loop. Each line you type is sent as a turn; the session prints state transitions ([state=...]), the transcript of what the agent heard (you (heard): ...), the agent's spoken answer (agent: ...), and on exit the total agent audio received (session ended cleanly (received N bytes of agent audio).). An empty line or EOF ends the session.

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).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL