Documentation
¶
Overview ¶
Package voice provides voice processing capabilities for omniagent.
Index ¶
- Constants
- type Config
- type Gateway
- func (g *Gateway) GetSession(callID string) (gateway.Session, bool)
- func (g *Gateway) ListSessions() []gateway.Session
- func (g *Gateway) MakeCall(ctx context.Context, to string) (gateway.Session, error)
- func (g *Gateway) OnCall(handler gateway.CallHandler)
- func (g *Gateway) OnSessionEnd(handler func(session gateway.Session))
- func (g *Gateway) OnSessionStart(handler func(session gateway.Session))
- func (g *Gateway) ProcessWithAgent(ctx context.Context, session gateway.Session, userText string) (string, error)
- func (g *Gateway) Start(ctx context.Context) error
- func (g *Gateway) Stop() error
- type GatewayConfig
- type Processor
- type STTConfig
- type TTSConfig
- type ToolDefinition
- type ToolHandler
- type VoiceAgentLLMProvider
Constants ¶
const DefaultVoiceSystemPrompt = `` /* 636-byte string literal not displayed */
DefaultVoiceSystemPrompt is the default system prompt for voice conversations.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Enabled indicates whether voice processing is enabled.
Enabled bool
// ResponseMode controls when to respond with voice: "auto", "always", "never".
// "auto" responds with voice when the user sends a voice message.
ResponseMode string
// STT configures speech-to-text.
STT STTConfig
// TTS configures text-to-speech.
TTS TTSConfig
}
Config configures voice processing.
type Gateway ¶ added in v0.10.0
type Gateway struct {
// contains filtered or unexported fields
}
Gateway wraps a voice gateway provider with omniagent integration.
func NewGateway ¶ added in v0.10.0
func NewGateway(cfg GatewayConfig) (*Gateway, error)
NewGateway creates a new voice gateway integrated with omniagent.
func (*Gateway) GetSession ¶ added in v0.10.0
GetSession retrieves an active session.
func (*Gateway) ListSessions ¶ added in v0.10.0
ListSessions returns all active sessions.
func (*Gateway) OnCall ¶ added in v0.10.0
func (g *Gateway) OnCall(handler gateway.CallHandler)
OnCall sets the handler for incoming calls.
func (*Gateway) OnSessionEnd ¶ added in v0.10.0
OnSessionEnd sets the callback for when a session ends.
func (*Gateway) OnSessionStart ¶ added in v0.10.0
OnSessionStart sets the callback for when a session starts.
func (*Gateway) ProcessWithAgent ¶ added in v0.10.0
func (g *Gateway) ProcessWithAgent(ctx context.Context, session gateway.Session, userText string) (string, error)
ProcessWithAgent processes a conversation turn using the omniagent LLM.
type GatewayConfig ¶ added in v0.10.0
type GatewayConfig struct {
// Provider selects the telephony provider ("twilio" or "telnyx").
Provider string
// Twilio configuration
TwilioAccountSID string
TwilioAuthToken string
TwilioPhone string
// Telnyx configuration
TelnyxAPIKey string
TelnyxPhone string
TelnyxConnectionID string
// Server configuration
PublicURL string
ListenAddr string
Listener net.Listener // Optional external listener (e.g., ngrok)
// Pipeline mode: "text" (STT→LLM→TTS, ~500-1000ms) or "realtime" (voice-to-voice, ~100-200ms)
// Default: "text"
Mode string
// Voice processing (used when Mode is "text")
Config Config
// LLM configuration (used when Mode is "text")
LLMProvider string
LLMModel string
LLMSystemPrompt string
// Realtime configuration (used when Mode is "realtime")
// RealtimeProvider: "openai" or "gemini"
RealtimeProvider string
RealtimeAPIKey string
RealtimeModel string // e.g., "gpt-4o-realtime-preview-2024-12-17", "gemini-2.0-flash-live"
RealtimeVoice string // e.g., "alloy", "Puck"
// Tools available to the voice LLM
Tools []ToolDefinition
ToolHandlers map[string]ToolHandler
// Greeting is the initial message spoken when a call connects.
Greeting string
// Session limits
MaxSessionDuration time.Duration
InterruptionMode string
// Logger
Logger *slog.Logger
}
GatewayConfig configures the voice gateway integration.
type Processor ¶
type Processor struct {
// contains filtered or unexported fields
}
Processor handles voice transcription and synthesis using OmniVoice interfaces.
func (*Processor) ResponseMode ¶
ResponseMode returns the voice response mode.
func (*Processor) SynthesizeSpeech ¶
SynthesizeSpeech converts text to audio using the configured TTS provider. Returns audio bytes and MIME type.
type STTConfig ¶
type STTConfig struct {
// Provider is the STT provider name (e.g., "deepgram").
Provider string
// APIKey is the provider API key.
APIKey string //nolint:gosec // G117: APIKey loaded from config file
// Model is the provider-specific model identifier.
Model string
// Language is the BCP-47 language code. Empty for auto-detection.
Language string
}
STTConfig configures the speech-to-text provider.
type TTSConfig ¶
type TTSConfig struct {
// Provider is the TTS provider name (e.g., "deepgram").
Provider string
// APIKey is the provider API key.
APIKey string //nolint:gosec // G117: APIKey loaded from config file
// Model is the provider-specific model identifier.
Model string
// VoiceID is the provider-specific voice identifier.
VoiceID string
}
TTSConfig configures the text-to-speech provider.
type ToolDefinition ¶ added in v0.10.0
type ToolDefinition struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters map[string]any `json:"parameters"`
}
ToolDefinition defines a tool available to the voice LLM.
type ToolHandler ¶ added in v0.10.0
ToolHandler processes a tool call.
type VoiceAgentLLMProvider ¶ added in v0.10.0
type VoiceAgentLLMProvider struct {
// contains filtered or unexported fields
}
VoiceAgentLLMProvider implements the gateway.LLMProvider interface using omniagent.
func NewVoiceAgentLLMProvider ¶ added in v0.10.0
func NewVoiceAgentLLMProvider(gw *Gateway) *VoiceAgentLLMProvider
NewVoiceAgentLLMProvider creates a new LLM provider that uses omniagent.