aboutsummaryrefslogtreecommitdiff
path: root/app/backends/qwen.py
diff options
context:
space:
mode:
authorhistoria <historiavg@proton.me>2026-08-28 14:57:48 -0400
committerhistoria <historiavg@proton.me>2026-08-28 14:57:48 -0400
commitdb38085d07ce75f8961eecdc1919e98748254c53 (patch)
treebeaea2ba84de05bfc2fa90e9b92a24568d3b4cb9 /app/backends/qwen.py
parentafb2c2d5b297c5aa28bcced0e3f90e207d799c2a (diff)
downloadtts-audiobook-generator-db38085d07ce75f8961eecdc1919e98748254c53.tar.gz
refactor: overhaul config.py, remove cli default options
Diffstat (limited to 'app/backends/qwen.py')
-rw-r--r--app/backends/qwen.py44
1 files changed, 24 insertions, 20 deletions
diff --git a/app/backends/qwen.py b/app/backends/qwen.py
index d6dd2e0..a4cddb5 100644
--- a/app/backends/qwen.py
+++ b/app/backends/qwen.py
@@ -6,9 +6,10 @@ ONE Qwen3-TTS model per process — CustomVoice (built-in speakers), Base
(voice cloning) or VoiceDesign (described voice). This module sets it up
end-to-end: pip-install the package into its own managed venv
(``app/envs/qwen`` — the app venv and the faster backend's never receive
-it). There are no questions to ask — the port and which model to run live in
-``app/converter/config.py`` (the model is chosen per run on the hub's
-Generate-audiobooks screen), and only one server runs at a time.
+it). There are no questions to ask — the port lives in
+``app/converter/config.py`` (the hub's Settings screen) and the model is
+chosen per run on the hub's Generate-audiobooks screen; only one server
+runs at a time.
Model weights are not part of the install: each demo lazily fetches its
~4GB snapshot from HuggingFace into the standard hub cache the first time a
@@ -52,9 +53,9 @@ QWEN_PIP_PKG = "qwen-tts"
QWEN_ENV = envs.QWEN_ENV_DIR
DEFAULT_PORT = 7860
-# The models a single demo server can host, by config.QWEN_MODEL name.
-# A running server identifies itself via its probe identity (backends.probe),
-# so "which model is up" is always read off the server, never assumed.
+# The models a single demo server can host. A running server identifies
+# itself via its probe identity (backends.probe), so "which model is up" is
+# always read off the server, never assumed.
MODEL_REPOS = {
"CustomVoice": "Qwen/Qwen3-TTS-12Hz-1.7B-CustomVoice",
"Base": "Qwen/Qwen3-TTS-12Hz-1.7B-Base",
@@ -66,11 +67,13 @@ IDENTITY_TO_MODEL = {
probe.IDENTITY_QWEN_CLONE: "Base",
probe.IDENTITY_QWEN_DESIGN: "VoiceDesign",
}
+# The model a fresh managed start (Start/Stop Backend Servers menu) hosts;
+# Generate-audiobooks runs needing another model restart the server.
DEFAULT_MODEL = "CustomVoice"
-# Built-in CustomVoice speakers (see app/converter/config.py SPEAKER). The
-# canonical list lives in converter.clients.speakers (shared with the
-# audio.cpp backend's Convert-form Speaker picker).
+# Built-in CustomVoice speakers. The canonical list lives in
+# converter.clients.speakers (shared with the audio.cpp backend's
+# Convert-form Speaker picker); a run's speaker is picked per run.
QWEN_SPEAKERS = QWEN3_TTS_SPEAKERS
@@ -179,8 +182,8 @@ def _config_port(url: str, fallback: int) -> int:
def current_model() -> str:
- """The configured model to host (a MODEL_REPOS key; DEFAULT_MODEL on typos)."""
- return config.QWEN_MODEL if config.QWEN_MODEL in MODEL_REPOS else DEFAULT_MODEL
+ """The model a fresh managed start hosts (DEFAULT_MODEL)."""
+ return DEFAULT_MODEL
def model_for_identity(identity: Optional[str]) -> Optional[str]:
@@ -202,8 +205,9 @@ def _wizard(stdscr, args: argparse.Namespace) -> dict:
The qwen backend has no per-install choices: install happens when the
package is missing (and not skipped by flag), and every other value —
- port, speaker, which model runs — lives in app/converter/config.py /
- the hub's Settings and Generate-audiobooks screens.
+ port — lives in app/converter/config.py (the hub's Settings screen);
+ the model and voice are picked per run on the Generate-audiobooks
+ screen.
"""
return {
"do_install": (not _is_installed()) and not args.skip_install,
@@ -306,11 +310,12 @@ def _managed_running_model() -> Optional[str]:
def detect() -> BackendStatus:
"""Detect whether qwen-tts is installed, plus the launch command.
- One managed spec exists, hosting ``config.QWEN_MODEL`` on the single
- configured port. Which model currently answers there is read via the
- probe (local pid alive => check our own URL; otherwise the remote URL)
- so the status names the *running* model even when it differs from the
- configured one.
+ One managed spec exists, hosting the default model on the single
+ configured port (Generate-audiobooks runs needing another model boot
+ it via their own spec). Which model currently answers there is read
+ via the probe (local pid alive => check our own URL; otherwise the
+ remote URL) so the status names the *running* model even when it
+ differs from the default one.
"""
installed = _is_installed()
model = current_model()
@@ -319,8 +324,7 @@ def detect() -> BackendStatus:
details.append("pip: installed" if installed else
"not installed — run setup to pip install qwen-tts")
details.append(f"port: {_config_port(url, DEFAULT_PORT)}")
- details.append(f"model: {model}")
- details.append(f"speaker: {config.SPEAKER}")
+ details.append(f"default model: {model}")
specs = [_build_spec(model)]
managed = servers.manages(specs)
# A locally-managed server names its running model via the probe of the