- 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
61 lines
1.9 KiB
Python
61 lines
1.9 KiB
Python
import logging
|
|
from sqlalchemy.orm import Session
|
|
from .ffmpeg_service import FFmpegService
|
|
from .transcription_service import TranscriptionService
|
|
from ..database import Meeting, TranscriptChunk
|
|
from ..config import settings
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
def process_meeting_task(meeting_id: int, db_session_factory):
|
|
db = db_session_factory()
|
|
meeting = db.query(Meeting).filter(Meeting.id == meeting_id).first()
|
|
if not meeting:
|
|
return
|
|
|
|
try:
|
|
ffmpeg = FFmpegService()
|
|
transcriber = TranscriptionService()
|
|
|
|
# Phase 1: Split
|
|
meeting.status = "SPLITTING"
|
|
db.commit()
|
|
|
|
meeting.duration_seconds = ffmpeg.get_duration(meeting.file_path)
|
|
chunks = ffmpeg.split_audio(meeting.file_path, meeting.id)
|
|
|
|
# Phase 2: Transcribe
|
|
meeting.status = "TRANSCRIBING"
|
|
db.commit()
|
|
|
|
all_text = []
|
|
for i, chunk_path in enumerate(chunks):
|
|
offset = i * settings.CHUNK_DURATION_SEC
|
|
logger.info(f"Processing chunk {i+1}/{len(chunks)} with offset {offset}s")
|
|
|
|
result = transcriber.transcribe_chunk(chunk_path, offset)
|
|
|
|
# Save chunk result
|
|
db_chunk = TranscriptChunk(
|
|
meeting_id=meeting.id,
|
|
chunk_index=i,
|
|
raw_text=result["raw_text"]
|
|
)
|
|
db.add(db_chunk)
|
|
all_text.append(result["raw_text"])
|
|
db.commit()
|
|
|
|
# Phase 3: Finalize
|
|
meeting.status = "COMPLETED"
|
|
# Combine summary (first attempt - can be refined later with separate LLM call)
|
|
# meeting.summary = ...
|
|
db.commit()
|
|
logger.info(f"Meeting {meeting.id} processing completed.")
|
|
|
|
except Exception as e:
|
|
logger.error(f"Error processing meeting {meeting_id}: {e}", exc_info=True)
|
|
meeting.status = "ERROR"
|
|
db.commit()
|
|
finally:
|
|
db.close()
|