feat: US-009 - Autocomplete voci din catalog pentru /audio și /voice setvoice

- tools/tts.py: +list_voice_names(engine=None), sursă live din tts_voices.json
- src/fast_commands.py: _VOICES statice -> _supertonic_voice_names() din catalog
- discord_bot.py /audio și discord_voice.py /voice setvoice: choices statice -> autocomplete live
- gates rulate: tests PASS (1043 passed, 22 eșecuri preexistente neschimbate), ui/backend review PASS manual
This commit is contained in:
2026-07-11 10:44:04 +00:00
parent 3d5c2a4ace
commit 504e12ac4e
4 changed files with 80 additions and 27 deletions

View File

@@ -24,7 +24,8 @@ if str(REPO_ROOT) not in sys.path:
sys.path.insert(0, str(REPO_ROOT))
SUPERTONIC_URL = "http://127.0.0.1:7788"
VOICES = {"M1", "M2", "M3", "M4", "M5", "F1", "F2", "F3", "F4", "F5"}
# Safety net dacă tts_voices.json lipsește/e gol — normal, catalogul e sursa de adevăr.
_FALLBACK_SUPERTONIC_VOICES = {"M1", "M2", "M3", "M4", "M5", "F1", "F2", "F3", "F4", "F5"}
DEFAULT_VOICE = "M2"
DEFAULT_LANG = "ro"
DEFAULT_ENGINE = "supertonic"
@@ -84,6 +85,18 @@ def _catalog_entry(voice: str) -> dict | None:
return catalog.get(voice) or catalog.get(voice.upper())
def list_voice_names(engine: str | None = None) -> list[str]:
"""Nume de voci din tts_voices.json, opțional filtrate pe `engine`.
Sursă live pentru autocomplete Discord (/audio, /voice setvoice) — o voce
nouă adăugată în catalog apare imediat, fără redeploy.
"""
catalog = _load_voice_catalog()
if engine is not None:
return sorted(name for name, entry in catalog.items() if entry.get("engine") == engine)
return sorted(catalog.keys())
def _config_get(key: str, default: str) -> str:
from src.config import Config
@@ -110,7 +123,8 @@ def _synthesize_supertonic(text: str, voice: str = DEFAULT_VOICE, lang: str = DE
text = sanitize_for_supertonic(text)
voice = voice.upper()
if voice not in VOICES:
supertonic_voices = set(list_voice_names(engine="supertonic")) or _FALLBACK_SUPERTONIC_VOICES
if voice not in supertonic_voices:
voice = DEFAULT_VOICE
try: