aboutsummaryrefslogtreecommitdiff
path: root/app/backends
diff options
context:
space:
mode:
authorhistoria <historiavg@proton.me>2026-08-24 20:41:51 -0400
committerhistoria <historiavg@proton.me>2026-08-24 20:41:51 -0400
commit610d6828fa8300efa3f8df3d3bf8e3c00e24c1dc (patch)
treedd50ad49c0f925361585b7adc7b588ddd203b55e /app/backends
parentcf24fa74188cee498eeb7b94422371c952278d4a (diff)
downloadtts-audiobook-generator-610d6828fa8300efa3f8df3d3bf8e3c00e24c1dc.tar.gz
remove: partial feature to point at existing backend checkout
Diffstat (limited to 'app/backends')
-rwxr-xr-xapp/backends/audiocpp.py101
-rwxr-xr-xapp/backends/faster.py35
-rw-r--r--app/backends/qwen.py19
3 files changed, 26 insertions, 129 deletions
diff --git a/app/backends/audiocpp.py b/app/backends/audiocpp.py
index feeb22a..d4c79b0 100755
--- a/app/backends/audiocpp.py
+++ b/app/backends/audiocpp.py
@@ -94,7 +94,7 @@ AUDIOCPP_DIR_NAME = "audio.cpp"
AUDIOCPP_GIT_URL = "https://github.com/0xShug0/audio.cpp"
# Sentinel returned by tui.confirm (via its cancel_value) when the user
-# presses Esc on an overwrite prompt to go back to the checkout browser
+# presses Esc on an overwrite prompt to go back to the wav-directory browser
# instead of aborting the wizard.
_GO_BACK = object()
@@ -161,38 +161,6 @@ def _resolve_audiocpp_root(directory: Path) -> Optional[Path]:
return None
-def _audiocpp_root_status(directory: Path) -> Tuple[str, str]:
- """TUI status describing the directory listed in the checkout browser."""
- if _resolve_audiocpp_root(directory) is not None:
- return ("model_specs/ found here", "ok")
- return ("No model_specs/ directory here", "warn")
-
-
-def _audiocpp_root_preview(directory: Path) -> Optional[Tuple[str, str]]:
- """TUI status for a highlighted subdirectory in the checkout browser."""
- if (directory / "model_specs").is_dir():
- return ("contains model_specs/", "ok")
- return None
-
-
-def _checkout_auto_select(entry: Path) -> Optional[Path]:
- """Auto-accept a highlighted checkout in the TUI browser.
-
- A subdirectory named ``audio.cpp`` that already contains a
- ``model_specs`` directory is the audio.cpp checkout root, so it is
- accepted immediately on Enter/Right (as if ``[ Use this directory ]``
- had been pressed) instead of being descended into. Anything else
- returns None so the user keeps browsing. This is only consulted
- while auto-accepting is still enabled; after the user presses Esc to
- go back, the browser is restarted inside the previously accepted
- checkout and this callback is no longer passed, so a wrong guess can
- be corrected.
- """
- if entry.name == "audio.cpp" and (entry / "model_specs").is_dir():
- return entry
- return None
-
-
# Backend display order, with short descriptions. The backend name is padded
# so the descriptions' dashes line up in the menu.
_BACKEND_DESCRIPTIONS = (
@@ -1058,54 +1026,6 @@ def _wizard(stdscr, args: argparse.Namespace, parser: argparse.ArgumentParser
"unused_entries": s["unused_entries"],
}
- def screen_no_checkout():
- """First screen when no checkout exists: clone or browse.
-
- No ``back_value``: Esc aborts the whole wizard (nothing before it).
- """
- choice = tui.menu(
- stdscr, "No audio.cpp checkout found",
- [(f"Clone into ./app/{AUDIOCPP_DIR_NAME} "
- f"(from {AUDIOCPP_GIT_URL})", "clone"),
- ("Browse for an existing checkout", "browse")],
- help_lines=[
- "audio.cpp hosts the TTS model families "
- "this generator uses.",
- "Clone it into the project's app "
- "directory, or point at an existing "
- "checkout."])
- if choice == "clone":
- target = APP_DIR / AUDIOCPP_DIR_NAME
- with tui.suspend(stdscr):
- rc = common.git_clone(AUDIOCPP_GIT_URL, target)
- if rc != 0:
- raise _TuiError(
- f"git clone failed (exit {rc}). Clone "
- f"audio.cpp manually: git clone "
- f"{AUDIOCPP_GIT_URL} {target}")
- resolve_checkout(target)
- else:
- return screen_browse_checkout
- return _after_families()
-
- def screen_browse_checkout():
- """Browse for an existing checkout (Esc returns to the clone menu)."""
- audiocpp_dir = tui.browse_directory(
- stdscr, "Select your audio.cpp directory",
- validate=lambda p: None if _resolve_audiocpp_root(p)
- else "No model_specs/ directory here",
- info=_audiocpp_root_status,
- preview=_audiocpp_root_preview,
- help_lines=["The root folder of your audio.cpp checkout;",
- "it is the one that contains model_specs/"],
- start=Path.cwd(),
- auto_select=_checkout_auto_select,
- back_value=_GO_BACK)
- if audiocpp_dir is _GO_BACK:
- return tui.Wizard.BACK
- resolve_checkout(audiocpp_dir)
- return _after_families()
-
def screen_families():
"""Pick TTS model families and packages (the modify tree)."""
tree_families = _build_tree_families(s["catalog"])
@@ -1385,15 +1305,24 @@ def _wizard(stdscr, args: argparse.Namespace, parser: argparse.ArgumentParser
return _finalize()
# First screen: resolve the checkout directly when it already exists
- # (the modify flow), so the wizard starts on a real screen.
+ # (the modify flow), so the wizard starts on a real screen. When no
+ # checkout exists, clone it into ./app/audio.cpp without asking, then
+ # continue the same way.
audiocpp_dir = args.audiocpp_dir
if audiocpp_dir is None:
audiocpp_dir = find_local_checkout()
if audiocpp_dir is None:
- first = screen_no_checkout
- else:
- resolve_checkout(audiocpp_dir)
- first = _after_families()
+ target = APP_DIR / AUDIOCPP_DIR_NAME
+ with tui.suspend(stdscr):
+ rc = common.git_clone(AUDIOCPP_GIT_URL, target)
+ if rc != 0:
+ raise _TuiError(
+ f"git clone failed (exit {rc}). Clone "
+ f"audio.cpp manually: git clone "
+ f"{AUDIOCPP_GIT_URL} {target}")
+ audiocpp_dir = target
+ resolve_checkout(audiocpp_dir)
+ first = _after_families()
return tui.Wizard().run(first)
diff --git a/app/backends/faster.py b/app/backends/faster.py
index e209ff2..36121ff 100755
--- a/app/backends/faster.py
+++ b/app/backends/faster.py
@@ -225,30 +225,11 @@ def _wizard(stdscr, args: argparse.Namespace) -> Optional[dict]:
wav_start = next(iter(ref_dirs))
s["wav_start"] = wav_start
- def screen_install():
- choice = tui.confirm(stdscr, "faster-qwen3-tts is not installed. "
- "pip install it now?", default=True,
- cancel_value=_GO_BACK)
- if choice is _GO_BACK:
- return tui.Wizard.BACK
- s["do_install"] = choice
- return _after_install()
-
- def _after_install():
- if not _is_cloned() and not args.skip_clone:
- return screen_clone
- s["do_clone"] = False
- return _after_clone()
-
- def screen_clone():
- choice = tui.confirm(
- stdscr, f"faster-qwen3-tts repo not cloned. Clone it into "
- f"./app/{FASTER_DIR_NAME}?", default=True,
- cancel_value=_GO_BACK)
- if choice is _GO_BACK:
- return tui.Wizard.BACK
- s["do_clone"] = choice
- return _after_clone()
+ # Install and clone happen without asking: when the package or repo is
+ # missing (and not skipped by flag), the wizard just does it and moves
+ # to the next screen.
+ s["do_install"] = (not _is_installed()) and not args.skip_install
+ s["do_clone"] = (not _is_cloned()) and not args.skip_clone
def _after_clone():
if args.input_dir is None:
@@ -361,11 +342,7 @@ def _wizard(stdscr, args: argparse.Namespace) -> Optional[dict]:
"plan": s["plan"],
}
- if not _is_installed() and not args.skip_install:
- first = screen_install
- else:
- first = _after_install()
- return tui.Wizard().run(first)
+ return tui.Wizard().run(_after_clone())
def _try_language(value: str) -> bool:
diff --git a/app/backends/qwen.py b/app/backends/qwen.py
index 3416ebe..f1e7c79 100644
--- a/app/backends/qwen.py
+++ b/app/backends/qwen.py
@@ -71,15 +71,6 @@ def _wizard(stdscr, args: argparse.Namespace) -> Optional[dict]:
_GO_BACK = object()
s: dict = {}
- def screen_install():
- choice = tui.confirm(stdscr, "qwen-tts is not installed. "
- "pip install it now?", default=True,
- cancel_value=_GO_BACK)
- if choice is _GO_BACK:
- return tui.Wizard.BACK
- s["do_install"] = choice
- return _after_install()
-
def _after_install():
if args.port_custom is None:
return screen_custom_port
@@ -145,11 +136,11 @@ def _wizard(stdscr, args: argparse.Namespace) -> Optional[dict]:
"speaker": s["speaker"],
}
- if not _is_installed() and not args.skip_install:
- first = screen_install
- else:
- first = _after_install()
- return tui.Wizard().run(first)
+ # pip install happens without asking: when the package is missing (and
+ # not skipped by flag), the wizard just does it and moves to the next
+ # screen.
+ s["do_install"] = (not _is_installed()) and not args.skip_install
+ return tui.Wizard().run(_after_install())
def _execute(settings: dict) -> int: