5a0bfba6a3
Replaces the manual rsync+build+run with a proper spark-control feature.
First in the audio path that doesn't require shell access on Spark 2.
What's in the box
─────────────────
* image/whisperx_container/ - the build context (Dockerfile, requirements,
app/main.py FastAPI wrapper). Mainline pipeline: faster-whisper for STT +
pyannote 3.1 for diarization + wav2vec2 forced alignment. Single endpoint
/v1/audio/transcribe-with-speakers returns the exact same shape spark-
control's existing endpoint does, so the recap-relay PR spec needs no
changes when we cut over.
* image/app/whisperx_install.py - install manager. ships build context to
Spark 2 over SSH, runs `docker build`, runs `docker run` with 40 GB
memory cap (vs Sortformer's unbounded which thrashed Spark 2 on a 90-min
file), polls /health until both Whisper + pyannote report loaded.
* Audio proxy: /api/audio/transcribe-with-speakers now prefers WhisperX
when its /health reports diarizer_loaded=true, falls back to the legacy
Parakeet + Sortformer path otherwise. Same response shape either way.
Clean cutover, easy rollback (`docker rm whisperx-asr`).
* Dashboard (Audio / Speech tab):
- "Add WhisperX" banner appears when not installed, with a primary
"Install WhisperX" button. One click triggers the install.
- Build progress dialog with phase + elapsed timer + live build log via
SSE (`/api/whisperx/install/{job_id}/stream`).
- After install, WhisperX auto-registers as a managed service alongside
Parakeet and Magpie (Start/Restart/Stop, deep-check, auto-restart).
- Banner self-hides once /api/whisperx/status reports healthy.
New endpoints
─────────────
GET /api/whisperx/status
POST /api/whisperx/install
GET /api/whisperx/install/{job_id}
GET /api/whisperx/install/{job_id}/stream (SSE phase + log)
Config additions (env)
──────────────────────
WHISPERX_HOST (defaults to spark2_host)
WHISPERX_USER (defaults to spark2_user)
WHISPERX_CONTAINER (default: whisperx-asr)
WHISPERX_PORT (default: 8002)
WHISPERX_MODEL (default: medium; tiny/base/small/medium/large-v3)
Dockerfile
──────────
Added COPY whisperx_container /app/whisperx_container so the runtime
install manager can read the build context from inside the spark-control
image and ship it over SSH.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
88 lines
2.9 KiB
Python
88 lines
2.9 KiB
Python
from __future__ import annotations
|
|
import os
|
|
from dataclasses import dataclass
|
|
from pathlib import Path
|
|
|
|
|
|
def _env(name: str, default: str = "") -> str:
|
|
return os.environ.get(name, default)
|
|
|
|
|
|
def _resolve_models_yaml() -> str:
|
|
if env := os.environ.get("MODELS_YAML"):
|
|
return env
|
|
here = Path(__file__).resolve().parent # app/
|
|
candidates = [
|
|
here.parent / "models.yaml", # image/models.yaml (Docker)
|
|
here.parent.parent / "models.yaml", # <repo>/models.yaml (dev)
|
|
Path("/app/models.yaml"), # explicit container path
|
|
]
|
|
for p in candidates:
|
|
if p.exists():
|
|
return str(p)
|
|
return str(candidates[0]) # let load fail with a clear path
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class Settings:
|
|
spark1_host: str
|
|
spark1_user: str
|
|
spark2_host: str
|
|
spark2_user: str
|
|
parakeet_host: str
|
|
parakeet_user: str
|
|
parakeet_container: str
|
|
magpie_host: str
|
|
magpie_user: str
|
|
magpie_container: str
|
|
whisperx_host: str
|
|
whisperx_user: str
|
|
whisperx_container: str
|
|
whisperx_port: int
|
|
whisperx_model: str
|
|
ssh_key_path: str
|
|
ssh_known_hosts: str
|
|
models_yaml: str
|
|
vllm_port: int
|
|
parakeet_port: int
|
|
magpie_port: int
|
|
bind_port: int
|
|
open_webui_url: str
|
|
ngc_api_key: str
|
|
|
|
@classmethod
|
|
def from_env(cls) -> "Settings":
|
|
spark2_host = _env("SPARK2_HOST")
|
|
spark2_user = _env("SPARK2_USER")
|
|
# Parakeet, Magpie, and WhisperX all default to Spark 2 unless overridden.
|
|
return cls(
|
|
spark1_host=_env("SPARK1_HOST"),
|
|
spark1_user=_env("SPARK1_USER"),
|
|
spark2_host=spark2_host,
|
|
spark2_user=spark2_user,
|
|
parakeet_host=_env("PARAKEET_HOST") or spark2_host,
|
|
parakeet_user=_env("PARAKEET_USER") or spark2_user,
|
|
parakeet_container=_env("PARAKEET_CONTAINER") or "parakeet-asr",
|
|
magpie_host=_env("MAGPIE_HOST") or spark2_host,
|
|
magpie_user=_env("MAGPIE_USER") or spark2_user,
|
|
magpie_container=_env("MAGPIE_CONTAINER") or "magpie-tts",
|
|
whisperx_host=_env("WHISPERX_HOST") or spark2_host,
|
|
whisperx_user=_env("WHISPERX_USER") or spark2_user,
|
|
whisperx_container=_env("WHISPERX_CONTAINER") or "whisperx-asr",
|
|
whisperx_port=int(_env("WHISPERX_PORT", "8002")),
|
|
whisperx_model=_env("WHISPERX_MODEL", "medium"),
|
|
ssh_key_path=_env("SSH_KEY_PATH"),
|
|
ssh_known_hosts=_env("SSH_KNOWN_HOSTS"),
|
|
models_yaml=_resolve_models_yaml(),
|
|
vllm_port=int(_env("VLLM_PORT", "8888")),
|
|
parakeet_port=int(_env("PARAKEET_PORT", "8000")),
|
|
magpie_port=int(_env("MAGPIE_PORT", "9000")),
|
|
bind_port=int(_env("BIND_PORT", "9999")),
|
|
open_webui_url=_env("OPEN_WEBUI_URL", ""),
|
|
ngc_api_key=_env("NGC_API_KEY", ""),
|
|
)
|
|
|
|
@property
|
|
def configured(self) -> bool:
|
|
return bool(self.spark1_host)
|