voicegateway

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BackendGeminiLive bridges WebRTC voice sessions to Gemini Live.
	BackendGeminiLive = "gemini-live"
	// BackendLocalStack is the local ASR/LLM/TTS model stack.
	BackendLocalStack = "local-stack"
)

Internal backend IDs. A gateway instance serves exactly one of these. They are gateway implementation details: they appear in gateway config, logs, and tests, but never in the client contract.

View Source
const DefaultGeminiModel = "gemini-3.8-live"

DefaultGeminiModel is the Gemini Live model used when config.model is empty.

Model IDs are bare, without the models/ resource-name prefix; the Gemini adapter qualifies them for the wire.

View Source
const DefaultVoiceScope = "voice.session"

DefaultVoiceScope is the OAuth scope a gateway requires on an OAuth access token that authorizes a voice session.

Variables

This section is empty.

Functions

func DefaultConfigPath

func DefaultConfigPath() string

DefaultConfigPath returns the canonical standalone voice gateway config path.

func NewEmbeddedHandler

func NewEmbeddedHandler(bridge MediaBridgeProvider, textSessions TextSessionServer) http.Handler

NewEmbeddedHandler returns voice gateway routes for a caller that already enforces request authentication before dispatch. textSessions may be nil.

func NewHandler

func NewHandler(
	cfg *Config,
	bridge MediaBridge,
	textSessions TextSessionServer,
) (http.Handler, error)

NewHandler returns a reusable voice gateway HTTP handler. textSessions may be nil when no backend serves text voice sessions.

Types

type CloseSessionResp

type CloseSessionResp struct {
	Status string `json:"status"`
}

CloseSessionResp is returned after closing a voice gateway session.

type Config

type Config struct {
	Server         ServerConfig          `toml:"server"`
	Model          string                `toml:"model"`
	Backend        string                `toml:"backend"`
	LocalStack     LocalStackConfig      `toml:"local_stack"`
	TrustedIssuers []TrustedIssuerConfig `toml:"trusted_issuers"`
}

Config is the static voice gateway configuration.

A gateway instance serves exactly one backend. Operators run multiple instances (and point clients at different URLs) to offer multiple profiles.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the standalone voice gateway defaults.

func LoadConfig

func LoadConfig(path string) (Config, error)

LoadConfig reads config.toml, returning defaults when the file does not exist.

func (*Config) Validate

func (c *Config) Validate() error

Validate returns an error if c is not a usable static gateway config.

func (*Config) ValidateEmbedded

func (c *Config) ValidateEmbedded() error

ValidateEmbedded returns an error if c is not usable by an embedded service gateway.

type DiagnosticMediaBridge

type DiagnosticMediaBridge interface {
	DiagnoseVoiceRTC(ctx context.Context, sessionID string, client *voicev1.VoiceRTCClientDiagnostics) voicev1.VoiceRTCDiagnosticsResp
}

DiagnosticMediaBridge returns structured WebRTC connectivity diagnostics.

type HealthResp

type HealthResp struct {
	Status string `json:"status"`
}

HealthResp is returned by GET /api/voicegateway/v1/voice/health.

type LocalStackASRConfig

type LocalStackASRConfig struct {
	Engine   LocalStackASREngine `toml:"engine"`
	Provider string              `toml:"provider"`
	Remote   string              `toml:"remote"`
	Model    string              `toml:"model"`
}

LocalStackASRConfig configures the local ASR (speech-to-text) adapter.

type LocalStackASREngine added in v0.1.2

type LocalStackASREngine string

LocalStackASREngine selects how utterances are transcribed.

const (
	// LocalStackASRGenAI uses a registered genai provider (managed llama.cpp by default).
	LocalStackASRGenAI LocalStackASREngine = "genai"
	// LocalStackASROpenAIAudio uses an OpenAI-compatible transcription endpoint.
	LocalStackASROpenAIAudio LocalStackASREngine = "openai-audio"
	// LocalStackASRWhistle runs the managed Cactus Whistle recognizer.
	LocalStackASRWhistle LocalStackASREngine = "whistle"
	// LocalStackASRWhisperCPP uses whisper.cpp's inference endpoint.
	LocalStackASRWhisperCPP LocalStackASREngine = "whispercpp"
)

type LocalStackConfig

type LocalStackConfig struct {
	ASR LocalStackASRConfig `toml:"asr"`
	LLM LocalStackLLMConfig `toml:"llm"`
	TTS LocalStackTTSConfig `toml:"tts"`
}

LocalStackConfig configures local model adapters.

type LocalStackLLMConfig

type LocalStackLLMConfig struct {
	Provider string `toml:"provider"`
	Remote   string `toml:"remote"`
	Model    string `toml:"model"`
	// APIKeyName names the environment variable containing the bearer token
	// for an openaicompatible endpoint. The credential is never stored in TOML.
	APIKeyName string `toml:"api_key_name"`
}

LocalStackLLMConfig configures the local LLM adapter.

type LocalStackTTSConfig added in v0.1.2

type LocalStackTTSConfig struct {
	Engine LocalStackTTSEngine `toml:"engine"`
	Remote string              `toml:"remote"`
	Model  string              `toml:"model"`
	Voice  string              `toml:"voice"`
}

LocalStackTTSConfig selects a speech synthesis engine. The default is managed KittenTTS.

KittenTTS defaults to the KittenTTS 2 model and Jasper voice when Model and Voice are empty. OpenAI audio requires Remote, Model and Voice.

type LocalStackTTSEngine added in v0.1.2

type LocalStackTTSEngine string

LocalStackTTSEngine selects how assistant text is synthesized.

const (
	// LocalStackTTSKittenTTS runs the managed KittenTTS worker.
	LocalStackTTSKittenTTS LocalStackTTSEngine = "kittentts"
	// LocalStackTTSOpenAIAudio uses an OpenAI-compatible speech endpoint.
	LocalStackTTSOpenAIAudio LocalStackTTSEngine = "openai-audio"
)

type MediaBridge

type MediaBridge interface {
	HandleOffer(ctx context.Context, sdp string) (sdpAnswer, sessionID string, err error)
	Close(sessionID string)
}

MediaBridge is the WebRTC media transport used by the voice gateway API.

type MediaBridgeProvider

type MediaBridgeProvider func() MediaBridge

MediaBridgeProvider returns the current WebRTC media transport.

type OfferResp

type OfferResp struct {
	SDP       string `json:"sdp"`
	SessionID string `json:"sessionID"`
}

OfferResp returns the WebRTC SDP answer and gateway session ID.

type ServerConfig

type ServerConfig struct {
	HTTP          string `toml:"http"`
	WebRTCUDPPort int    `toml:"webrtc_udp_port"`
}

ServerConfig configures gateway HTTP and WebRTC listeners.

type TextSessionServer added in v0.1.2

type TextSessionServer interface {
	// ServeTextSession runs one text session on the HTTP response. It owns the
	// response and writes its own error response, so the caller only logs a
	// returned error.
	ServeTextSession(ctx context.Context, w http.ResponseWriter, r *http.Request) error
}

TextSessionServer serves bidirectional text voice sessions where the client performs speech recognition and synthesis.

type TrustedIssuerConfig

type TrustedIssuerConfig struct {
	// Service is the service kind allowed to issue tokens, for example "caic" or "mddb".
	Service string `toml:"service"`
	// Issuer is the backend origin that owns the signing key.
	//
	// It must match the service authorization base URL and the token backend origin.
	Issuer string `toml:"issuer"`
	// PublicKey is the imported Ed25519 public key used to verify scoped tokens from issuer.
	//
	// The expected format is the value returned by gomode.EncodeServiceSigningPublicKey.
	PublicKey string `toml:"public_key"`
	// OAuth enables OAuth 2.0 access token verification through discovery and JWKS.
	OAuth bool `toml:"oauth"`
	// Audience is the required OAuth token audience. It defaults to
	// gomode.ScopedTokenAudience when empty.
	Audience string `toml:"audience"`
	// Scope is the OAuth scope a token must carry. It defaults to
	// DefaultVoiceScope when empty.
	Scope string `toml:"scope"`
}

TrustedIssuerConfig configures a service backend trusted to issue tokens.

Exactly one of PublicKey or OAuth selects the token form. PublicKey verifies the transitional scoped Ed25519 token. OAuth verifies a standard OAuth 2.0 access token through issuer metadata discovery and its published JWKS.

func (*TrustedIssuerConfig) OAuthAudience

func (c *TrustedIssuerConfig) OAuthAudience() string

OAuthAudience returns the audience an OAuth token from this issuer must carry.

func (*TrustedIssuerConfig) OAuthScope

func (c *TrustedIssuerConfig) OAuthScope() string

OAuthScope returns the scope an OAuth token from this issuer must carry.

Directories

Path Synopsis
api
Package api provides shared voice gateway API infrastructure.
Package api provides shared voice gateway API infrastructure.
v1
Package voicertc implements WebRTC voice sessions through the voice gateway protocol.
Package voicertc implements WebRTC voice sessions through the voice gateway protocol.
data
Package data defines persisted voice activity records independently of the session protocol.
Package data defines persisted voice activity records independently of the session protocol.

Jump to

Keyboard shortcuts

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