aboutsummaryrefslogtreecommitdiff
path: root/app/backends/qwen.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/backends/qwen.py')
-rw-r--r--app/backends/qwen.py53
1 files changed, 12 insertions, 41 deletions
diff --git a/app/backends/qwen.py b/app/backends/qwen.py
index 501d929..c0aafef 100644
--- a/app/backends/qwen.py
+++ b/app/backends/qwen.py
@@ -28,6 +28,7 @@ from backends import (
format_launch_hint,
probe,
servers,
+ setup,
)
from converter import config
from converter.clients import QWEN3_TTS_SPEAKERS
@@ -40,8 +41,8 @@ DEFAULT_CUSTOM_PORT = 7860
DEFAULT_CLONE_PORT = 7861
# Built-in CustomVoice speakers (see app/converter/config.py SPEAKER). The
-# canonical list lives in converter.tts (shared with the audiocpp backend's
-# Convert-form Speaker picker).
+# canonical list lives in converter.clients.speakers (shared with the
+# audio.cpp backend's Convert-form Speaker picker).
QWEN_SPEAKERS = QWEN3_TTS_SPEAKERS
@@ -203,40 +204,21 @@ def _execute(settings: dict) -> int:
def setup_screen(stdscr) -> int:
"""Run the setup wizard on an existing curses screen (the hub's).
- The hub drives this as one screen of its own ``tui.Wizard`` stack, so
- Esc on the wizard's first screen simply returns here and the hub pops
- back to the menu that launched it. The setup tail (pip install / config
- sync) runs inside the TUI task view on this same screen, so the hub's
- curses session stays intact and the user sees per-step status instead of
- being dropped to the console. Returns 0 on completion, 1 when the user
- aborted.
+ See backends.setup.screen_flow for the shared flow. Returns 0 on
+ completion, 1 when the user aborted.
"""
- args = build_parser().parse_args([])
- settings = _wizard(stdscr, args)
- if settings is None:
- return 1
- return taskview.run_steps(stdscr, "Setting up qwen-tts",
- _execute_steps(settings))
+ return setup.screen_flow(stdscr, wizard=_wizard,
+ steps_of=_execute_steps,
+ title="Setting up qwen-tts",
+ parser_factory=build_parser)
def run_tui(args: Optional[argparse.Namespace] = None) -> int:
"""Run the qwen setup wizard end-to-end."""
- import curses
if args is None:
args = build_parser().parse_args([])
- try:
- settings = curses.wrapper(_wizard, args)
- except tui.WizardCancelled:
- print("\n[INFO] Cancelled; nothing was written")
- return 1
- try:
- curses.curs_set(1)
- except curses.error:
- pass
- if settings is None:
- print("[INFO] Aborted")
- return 1
- return _execute(settings)
+ return setup.tui_flow(_wizard, _execute, args=args,
+ aborted_message="[INFO] Aborted")
def _collect_from_flags(args: argparse.Namespace,
@@ -375,23 +357,12 @@ def main() -> int:
parser = build_parser()
args = parser.parse_args()
- if _interactive():
+ if setup.interactive():
return run_tui(args)
settings = _collect_from_flags(args, parser)
return _execute(settings)
-def _interactive() -> bool:
- try:
- import curses # noqa: F401
- except ImportError:
- return False
- try:
- return sys.stdin.isatty() and sys.stdout.isatty()
- except (AttributeError, ValueError):
- return False
-
-
if __name__ == "__main__":
sys.exit(main())