Files
viettranx 613b6e38d7 feat(tts): provider capabilities schema + Gemini TTS + dynamic param forms
Baseline groundwork for TTS expansion plan. Introduces a capabilities
system that the follow-up plan (phase-01..04) builds on.

Backend:
- `audio.ParamSchema` / `ProviderCapabilities` types + per-provider
  capabilities.go for edge, elevenlabs, minimax, openai, gemini.
- Gemini TTS provider (client, models, voices, wav encoder,
  multi-speaker via SpeakerVoice, audio-tag aware prompts).
- TTSOptions gains `Params map[string]any` (read-only) + `Speakers`.
- `VoiceListProvider` interface decouples HTTP voice handler from
  provider-specific impls.
- `nested_keys.go` resolves dot-separated param paths for nested
  provider bodies (voice_settings.stability etc.).
- Characterization + defaults-invariant tests per provider lock
  nil-params byte-equivalence before new params land.
- `/v1/tts/capabilities` HTTP endpoint + integration coverage.
- Dual-read tests (PG + SQLite) for tts_config.

Frontend (web + desktop):
- `DynamicParamForm` with depends-on evaluation, split into
  fields/logic modules. Slider primitive added.
- `AudioTagPicker` + `MultiSpeakerEditor` for Gemini.
- `voice-picker` refactored toward portal UX; combobox tightened.
- tts-capabilities API client + typed hooks.
- i18n catalogs (en/vi/zh) expanded; parity tests guard key drift.
- TTS page reorganised (voice-model-section removed; playground +
  credentials + provider-setup split cleanly).

Docs: codebase-summary, project-changelog, tts-provider-capabilities.
2026-04-20 00:05:19 +07:00

76 lines
2.4 KiB
Go

package edge
import "github.com/nextlevelbuilder/goclaw/internal/audio"
// edgeDefaultVoices lists a representative set of Edge TTS voices.
// Full list is available via `edge-tts --list-voices`; these cover common locales.
var edgeDefaultVoices = []audio.VoiceOption{
{VoiceID: "en-US-MichelleNeural", Name: "Michelle", Language: "en-US", Gender: "Female"},
{VoiceID: "en-US-GuyNeural", Name: "Guy", Language: "en-US", Gender: "Male"},
{VoiceID: "en-GB-SoniaNeural", Name: "Sonia", Language: "en-GB", Gender: "Female"},
{VoiceID: "vi-VN-HoaiMyNeural", Name: "HoaiMy", Language: "vi-VN", Gender: "Female"},
{VoiceID: "vi-VN-NamMinhNeural", Name: "NamMinh", Language: "vi-VN", Gender: "Male"},
{VoiceID: "zh-CN-XiaoxiaoNeural", Name: "Xiaoxiao", Language: "zh-CN", Gender: "Female"},
{VoiceID: "zh-CN-YunxiNeural", Name: "Yunxi", Language: "zh-CN", Gender: "Male"},
}
var (
rateMin = -50.0
rateMax = 100.0
rateStep = 1.0
pitchMin = -50.0
pitchMax = 50.0
pitchStep = 1.0
volumeMin = -50.0
volumeMax = 100.0
volumeStep = 1.0
)
// edgeParams is the enriched param schema for Edge TTS.
// Defaults MUST match the hardcoded tts.go behaviour (no --rate/--pitch/--volume flags = zero).
// UI slider int values; Synthesize converts via sliderToRateString / sliderToPitchString.
var edgeParams = []audio.ParamSchema{
{
Key: "rate",
Type: audio.ParamTypeInteger,
Label: "Rate",
Description: "Speech rate adjustment in percent (-50 to +100).",
Default: 0,
Min: &rateMin,
Max: &rateMax,
Step: &rateStep,
},
{
Key: "pitch",
Type: audio.ParamTypeInteger,
Label: "Pitch",
Description: "Pitch adjustment in Hz (-50 to +50).",
Default: 0,
Min: &pitchMin,
Max: &pitchMax,
Step: &pitchStep,
},
{
Key: "volume",
Type: audio.ParamTypeInteger,
Label: "Volume",
Description: "Volume adjustment in percent (-50 to +100).",
Default: 0,
Min: &volumeMin,
Max: &volumeMax,
Step: &volumeStep,
},
}
// Capabilities returns the full capability schema for the Edge TTS provider.
// Edge TTS requires no API key (uses the free edge-tts CLI).
func (p *Provider) Capabilities() audio.ProviderCapabilities {
return audio.ProviderCapabilities{
Provider: "edge",
DisplayName: "Edge TTS (Microsoft)",
RequiresAPIKey: false,
Voices: edgeDefaultVoices,
Params: edgeParams,
}
}