diff options
Diffstat (limited to 'app/backends/__init__.py')
| -rw-r--r-- | app/backends/__init__.py | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/app/backends/__init__.py b/app/backends/__init__.py index 488c36e..3dff306 100644 --- a/app/backends/__init__.py +++ b/app/backends/__init__.py @@ -1,12 +1,12 @@ """Registry of the TTS backends the audiobook generator can talk to. Each backend (audio.cpp, qwen, faster) lives in its own module and owns -its setup wizard, its status detection, and the launch command it prints -once configured. This package aggregates them into a single registry so -``audiobook.py``'s TUI hub and future tools can iterate backends without -hardcoding their names: ``backends.detect_all()`` reports which are set +its setup wizard, its status detection, its uninstaller, and the launch +command it prints once configured. This package aggregates them into a single +registry so ``audiobook.py``'s TUI hub and future tools can iterate backends +without hardcoding their names: ``backends.detect_all()`` reports which are set up (and whether their server is currently running), and the registry -drives the hub's setup/configure menus. +drives the hub's "Configure backends" menu. The registry is built lazily on the first call to ``get``/``detect_all``/ ``detect`` (not at package import time), because the backend modules pull @@ -17,9 +17,8 @@ importing this package must stay cheap and dependency-free. Adding a backend: create ``backends/<name>.py`` exposing ``detect() -> BackendStatus``, ``run_tui() -> int`` and -``configure_actions: list[ConfigureAction]``, then append a ``BackendInfo`` in -``_build_registry`` below. ``audiobook.py`` and the hub pick it up -automatically. +``uninstall() -> int``, then append a ``BackendInfo`` in ``_build_registry`` +below. ``audiobook.py`` and the hub pick it up automatically. """ import shlex @@ -131,20 +130,13 @@ def format_launch_hint(servers: List[ServerSpec]) -> str: @dataclass -class ConfigureAction: - """A per-backend "configure" menu entry (e.g. "New server.json").""" - label: str - run: Callable[[], int] - - -@dataclass class BackendInfo: - """One registry entry: identity, detector, setup wizard, configure menu.""" + """One registry entry: identity, detector, setup wizard, uninstaller.""" key: str label: str detect: Callable[[], BackendStatus] setup_tui: Callable[[], int] - configure_actions: List[ConfigureAction] = field(default_factory=list) + uninstall: Callable[[], int] = lambda: 0 REGISTRY: List[BackendInfo] = [] @@ -162,21 +154,21 @@ def _build_registry() -> None: label="audio.cpp", detect=audiocpp.detect, setup_tui=audiocpp.run_tui, - configure_actions=audiocpp.configure_actions, + uninstall=audiocpp.uninstall, )) REGISTRY.append(BackendInfo( key="qwen", label="qwen-tts", detect=qwen.detect, setup_tui=qwen.run_tui, - configure_actions=qwen.configure_actions, + uninstall=qwen.uninstall, )) REGISTRY.append(BackendInfo( key="faster", label="faster-qwen3-tts", detect=faster.detect, setup_tui=faster.run_tui, - configure_actions=faster.configure_actions, + uninstall=faster.uninstall, )) for info in REGISTRY: _BY_KEY[info.key] = info |
