CineGraph / app /main.py
PopovDanil's picture
fix4
1c9b30c
raw
history blame contribute delete
524 Bytes
from fastapi import FastAPI
from .cleaner import clean_subtitle
from .model import get_model
from .schemas import EmotionResponse, SubtitleRequest
app = FastAPI(title="Emotion Analyzer API")
@app.get("/")
async def root():
return {"status": "ok"}
@app.post("/analyze", response_model=EmotionResponse)
async def analyze(req: SubtitleRequest):
model = get_model()
text = clean_subtitle(req.text)
df = model.analyze_text(text)
return EmotionResponse(
data=df.to_dict(orient="records")
)