aboutsummaryrefslogtreecommitdiff
path: root/app/backends/audiocpp.py
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/audiocpp.py
parentcf24fa74188cee498eeb7b94422371c952278d4a (diff)
downloadtts-audiobook-generator-610d6828fa8300efa3f8df3d3bf8e3c00e24c1dc.tar.gz
remove: partial feature to point at existing backend checkout
Diffstat (limited to 'app/backends/audiocpp.py')
-rwxr-xr-xapp/backends/audiocpp.py101
1 files changed, 15 insertions, 86 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)