✨(summary) enhance transcription document naming with room context
Add optional room name, recording time and date to generate better document names based on user feedback. Template is customizable for internationalization support.
This commit is contained in:
committed by
aleb_the_flash
parent
16dde229cc
commit
6c4c44e933
@@ -136,6 +136,13 @@ class NotificationService:
|
||||
"filename": recording.key,
|
||||
"email": owner_access.user.email,
|
||||
"sub": owner_access.user.sub,
|
||||
"room": recording.room.name,
|
||||
"recording_date": recording.created_at.astimezone(
|
||||
owner_access.user.timezone
|
||||
).strftime("%Y-%m-%d"),
|
||||
"recording_time": recording.created_at.astimezone(
|
||||
owner_access.user.timezone
|
||||
).strftime("%H:%M"),
|
||||
}
|
||||
|
||||
headers = {
|
||||
|
||||
@@ -20,6 +20,9 @@ class TaskCreation(BaseModel):
|
||||
email: str
|
||||
sub: str
|
||||
version: Optional[int] = 2
|
||||
room: Optional[str]
|
||||
recording_date: Optional[str]
|
||||
recording_time: Optional[str]
|
||||
|
||||
|
||||
router = APIRouter(prefix="/tasks")
|
||||
@@ -34,7 +37,13 @@ async def create_task(request: TaskCreation):
|
||||
)
|
||||
else:
|
||||
task = process_audio_transcribe_summarize_v2.delay(
|
||||
request.filename, request.email, request.sub, time.time()
|
||||
request.filename,
|
||||
request.email,
|
||||
request.sub,
|
||||
time.time(),
|
||||
request.room,
|
||||
request.recording_date,
|
||||
request.recording_time,
|
||||
)
|
||||
|
||||
return {"id": task.id, "message": "Task created"}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
"""Celery workers."""
|
||||
|
||||
# ruff: noqa: PLR0913
|
||||
|
||||
import json
|
||||
import os
|
||||
import tempfile
|
||||
import time
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
import openai
|
||||
import sentry_sdk
|
||||
@@ -233,7 +236,14 @@ def process_audio_transcribe_summarize(filename: str, email: str, sub: str):
|
||||
max_retries=settings.celery_max_retries,
|
||||
)
|
||||
def process_audio_transcribe_summarize_v2(
|
||||
self, filename: str, email: str, sub: str, received_at: float
|
||||
self,
|
||||
filename: str,
|
||||
email: str,
|
||||
sub: str,
|
||||
received_at: float,
|
||||
room: Optional[str],
|
||||
recording_date: Optional[str],
|
||||
recording_time: Optional[str],
|
||||
):
|
||||
"""Process an audio file by transcribing it and generating a summary.
|
||||
|
||||
@@ -269,7 +279,10 @@ def process_audio_transcribe_summarize_v2(
|
||||
audio_file = File(temp_file_path)
|
||||
metadata_manager.track(task_id, {"audio_length": audio_file.info.length})
|
||||
|
||||
if settings.recording_max_duration is not None and audio_file.info.length > settings.recording_max_duration:
|
||||
if (
|
||||
settings.recording_max_duration is not None
|
||||
and audio_file.info.length > settings.recording_max_duration
|
||||
):
|
||||
error_msg = "Recording too long: %.2fs > %.2fs limit" % (
|
||||
audio_file.info.length,
|
||||
settings.recording_max_duration,
|
||||
@@ -314,8 +327,16 @@ def process_audio_transcribe_summarize_v2(
|
||||
|
||||
metadata_manager.track_transcription_metadata(task_id, transcription)
|
||||
|
||||
if not room or not recording_date or not recording_time:
|
||||
title = settings.document_default_title
|
||||
else:
|
||||
title = settings.document_title_template.format(
|
||||
room=room,
|
||||
room_recording_date=recording_date,
|
||||
room_recording_time=recording_time,
|
||||
)
|
||||
data = {
|
||||
"title": settings.document_title,
|
||||
"title": title,
|
||||
"content": formatted_transcription,
|
||||
"email": email,
|
||||
"sub": sub,
|
||||
|
||||
@@ -46,7 +46,10 @@ class Settings(BaseSettings):
|
||||
webhook_url: str
|
||||
|
||||
# Output related settings
|
||||
document_title: Optional[str] = "Transcription"
|
||||
document_default_title: Optional[str] = "Transcription"
|
||||
document_title_template: Optional[str] = (
|
||||
'Réunion "{room}" du {room_recording_date} à {room_recording_time}'
|
||||
)
|
||||
|
||||
# Sentry
|
||||
sentry_is_enabled: bool = False
|
||||
|
||||
Reference in New Issue
Block a user