Spaces:
Running
Running
Commit ·
1c9b30c
1
Parent(s): d2141dd
fix4
Browse files- app/main.py +3 -8
app/main.py
CHANGED
|
@@ -3,7 +3,7 @@ from fastapi import FastAPI
|
|
| 3 |
|
| 4 |
from .cleaner import clean_subtitle
|
| 5 |
from .model import get_model
|
| 6 |
-
from .schemas import
|
| 7 |
|
| 8 |
app = FastAPI(title="Emotion Analyzer API")
|
| 9 |
|
|
@@ -17,14 +17,9 @@ async def root():
|
|
| 17 |
async def analyze(req: SubtitleRequest):
|
| 18 |
model = get_model()
|
| 19 |
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
return EmotionResponse(
|
| 23 |
data=df.to_dict(orient="records")
|
| 24 |
-
)
|
| 25 |
-
|
| 26 |
-
@app.post('/clean', response_model=CleanResponse)
|
| 27 |
-
async def clean(req: SubtitleRequest):
|
| 28 |
-
return CleanResponse(
|
| 29 |
-
text=clean_subtitle(req.text)
|
| 30 |
)
|
|
|
|
| 3 |
|
| 4 |
from .cleaner import clean_subtitle
|
| 5 |
from .model import get_model
|
| 6 |
+
from .schemas import EmotionResponse, SubtitleRequest
|
| 7 |
|
| 8 |
app = FastAPI(title="Emotion Analyzer API")
|
| 9 |
|
|
|
|
| 17 |
async def analyze(req: SubtitleRequest):
|
| 18 |
model = get_model()
|
| 19 |
|
| 20 |
+
text = clean_subtitle(req.text)
|
| 21 |
+
df = model.analyze_text(text)
|
| 22 |
|
| 23 |
return EmotionResponse(
|
| 24 |
data=df.to_dict(orient="records")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
)
|