Documentation
¶
Overview ¶
Package voiceagent provides an embeddable Voice Agent service.
Voice Agent is the realtime audio-to-audio mode: a duplex WebSocket session with the underlying live model (for example OpenAI Realtime, or a pipeline fallback) where the user and the agent take audio turns in sequence. Use this when the host needs brainstorming, support, or follow-up dialogue rather than a one-shot result.
For tool registration, lifecycle hooks, and session memory, build on top of this with github.com/kombifyio/SpeechKit/pkg/speechkit/agentkit.
Construct an instance with NewService, passing a provider and the strict- mode policy fields from the host config.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrMissingProvider = errors.New("speechkit voiceagent: provider is required")
ErrMissingProvider is returned by NewService when Options.Provider is nil, and by every Service method called on a nil receiver or on a Service without a provider.
Functions ¶
This section is empty.
Types ¶
type Callbacks ¶
type Callbacks struct {
// OnAudio receives a chunk of agent audio to play back; SpeechKit
// providers deliver 24 kHz 16-bit little-endian mono PCM.
OnAudio func([]byte)
// OnText receives agent text (an answer or output transcript) to display.
OnText func(string)
// OnError receives session errors, including the failure that ends a
// session.
OnError func(error)
}
Callbacks are the host handlers a Provider invokes during a session. Every field is optional; nil handlers are skipped. Providers may call them from a background goroutine, so handlers must return quickly and guard their own state.
type Config ¶
type Config struct {
// ProviderProfileID is the public realtime profile to run, for example
// "realtime.openai.gpt-realtime-2".
ProviderProfileID string
// Model is the provider-specific realtime model id.
Model string
// Locale is the BCP-47 dialogue locale, for example "de-DE".
Locale string
// Instruction is the system prompt the agent follows.
Instruction string
}
Config carries the per-session settings a Service hands to its Provider on Start. Empty fields keep the provider's own configuration.
type Options ¶
Options are the inputs to NewService. Provider is required; Config and Callbacks are forwarded unchanged on every Start.
type Provider ¶
type Provider interface {
// StartVoiceAgent opens a session configured by the given Config and
// reports events through the Callbacks until the session ends.
StartVoiceAgent(context.Context, Config, Callbacks) error
// StopVoiceAgent ends the session and returns its record.
StopVoiceAgent(context.Context) (speechkit.VoiceAgentSession, error)
// SendText injects a user text turn into the running session.
SendText(context.Context, string) error
// CurrentSession returns a snapshot of the running or most recent
// session.
CurrentSession(context.Context) (speechkit.VoiceAgentSession, error)
}
Provider is the backend a Service delegates to. SpeechKit's in-process implementation lives in the voiceagent/local subpackage; hosts may supply their own.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service implements speechkit.VoiceAgentService by delegating to a Provider with a fixed Config and Callbacks. It keeps no session state of its own, and a nil *Service is safe to call: every method then reports ErrMissingProvider.
func NewService ¶
NewService builds a Service from opts. It returns ErrMissingProvider when opts.Provider is nil.
func (*Service) CurrentSession ¶
CurrentSession returns the provider's snapshot of the running or most recent session.
func (*Service) Start ¶
Start opens a Voice Agent session through the provider with the configured Config and Callbacks.
func (*Service) Stop ¶
Stop ends the current session and returns its speechkit.VoiceAgentSession record.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package a2a adapts a registered A2A agent to SpeechKit's cascaded voice pipeline.
|
Package a2a adapts a registered A2A agent to SpeechKit's cascaded voice pipeline. |
|
Package cascaded implements a turn-based STT -> LLM -> TTS voice agent provider.
|
Package cascaded implements a turn-based STT -> LLM -> TTS voice agent provider. |
|
Package live exposes the low-level Voice Agent realtime-protocol types.
|
Package live exposes the low-level Voice Agent realtime-protocol types. |
|
allproviders
Package allproviders is the batteries-included realtime Voice Agent assembly layer: it knows every provider SpeechKit ships and resolves a provider id, alias or profile id to a live provider.
|
Package allproviders is the batteries-included realtime Voice Agent assembly layer: it knows every provider SpeechKit ships and resolves a provider id, alias or profile id to a live provider. |
|
assemblyai
Package assemblyai adapts the AssemblyAI Voice Agent WebSocket API (wss://agents.assemblyai.com/v1/ws) to live.LiveProvider.
|
Package assemblyai adapts the AssemblyAI Voice Agent WebSocket API (wss://agents.assemblyai.com/v1/ws) to live.LiveProvider. |
|
deepgram
Package deepgram adapts the Deepgram Voice Agent API (wss://agent.deepgram.com/v1/agent/converse) to live.LiveProvider: one WebSocket carries listen (Flux or Nova STT), think (a Deepgram-managed or bring-your-own LLM) and speak (Aura-2 or Flux TTS).
|
Package deepgram adapts the Deepgram Voice Agent API (wss://agent.deepgram.com/v1/agent/converse) to live.LiveProvider: one WebSocket carries listen (Flux or Nova STT), think (a Deepgram-managed or bring-your-own LLM) and speak (Aura-2 or Flux TTS). |
|
foundry
Package foundry adapts the OpenAI Realtime provider to Microsoft Foundry.
|
Package foundry adapts the OpenAI Realtime provider to Microsoft Foundry. |
|
gemini
Package gemini adapts the Google Gemini Live API (via the google.golang.org/genai SDK) to live.LiveProvider.
|
Package gemini adapts the Google Gemini Live API (via the google.golang.org/genai SDK) to live.LiveProvider. |
|
livecontract
Package livecontract provides reusable conformance checks for LiveProvider implementations.
|
Package livecontract provides reusable conformance checks for LiveProvider implementations. |
|
openai
Package openai adapts the OpenAI Realtime WebSocket API (wss://api.openai.com/v1/realtime, GA session shape) to live.LiveProvider.
|
Package openai adapts the OpenAI Realtime WebSocket API (wss://api.openai.com/v1/realtime, GA session shape) to live.LiveProvider. |
|
voicelive
Package voicelive adapts the OpenAI Realtime provider to Microsoft Foundry's Voice Live API.
|
Package voicelive adapts the OpenAI Realtime provider to Microsoft Foundry's Voice Live API. |
|
Package local implements voiceagent.Provider on top of an in-process live session — realtime voice agents (Deepgram Voice Agent, Gemini Live, OpenAI Realtime, AssemblyAI, cascaded) without a speechkit-server.
|
Package local implements voiceagent.Provider on top of an in-process live session — realtime voice agents (Deepgram Voice Agent, Gemini Live, OpenAI Realtime, AssemblyAI, cascaded) without a speechkit-server. |