feat(transcription): add meeting assistant micro-service v0.1.0
- Added FastAPI backend with FFmpeg and Gemini 2.0 integration - Added React frontend with upload and meeting list - Integrated into main docker-compose stack and dashboard
This commit is contained in:
72
transcription-tool/backend/app.py
Normal file
72
transcription-tool/backend/app.py
Normal file
@@ -0,0 +1,72 @@
|
||||
from fastapi import FastAPI, Depends, HTTPException, UploadFile, File, BackgroundTasks
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from sqlalchemy.orm import Session
|
||||
import os
|
||||
import shutil
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
|
||||
from .config import settings
|
||||
from .database import init_db, get_db, Meeting, TranscriptChunk, AnalysisResult, SessionLocal
|
||||
from .services.orchestrator import process_meeting_task
|
||||
|
||||
app = FastAPI(
|
||||
title=settings.APP_NAME,
|
||||
version=settings.VERSION,
|
||||
root_path="/tr"
|
||||
)
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"],
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
@app.on_event("startup")
|
||||
def startup_event():
|
||||
init_db()
|
||||
|
||||
@app.get("/api/health")
|
||||
def health():
|
||||
return {"status": "ok", "version": settings.VERSION}
|
||||
|
||||
@app.get("/api/meetings")
|
||||
def list_meetings(db: Session = Depends(get_db)):
|
||||
return db.query(Meeting).order_by(Meeting.created_at.desc()).all()
|
||||
|
||||
@app.post("/api/upload")
|
||||
async def upload_audio(
|
||||
background_tasks: BackgroundTasks,
|
||||
file: UploadFile = File(...),
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
# 1. Save File
|
||||
file_id = str(uuid.uuid4())
|
||||
ext = os.path.splitext(file.filename)[1]
|
||||
filename = f"{file_id}{ext}"
|
||||
file_path = os.path.join(settings.UPLOAD_DIR, filename)
|
||||
|
||||
with open(file_path, "wb") as buffer:
|
||||
shutil.copyfileobj(file.file, buffer)
|
||||
|
||||
# 2. Create DB Entry
|
||||
meeting = Meeting(
|
||||
title=file.filename,
|
||||
filename=filename,
|
||||
file_path=file_path,
|
||||
status="UPLOADED"
|
||||
)
|
||||
db.add(meeting)
|
||||
db.commit()
|
||||
db.refresh(meeting)
|
||||
|
||||
# 3. Trigger Processing in Background
|
||||
background_tasks.add_task(process_meeting_task, meeting.id, SessionLocal)
|
||||
|
||||
return meeting
|
||||
|
||||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
uvicorn.run("backend.app:app", host="0.0.0.0", port=8001, reload=True)
|
||||
Reference in New Issue
Block a user