diff options
Diffstat (limited to 'backends/__init__.py')
| -rw-r--r-- | backends/__init__.py | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/backends/__init__.py b/backends/__init__.py index 9203143..629551e 100644 --- a/backends/__init__.py +++ b/backends/__init__.py @@ -5,11 +5,12 @@ 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 -up, and ``backends.REGISTRY`` drives the hub's setup/modify menus. +up (and whether their server is currently running), and +``backends.REGISTRY`` drives the hub's setup/configure menus. Adding a backend: create ``backends/<name>.py`` exposing ``detect() -> BackendStatus``, ``run_tui() -> int`` and -``modify_actions: list[ModifyAction]``, then append a ``BackendInfo`` in +``configure_actions: list[ConfigureAction]``, then append a ``BackendInfo`` in ``_build_registry`` below. ``audiobook.py`` and the hub pick it up automatically. """ @@ -25,13 +26,17 @@ class BackendStatus: INSTALLED means the backend itself is present (a cloned + built checkout, or a pip package). CONFIGURED means the supporting files are in place (a server.json / voices.json and a converter/config.py that - points at the right port). DETAILS are short status lines for the hub. - LAUNCH_HINT is the exact command the user runs to start the server. + points at the right port). RUNNING means an external server is + currently accepting connections on the configured port (probed by + ``backends.common.server_running``). DETAILS are short status lines for + the hub. LAUNCH_HINT is the exact command the user runs to start the + server. """ key: str label: str installed: bool configured: bool + running: bool = False details: List[str] = field(default_factory=list) launch_hint: str = "" @@ -42,20 +47,20 @@ class BackendStatus: @dataclass -class ModifyAction: - """A per-backend "modify" menu entry (e.g. "New server.json").""" +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, modify menu.""" + """One registry entry: identity, detector, setup wizard, configure menu.""" key: str label: str detect: Callable[[], BackendStatus] setup_tui: Callable[[], int] - modify_actions: List[ModifyAction] = field(default_factory=list) + configure_actions: List[ConfigureAction] = field(default_factory=list) REGISTRY: List[BackendInfo] = [] @@ -73,21 +78,21 @@ def _build_registry() -> None: label="audio.cpp", detect=audiocpp.detect, setup_tui=audiocpp.run_tui, - modify_actions=audiocpp.modify_actions, + configure_actions=audiocpp.configure_actions, )) REGISTRY.append(BackendInfo( key="qwen", - label="Qwen3-TTS (demo server)", + label="qwen-tts", detect=qwen.detect, setup_tui=qwen.run_tui, - modify_actions=qwen.modify_actions, + configure_actions=qwen.configure_actions, )) REGISTRY.append(BackendInfo( key="faster", label="faster-qwen3-tts", detect=faster.detect, setup_tui=faster.run_tui, - modify_actions=faster.modify_actions, + configure_actions=faster.configure_actions, )) for info in REGISTRY: _BY_KEY[info.key] = info |
