aboutsummaryrefslogtreecommitdiff
path: root/app/backends/faster.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/backends/faster.py')
-rwxr-xr-xapp/backends/faster.py31
1 files changed, 11 insertions, 20 deletions
diff --git a/app/backends/faster.py b/app/backends/faster.py
index 2d0cad3..34fae45 100755
--- a/app/backends/faster.py
+++ b/app/backends/faster.py
@@ -59,6 +59,8 @@ from ui import taskview, tui
FASTER_DIR_NAME = "faster-qwen3-tts"
FASTER_GIT_URL = "https://github.com/andimarafioti/faster-qwen3-tts"
FASTER_PIP_PKG = "faster-qwen3-tts[demo]"
+# The managed server's port when the configured URL names none.
+DEFAULT_PORT = 8000
# The dedicated venv faster-qwen3-tts is installed into (never the app env
# or the qwen backend's; the wheel pulls its own qwen-tts-hf dependency,
# which ships the same qwen_tts module upstream qwen-tts does).
@@ -78,14 +80,6 @@ def _is_cloned() -> bool:
return (_checkout() / "examples" / "openai_server.py").is_file()
-def _config_port() -> int:
- import urllib.parse
- try:
- return urllib.parse.urlsplit(config.FASTER_API_URL).port or 8000
- except ValueError:
- return 8000
-
-
def build_voices(wav_files: list, language: str, whisper_model: str) -> dict:
"""Transcribe each wav file and build the voices mapping."""
voices = {}
@@ -363,7 +357,7 @@ def _print_launch_hint(voices_path: Path) -> None:
return
print("[INFO] Clone faster-qwen3-tts to get examples/openai_server.py,")
print(f" then run it with --voices {voices_path} "
- f"--port {_config_port()}")
+ f"--port {common.port_of(config.FASTER_API_URL, DEFAULT_PORT)}")
def setup_screen(stdscr) -> int:
@@ -471,7 +465,8 @@ def detect() -> BackendStatus:
if cloned and voices_json.exists():
argv = [str(envs.env_python(FASTER_ENV)),
str(_checkout() / "examples" / "openai_server.py"),
- "--voices", str(voices_json), "--port", str(_config_port())]
+ "--voices", str(voices_json), "--port",
+ str(common.port_of(config.FASTER_API_URL, DEFAULT_PORT))]
# identity: /health must report model_loaded before the server is
# really usable (the model loads after the port opens).
specs = [ServerSpec("faster", config.FASTER_API_URL, argv,
@@ -491,17 +486,13 @@ def detect() -> BackendStatus:
def _detect_remote(managed: bool = False):
"""Detect an externally-run faster server at the remote URL.
- Returns ``(running, {spec_name: url})``; see audiocpp._detect_remote for
- the shared semantics (empty URL disables, own server not counted twice).
+ Returns ``(running, {spec_name: url})``; see probe.detect_remote_url
+ for the shared semantics (empty URL disables, own server not counted
+ twice).
"""
- url = (config.FASTER_REMOTE_URL or "").strip()
- if not url:
- return False, {}
- if managed and probe.same_endpoint(url, config.FASTER_API_URL):
- return False, {}
- if probe.identify_server(url) == probe.IDENTITY_FASTER:
- return True, {"faster": url}
- return False, {}
+ return probe.detect_remote_url(config.FASTER_REMOTE_URL,
+ config.FASTER_API_URL,
+ probe.IDENTITY_FASTER, "faster", managed)
def update(*, emit=None, cancel=None) -> int: