Third ASR backend option alongside faster-whisper and qwen3. Builds microsoft/VibeVoice from source (pinned to a specific commit, since it's custom modeling code not in transformers' Auto* registry) into its own venv, inheriting the base image's torch/CUDA. Comes with built-in speaker diarization (VibeVoiceASRProcessor.post_process_transcription returns per-segment speaker ids directly, no separate pyannote pass needed). Verified end-to-end against a real recording: 200 OK, correct Korean transcription, speaker labels populated. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
from typing import Optional
|
|
|
|
from core.config import env_str
|
|
|
|
ASR_BASE_DIR = Path(env_str("ASR_BASE_DIR", "/srv/asr"))
|
|
MODEL_CACHE = Path(env_str("WHISPER_CACHE_DIR", str(ASR_BASE_DIR / "models-cache")))
|
|
UPLOAD_DIR = ASR_BASE_DIR / "uploads"
|
|
RESULT_DIR = ASR_BASE_DIR / "results"
|
|
CUSTOM_MODEL_DIR = ASR_BASE_DIR / "custom-models"
|
|
|
|
DEVICE = env_str("ASR_DEVICE", "cuda")
|
|
COMPUTE_TYPE = env_str("ASR_COMPUTE_TYPE", "float16")
|
|
DEFAULT_BACKEND = env_str("DEFAULT_BACKEND", "faster-whisper")
|
|
DEFAULT_MODEL = env_str("DEFAULT_MODEL", "large-v3")
|
|
DEFAULT_LANGUAGE = env_str("DEFAULT_LANGUAGE", "ko")
|
|
|
|
FASTER_WHISPER_URL = env_str("FASTER_WHISPER_URL", "http://127.0.0.1:8001")
|
|
QWEN3_URL = env_str("QWEN3_URL", "http://127.0.0.1:8004")
|
|
VIBEVOICE_URL = env_str("VIBEVOICE_URL", "http://127.0.0.1:8006")
|
|
|
|
PYANNOTE_HF_TOKEN = env_str("PYANNOTE_HF_TOKEN", "")
|
|
|
|
|
|
def ensure_runtime_dirs() -> None:
|
|
for p in [ASR_BASE_DIR, MODEL_CACHE, UPLOAD_DIR, RESULT_DIR, CUSTOM_MODEL_DIR]:
|
|
p.mkdir(parents=True, exist_ok=True)
|
|
|
|
|
|
def resolve_custom_model_path(custom_model_path: Optional[str]) -> Optional[str]:
|
|
if not custom_model_path:
|
|
return None
|
|
raw = custom_model_path.strip()
|
|
if not raw:
|
|
return None
|
|
candidate = Path(raw)
|
|
if candidate.is_absolute():
|
|
return str(candidate)
|
|
return str((CUSTOM_MODEL_DIR / candidate).resolve())
|