aboutsummaryrefslogtreecommitdiff
path: root/app/backends/qwen.py
diff options
context:
space:
mode:
authorhistoria <historiavg@proton.me>2026-08-28 17:16:54 -0400
committerhistoria <historiavg@proton.me>2026-08-28 17:16:54 -0400
commite66eb0e7d4342ae1c58e9bbd341843753be548f0 (patch)
tree0ade3b71c86b59511d7653e450377a9366a30482 /app/backends/qwen.py
parent270fa60c01866c4431d540be960b6cd2bc2b9c44 (diff)
downloadtts-audiobook-generator-e66eb0e7d4342ae1c58e9bbd341843753be548f0.tar.gz
feat: cli auto-starts and stops locally-managed servers if no --api-url is passed
Diffstat (limited to 'app/backends/qwen.py')
-rw-r--r--app/backends/qwen.py26
1 files changed, 22 insertions, 4 deletions
diff --git a/app/backends/qwen.py b/app/backends/qwen.py
index a4cddb5..a94b3cc 100644
--- a/app/backends/qwen.py
+++ b/app/backends/qwen.py
@@ -44,7 +44,8 @@ from backends import (
setup,
)
from converter import config
-from converter.clients import QWEN3_TTS_SPEAKERS
+from converter.clients import (QWEN3_TTS_SPEAKERS, VOICE_MODE_CLONE,
+ VOICE_MODE_CUSTOM, VOICE_MODE_DESIGN)
from ui import taskview, tui
QWEN_PIP_PKG = "qwen-tts"
@@ -191,6 +192,18 @@ def model_for_identity(identity: Optional[str]) -> Optional[str]:
return IDENTITY_TO_MODEL.get(identity)
+def model_for_voice_mode(voice_mode: str) -> str:
+ """The MODEL_REPOS key a run with VOICE_MODE needs hosted.
+
+ The mirror of ``model_for_identity`` for a planned (not yet running)
+ run: instructions design the voice (VoiceDesign), a reference .wav
+ clones (Base), otherwise built-in speakers (CustomVoice).
+ """
+ return {VOICE_MODE_DESIGN: "VoiceDesign",
+ VOICE_MODE_CLONE: "Base",
+ VOICE_MODE_CUSTOM: "CustomVoice"}[voice_mode]
+
+
def desired_identity(model: str) -> str:
"""The probe identity the model's demo answers as (used while booting)."""
return {
@@ -283,8 +296,13 @@ def build_parser() -> argparse.ArgumentParser:
return parser
-def _build_spec(model: str) -> ServerSpec:
- """The single managed ServerSpec hosting MODEL on the configured port."""
+def build_spec(model: str) -> ServerSpec:
+ """The single managed ServerSpec hosting MODEL on the configured port.
+
+ Public because callers outside this module (the hub's run preparation
+ and the CLI's managed-server bootstrap) need to boot exactly the model
+ their run selected, which can differ from the default one.
+ """
url = config.QWEN_API_URL
return ServerSpec(
"qwen", url,
@@ -325,7 +343,7 @@ def detect() -> BackendStatus:
"not installed — run setup to pip install qwen-tts")
details.append(f"port: {_config_port(url, DEFAULT_PORT)}")
details.append(f"default model: {model}")
- specs = [_build_spec(model)]
+ specs = [build_spec(model)]
managed = servers.manages(specs)
# A locally-managed server names its running model via the probe of the
# managed URL; a remotely-run demo names it via the remote-URL probe.