Rollback web speaker diarization; HF token helper for whisper_stt

- Remove app/diarize.py and pyannote from requirements.txt; web uses faster-whisper only
- Revert main.py job/transcribe flow and index.html meta/hints
- Add app/pyannote_auth.py for Pipeline.from_pretrained(..., token=...) used by whisper_stt
- Expand whisper_stt / README / requirements-whisper-stt for gated repos (community-1, 403)

Made-with: Cursor
This commit is contained in:
dosangyoon
2026-03-23 13:31:38 +09:00
parent 2e503d1a56
commit 13d1f75b34
8 changed files with 60 additions and 220 deletions

View File

@@ -13,6 +13,10 @@ from typing import Any
import whisper
import whisper.audio as whisper_audio
_STT_ROOT = os.path.dirname(os.path.abspath(__file__))
if _STT_ROOT not in sys.path:
sys.path.insert(0, _STT_ROOT)
DEFAULT_DIARIZE_MODEL_DIR = "./models/pyannote-diarization-3.1"
@@ -199,21 +203,37 @@ def _run_diarization(audio_path: str, *, diarize_model_dir: str | None) -> list[
)
sys.exit(1)
from pyannote.audio import Pipeline
model_dir = _resolve_local_diarize_dir(diarize_model_dir)
_validate_pyannote_snapshot(model_dir)
print(f"[4/4] 화자 분리(pyannote) — 로컬 모델: {model_dir}", flush=True)
print(
" (하위 모델이 허브에서 받아질 수 있음 — hf auth login 또는 HF_TOKEN 권장)",
flush=True,
)
print("[4/4] 화자 분리 실행 중... (수 분 걸릴 수 있음)", flush=True)
t0 = time.perf_counter()
try:
pipeline = Pipeline.from_pretrained(model_dir)
from app.pyannote_auth import load_pyannote_pipeline
pipeline = load_pyannote_pipeline(model_dir)
except Exception as e:
print(
f"오류: pyannote 파이프라인을 불러오지 못했습니다: {e}\n\n"
"config.yaml 은 있는데도 실패하면 하위 체크포인트(segmentation·embedding 등)가 빠졌을 수 있습니다.\n"
"폴더를 비운 뒤 전체 재다운로드:\n"
"speaker-diarization-3.1 은 실행 시 여러 게이트 저장소에서 파일을 추가로 받습니다.\n"
"오류 메시지에 나온 repo 이름마다, 로그인한 계정으로 아래를 **모두** 완료해야 합니다.\n"
" • https://hf.co/pyannote/speaker-diarization-3.1\n"
" • https://hf.co/pyannote/segmentation-3.0\n"
" • https://hf.co/pyannote/speaker-diarization-community-1 ← xvec_transform.npz 등\n"
" • (오류에 다른 pyannote/… 가 나오면 그 페이지도 동일)\n\n"
"각 페이지에서 양식·약관 제출 후, 화면에 «액세스 허용»·다운로드가 되는지 확인하세요.\n"
"«authorized list» / 403 이면: (1) 위 목록 중 빠진 저장소가 있는지 (2) 다른 HF 계정으로 로그인한 것은 아닌지.\n"
"토큰은 **위 접근이 된 계정**으로 발급하고, 게이트 동의 이후에 새로 만든 Read 토큰을 권장합니다.\n"
" hf auth login\n"
" hf auth whoami\n"
" # 또는 export HF_TOKEN=hf_...\n\n"
"미리 받아 두기(동의된 계정으로):\n"
" hf download pyannote/speaker-diarization-community-1 --local-dir ./models/pyannote-community-1\n"
" hf download pyannote/speaker-diarization-3.1 \\\n"
f" --local-dir {DEFAULT_DIARIZE_MODEL_DIR}\n",
file=sys.stderr,