feat(transcription): v0.4.0 with structured json, inline editing and deletion

- Backend: Switched prompt to JSON output for structured data
- Backend: Added PUT /chunks/{id} endpoint for persistence
- Backend: Fixed app.py imports and initialization logic
- Frontend: Complete rewrite for Unified View (flattened chunks)
- Frontend: Added Inline Editing (Text/Speaker) and Row Deletion
- Docs: Updated TRANSCRIPTION_TOOL.md with v0.4 features
This commit is contained in:
2026-01-24 20:43:33 +00:00
parent 4e52e194f1
commit 68f263978a
5 changed files with 389 additions and 99 deletions

View File

@@ -1,6 +1,8 @@
from fastapi import FastAPI, Depends, HTTPException, UploadFile, File, BackgroundTasks
from fastapi import FastAPI, Depends, HTTPException, UploadFile, File, BackgroundTasks, Body
from fastapi.staticfiles import StaticFiles
from fastapi.middleware.cors import CORSMiddleware
from sqlalchemy.orm import Session
from sqlalchemy.orm import Session, joinedload
from typing import List, Dict, Any
import os
import shutil
import uuid
@@ -10,6 +12,7 @@ from .config import settings
from .database import init_db, get_db, Meeting, TranscriptChunk, AnalysisResult, SessionLocal
from .services.orchestrator import process_meeting_task
# Initialize FastAPI App
app = FastAPI(
title=settings.APP_NAME,
version=settings.VERSION,
@@ -36,6 +39,33 @@ def health():
def list_meetings(db: Session = Depends(get_db)):
return db.query(Meeting).order_by(Meeting.created_at.desc()).all()
@app.get("/api/meetings/{meeting_id}")
def get_meeting(meeting_id: int, db: Session = Depends(get_db)):
meeting = db.query(Meeting).options(
joinedload(Meeting.chunks)
).filter(Meeting.id == meeting_id).first()
if not meeting:
raise HTTPException(404, detail="Meeting not found")
# Sort chunks by index
meeting.chunks.sort(key=lambda x: x.chunk_index)
return meeting
@app.put("/api/chunks/{chunk_id}")
def update_chunk(chunk_id: int, payload: Dict[str, Any] = Body(...), db: Session = Depends(get_db)):
chunk = db.query(TranscriptChunk).filter(TranscriptChunk.id == chunk_id).first()
if not chunk:
raise HTTPException(404, detail="Chunk not found")
# Update JSON content (e.g. after editing/deleting lines)
if "json_content" in payload:
chunk.json_content = payload["json_content"]
db.commit()
return {"status": "updated"}
@app.post("/api/upload")
async def upload_audio(
background_tasks: BackgroundTasks,
@@ -67,6 +97,39 @@ async def upload_audio(
return meeting
@app.delete("/api/meetings/{meeting_id}")
def delete_meeting(meeting_id: int, db: Session = Depends(get_db)):
meeting = db.query(Meeting).filter(Meeting.id == meeting_id).first()
if not meeting:
raise HTTPException(404, detail="Meeting not found")
# 1. Delete Files
try:
if os.path.exists(meeting.file_path):
os.remove(meeting.file_path)
# Delete chunks dir
chunk_dir = os.path.join(settings.UPLOAD_DIR, "chunks", str(meeting_id))
if os.path.exists(chunk_dir):
shutil.rmtree(chunk_dir)
except Exception as e:
print(f"Error deleting files: {e}")
# 2. Delete DB Entry (Cascade deletes chunks/analyses)
db.delete(meeting)
db.commit()
return {"status": "deleted"}
# Serve Frontend
# This must be the last route definition to avoid catching API routes
static_path = "/frontend_static"
if not os.path.exists(static_path):
# Fallback for local development if not in Docker
static_path = os.path.join(os.path.dirname(__file__), "../frontend/dist")
if os.path.exists(static_path):
app.mount("/", StaticFiles(directory=static_path, html=True), name="static")
if __name__ == "__main__":
import uvicorn
uvicorn.run("backend.app:app", host="0.0.0.0", port=8001, reload=True)