Files
talk/internal/provider/catalog.go
T
m3ta-chironandClaude Fable 5.1 85fa64cfe6 refactor: switch the whole project to English
talk is going to be published. Code comments, CLI output, error messages,
daemon log lines, MCP descriptions and results, test names and assertions,
README, spec, skill, build scripts and flake are now English. Only the
spoken announcement texts stay bilingual: the wrap result and the test
sentence are German or English depending on the detected language.

Language fallback is now configurable: `lang = "en" | "de"` (env
TALK_LANG, default en) is used when detection cannot tell (numbers, single
words, ties) and for talk's own announcements. langdetect.Detect takes the
fallback as an argument instead of hard-coding German. `talk setup` asks for
it; `talk doctor` and `talk status` show it.

Vocabulary pinned across packages so the process-boundary tests observe
stable strings: chain log lines ("chain: tier X skipped (not available)",
"falling back to the next tier", "spoken via X"), queue lines ("discarded:
quiet hours ... active", "replaced by toast", "max_age"), CLI notes
("speaking directly", "daemon started at", "no daemon", "nothing to cancel"),
status block with aligned English labels, MCP messages, origin guard 403.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-24 11:15:35 +02:00

91 lines
3.3 KiB
Go

package provider
import "sort"
// Voice is an entry of the voice catalog: a known voice of a provider for a
// language, with a readable name. The catalog is curated (the common
// standard voices), not complete; any voice ID of the provider also works
// without a catalog entry (--voice, config).
type Voice struct {
Provider string
Lang string // de | en
ID string
Name string
}
// catalog lists the known voices per provider. ElevenLabs: public premade
// voices (multilingual, hence listed for both de AND en). OpenAI: the voices
// of the TTS API (language independent). Edge: neural voices of the
// respective locale. osbuiltin has no IDs (the OS chooses).
var catalog = []Voice{
{"elevenlabs", "de", "21m00Tcm4TlvDq8ikWAM", "Rachel"},
{"elevenlabs", "de", "pNInz6obpgDQGcFmaJgB", "Adam"},
{"elevenlabs", "de", "EXAVITQu4vr4xnSDxMaL", "Bella"},
{"elevenlabs", "de", "ErXwobaYiN019PkySvjV", "Antoni"},
{"elevenlabs", "de", "TxGEqnHWrfWFTfGW9XjX", "Josh"},
{"elevenlabs", "en", "21m00Tcm4TlvDq8ikWAM", "Rachel"},
{"elevenlabs", "en", "pNInz6obpgDQGcFmaJgB", "Adam"},
{"elevenlabs", "en", "EXAVITQu4vr4xnSDxMaL", "Bella"},
{"elevenlabs", "en", "ErXwobaYiN019PkySvjV", "Antoni"},
{"elevenlabs", "en", "TxGEqnHWrfWFTfGW9XjX", "Josh"},
{"openai", "de", "alloy", "Alloy"},
{"openai", "de", "echo", "Echo"},
{"openai", "de", "fable", "Fable"},
{"openai", "de", "onyx", "Onyx"},
{"openai", "de", "nova", "Nova"},
{"openai", "de", "shimmer", "Shimmer"},
{"openai", "en", "alloy", "Alloy"},
{"openai", "en", "echo", "Echo"},
{"openai", "en", "fable", "Fable"},
{"openai", "en", "onyx", "Onyx"},
{"openai", "en", "nova", "Nova"},
{"openai", "en", "shimmer", "Shimmer"},
{"edge", "de", "de-DE-KatjaNeural", "Katja"},
{"edge", "de", "de-DE-ConradNeural", "Conrad"},
{"edge", "de", "de-DE-AmalaNeural", "Amala"},
{"edge", "de", "de-DE-KillianNeural", "Killian"},
{"edge", "de", "de-AT-IngridNeural", "Ingrid (AT)"},
{"edge", "de", "de-CH-LeniNeural", "Leni (CH)"},
{"edge", "en", "en-US-AriaNeural", "Aria"},
{"edge", "en", "en-US-GuyNeural", "Guy"},
{"edge", "en", "en-US-JennyNeural", "Jenny"},
{"edge", "en", "en-US-ChristopherNeural", "Christopher"},
{"edge", "en", "en-GB-SoniaNeural", "Sonia (GB)"},
{"edge", "en", "en-GB-RyanNeural", "Ryan (GB)"},
}
// Catalog returns the voice catalog in stable order (chain order of the
// providers, then de before en, then catalog order).
func Catalog() []Voice {
out := make([]Voice, len(catalog))
copy(out, catalog)
rank := map[string]int{}
for i, name := range DefaultOrder {
rank[name] = i
}
sort.SliceStable(out, func(i, j int) bool {
if rank[out[i].Provider] != rank[out[j].Provider] {
return rank[out[i].Provider] < rank[out[j].Provider]
}
return out[i].Lang < out[j].Lang
})
return out
}
// VoiceName returns the catalog name of a voice ID; empty if unknown.
func VoiceName(provider, id string) string {
for _, v := range catalog {
if v.Provider == provider && v.ID == id {
return v.Name
}
}
return ""
}
// DefaultVoice returns the effective default voice of a provider for a
// language: config mapping voice.<provider>.<lang> before the repo default
// (without a --voice pin). Empty for osbuiltin (the OS chooses).
func DefaultVoice(provider, lang string, cfgVoices map[string]map[string]string) string {
return resolveVoice(provider, lang, "", cfgVoices[provider])
}