Restructure into asr/tts packages and add TTS tab skeleton
Split the single ASR gateway into app/main.py (entrypoint) + app/core (shared env helpers) + app/asr (all existing ASR logic, unchanged behavior) + app/tts (placeholder router/config, no engine yet), so a real TTS backend can be dropped in later without reshuffling ASR code. API moved under /asr/* and /tts/* prefixes; UI gained a top-level ASR/TTS tab switcher built on a reusable nested .tab-group mechanism, with JS split into common.js/asr.js/tts.js. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
40
app/asr/config.py
Normal file
40
app/asr/config.py
Normal file
@@ -0,0 +1,40 @@
|
||||
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")
|
||||
|
||||
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())
|
||||
Reference in New Issue
Block a user