"""Selection du backend TTS par nom (pluggable)."""
from __future__ import annotations

from functools import lru_cache

from .base import TTSBackend

BACKENDS = ("kokoro", "qwen3")


@lru_cache(maxsize=4)
def get_backend(name: str = "kokoro") -> TTSBackend:
    name = name.lower()
    if name == "kokoro":
        from .kokoro import KokoroBackend
        return KokoroBackend()
    if name == "qwen3":
        from .qwen3 import Qwen3Backend
        return Qwen3Backend()
    raise ValueError(f"Backend TTS inconnu: {name!r} (dispo: {', '.join(BACKENDS)})")
