diff options
| author | historia <historiavg@proton.me> | 2026-08-24 01:57:13 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-08-24 01:58:17 -0400 |
| commit | c02d66b2d3221c0c5f5e8f2cb2ae218f1e325a0a (patch) | |
| tree | e9ec4f35c18102d4624d3cd59358d192be7bbfcb /backends/qwen.py | |
| parent | 194c63e4d11e6de9792a736a7b99788f1db78741 (diff) | |
| download | tts-audiobook-generator-c02d66b2d3221c0c5f5e8f2cb2ae218f1e325a0a.tar.gz | |
feat: manage venv for all backends
Diffstat (limited to 'backends/qwen.py')
| -rw-r--r-- | backends/qwen.py | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/backends/qwen.py b/backends/qwen.py index 60f3bb6..52f7a3f 100644 --- a/backends/qwen.py +++ b/backends/qwen.py @@ -14,18 +14,22 @@ Usage: """ import argparse -import importlib.util -import shutil import sys from pathlib import Path from typing import List, Optional sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) -from ui import tui -from backends import BackendStatus, ConfigureAction -from backends import common +from backends import ( + BackendStatus, + ConfigureAction, + ServerSpec, + common, + envs, + format_launch_hint, +) from converter import config +from ui import tui QWEN_PIP_PKG = "qwen-tts" QWEN_CUSTOMVOICE_MODEL = "Qwen/Qwen3-TTS-12Hz-1.7B-CustomVoice" @@ -39,9 +43,9 @@ QWEN_SPEAKERS = ("Vivian", "Serena", "Uncle_Fu", "Dylan", "Eric", "Ryan", def _is_installed() -> bool: - if shutil.which("qwen-tts-demo"): + if envs.env_script("qwen-tts-demo").is_file(): return True - return importlib.util.find_spec("qwen_tts") is not None + return envs.module_available("qwen_tts") def _config_port(url: str, fallback: int) -> int: @@ -144,11 +148,13 @@ def _execute(settings: dict) -> int: def _print_launch_hint(custom_port: int, clone_port: int) -> None: + demo = envs.env_script("qwen-tts-demo") print() - print("Start the servers (in separate terminals):") - print(f" qwen-tts-demo {QWEN_CUSTOMVOICE_MODEL} --ip 127.0.0.1 " + print("Start the servers (in separate terminals), or use the hub's") + print("'Server' menu / let a conversion start one automatically:") + print(f" {demo} {QWEN_CUSTOMVOICE_MODEL} --ip 127.0.0.1 " f"--port {custom_port}") - print(f" qwen-tts-demo {QWEN_BASE_MODEL} --ip 127.0.0.1 " + print(f" {demo} {QWEN_BASE_MODEL} --ip 127.0.0.1 " f"--port {clone_port}") print("Then run: python audiobook.py --backend qwen") @@ -219,13 +225,20 @@ def detect() -> BackendStatus: details.append(f"CustomVoice port: {custom_port}") details.append(f"Base (clone) port: {clone_port}") details.append(f"speaker: {config.SPEAKER}") - launch = (f"qwen-tts-demo {QWEN_CUSTOMVOICE_MODEL} --ip 127.0.0.1 " - f"--port {custom_port} ; qwen-tts-demo {QWEN_BASE_MODEL} " - f"--ip 127.0.0.1 --port {clone_port}") + demo = str(envs.env_script("qwen-tts-demo")) + servers = [ + ServerSpec("qwen-custom", config.QWEN_API_URL, + [demo, QWEN_CUSTOMVOICE_MODEL, "--ip", "127.0.0.1", + "--port", str(custom_port)]), + ServerSpec("qwen-clone", config.CLONE_API_URL, + [demo, QWEN_BASE_MODEL, "--ip", "127.0.0.1", + "--port", str(clone_port)]), + ] return BackendStatus("qwen", "qwen-tts", installed=installed, configured=installed, running=running, details=details, - launch_hint=launch) + launch_hint=format_launch_hint(servers), + servers=servers) configure_actions: List[ConfigureAction] = [ |
