File size: 882 Bytes
0db822c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from fastapi import HTTPException, Request

from src.inference.transcribe import WhisperTranscriber
from src.inference.analyze_call import CallAnalyzer


def get_transcriber(request: Request) -> WhisperTranscriber:
    transcriber = getattr(request.app.state, "transcriber", None)
    if transcriber is None:
        raise HTTPException(
            status_code=503,
            detail="Whisper model is not loaded. Check server logs and MODEL_PATH.",
        )
    return transcriber


def get_analyzer(request: Request) -> CallAnalyzer:
    analyzer = getattr(request.app.state, "analyzer", None)
    if analyzer is None:
        raise HTTPException(
            status_code=503,
            detail=(
                "Gemini analyzer is not available. "
                "Set GEMINI_API_KEY in the environment to enable this endpoint."
            ),
        )
    return analyzer