Spaces:
Sleeping
Sleeping
File size: 1,949 Bytes
2a31998 4e38ce6 2a31998 11d5151 2a31998 | 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | from fastapi import FastAPI, UploadFile
from fastapi.middleware.cors import CORSMiddleware
from backend.pipeline.transcriber import transcribeAudio
from api.database import Meeting, SessionLocal
import shutil
import os
import json
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=[
"http://localhost:5173",
"https://debrief-ai-meeting-analyst.vercel.app",
os.getenv("FRONTEND_URL", "")
],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/health")
def health():
return {"status": "ok"}
@app.get("/meetings")
def getAllMeetings():
db = SessionLocal()
meetings = db.query(Meeting).all()
db.close()
return {"All Meetings": [m.to_dict() for m in meetings]}
@app.get("/meetings/{meetingId}")
def getMeeting(meetingId: int):
db = SessionLocal()
meeting = db.query(Meeting).filter(Meeting.id == meetingId).first()
db.close()
if meeting is None:
return {"error": "Meeting not found"}
return {"meeting": meeting.to_dict()}
@app.post("/meetings/{meetingId}/send")
def sendMeeting(meetingId: int):
return {"message": f"Posts {meetingId} meeting"}
@app.post("/meetings/upload")
async def uploadMeeting(file: UploadFile):
with open("/tmp/temp_audio", "wb") as buffer:
shutil.copyfileobj(file.file, buffer)
try:
transcript = transcribeAudio("/tmp/temp_audio")
db = SessionLocal()
meeting = Meeting(
summary=transcript['summary'],
action_items=json.dumps(transcript['action_items']),
decisions=json.dumps(transcript['decisions']),
follow_up_questions=json.dumps(transcript['follow_up_questions'])
)
db.add(meeting)
db.commit()
db.refresh(meeting)
result = meeting.to_dict()
db.close()
return {"Uploaded File": result}
finally:
os.remove("/tmp/temp_audio") |