feat(config): add optional Audio config for STT/Music

Add optional Audio *AudioConfig pointer field on Config with STT and
Music sub-structs. Nil-safe — absent in JSON5 decodes as nil, no
breaking change. cfg.Tts retained unchanged for backward compat.
setupAudioExtras stub wired for Phase 3/4 STT/Music provider
registration.
This commit is contained in:
viettranx committed 2026-04-15 11:24:56 +07:00
1 parent 8fc4e5dea9
commit b0b87da7cd
4 files changed
+49 -1

No files matched your search

+10
View File
@@ -274,3 +274,13 @@ func setupTTS(cfg *config.Config) *tts.Manager {
return mgr
}
// setupAudioExtras wires optional STT + Music static defaults into the audio
// Manager. Phase 1 placeholder: body is empty — Phase 3 wires Music providers,
// Phase 4 wires STT providers. Kept here so the call-site in gateway_setup.go
// is stable from Phase 1 onward.
//
//nolint:unused // Phase 1 stub; wired in Phase 3/4.
func setupAudioExtras(_ *config.Config, _ *tts.Manager) {
// Intentionally empty. Phase 3/4 will register Music/STT providers here.
}
+3 -1
View File
@@ -137,11 +137,13 @@ func setupToolRegistry(
toolsReg.Register(tools.NewCreateAudioTool(providerRegistry,
cfg.Tts.ElevenLabs.APIKey, cfg.Tts.ElevenLabs.BaseURL))
// TTS (text-to-speech) system — always create TtsTool so config reload can populate it later
// Audio system (TTS today, STT/Music/SFX in later phases) — always create
// TtsTool so config reload can populate it later.
ttsMgr := setupTTS(cfg)
if ttsMgr == nil {
ttsMgr = tts.NewManager(tts.ManagerConfig{})
}
setupAudioExtras(cfg, ttsMgr) // Phase 1 stub; Phase 3/4 wire Music/STT.
ttsTool = tools.NewTtsTool(ttsMgr)
toolsReg.Register(ttsTool)
if ttsMgr.HasProviders() {
+1
View File
@@ -50,6 +50,7 @@ type Config struct {
Sessions SessionsConfig `json:"sessions"`
Database DatabaseConfig `json:"database"`
Tts TtsConfig `json:"tts"`
Audio *AudioConfig `json:"audio,omitempty"` // optional STT/Music defaults (Phase 3/4)
Cron CronConfig `json:"cron"`
Telemetry TelemetryConfig `json:"telemetry"`
Tailscale TailscaleConfig `json:"tailscale"`
+35
View File
@@ -0,0 +1,35 @@
package config
// AudioConfig is the optional cfg.Audio block for STT/Music static defaults.
// Pointer-typed field on Config so absent/empty JSON silently decodes as nil —
// existing config.json files that predate Phase 1 continue to load unchanged.
//
// Phase 1 ships the shape only (no consumers yet). Phase 3 wires Music; Phase 4
// wires STT. In both phases the Manager continues to honor per-tenant
// builtin_tools settings regardless of whether cfg.Audio is set.
type AudioConfig struct {
Stt *AudioSTTConfig `json:"stt,omitempty"`
Music *AudioMusicConfig `json:"music,omitempty"`
}
// AudioSTTConfig configures optional static STT defaults. Empty = "no global
// default; rely on tenant builtin_tools[stt] or per-channel STTProxyURL".
type AudioSTTConfig struct {
Provider string `json:"provider,omitempty"` // primary provider name (e.g. "scribe")
APIKey string `json:"api_key,omitempty"` // may be overridden by env / secrets
BaseURL string `json:"base_url,omitempty"` // override for enterprise deploys
Model string `json:"model,omitempty"` // provider-specific
Language string `json:"language,omitempty"` // BCP-47 hint
Fallback string `json:"fallback,omitempty"` // provider name to try on primary failure
TimeoutMs int `json:"timeout_ms,omitempty"` // default 30000
}
// AudioMusicConfig configures optional static Music defaults.
type AudioMusicConfig struct {
Provider string `json:"provider,omitempty"` // primary provider name (e.g. "elevenlabs")
APIKey string `json:"api_key,omitempty"`
BaseURL string `json:"base_url,omitempty"`
Model string `json:"model,omitempty"`
Fallback string `json:"fallback,omitempty"`
TimeoutMs int `json:"timeout_ms,omitempty"`
}