wip: replace created_at by started_at. may want to revert
This commit is contained in:
@@ -166,7 +166,7 @@ class NotificationService:
|
||||
"sub": owner_access.user.sub,
|
||||
"room": recording.room.name,
|
||||
"language": recording.options.get("language"),
|
||||
"recording_datetime": recording.created_at.isoformat(),
|
||||
"worker_id": recording.worker_id,
|
||||
"owner_timezone": str(owner_access.user.timezone),
|
||||
"download_link": f"{get_recording_download_base_url()}/{recording.id}",
|
||||
"context_language": owner_access.user.language,
|
||||
|
||||
@@ -25,7 +25,7 @@ class TranscribeSummarizeTaskCreation(BaseModel):
|
||||
sub: str
|
||||
version: Optional[int] = 2
|
||||
room: Optional[str]
|
||||
recording_datetime: Optional[str]
|
||||
worker_id: Optional[str]
|
||||
owner_timezone: Optional[str]
|
||||
language: Optional[str]
|
||||
download_link: Optional[str]
|
||||
@@ -58,7 +58,7 @@ async def create_transcribe_summarize_task(request: TranscribeSummarizeTaskCreat
|
||||
request.sub,
|
||||
time.time(),
|
||||
request.room,
|
||||
request.recording_datetime,
|
||||
request.worker_id,
|
||||
request.owner_timezone,
|
||||
request.language,
|
||||
request.download_link,
|
||||
|
||||
@@ -112,7 +112,7 @@ class MetadataManager:
|
||||
if self._is_disabled or self.has_task_id(task_id):
|
||||
return
|
||||
|
||||
_, filename, email, _, received_at, *_ = task_args
|
||||
_, filename, _, email, _, received_at, *_ = task_args
|
||||
|
||||
start_time = time.time()
|
||||
initial_metadata = {
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
# ruff: noqa: PLR0913
|
||||
|
||||
import json
|
||||
import os
|
||||
import time
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
from typing import Optional
|
||||
|
||||
import openai
|
||||
@@ -182,7 +183,7 @@ def process_audio_transcribe_summarize_v2(
|
||||
sub: str,
|
||||
received_at: float,
|
||||
room: Optional[str],
|
||||
recording_datetime: Optional[str],
|
||||
worker_id: Optional[str],
|
||||
owner_timezone: Optional[str],
|
||||
language: Optional[str],
|
||||
download_link: Optional[str],
|
||||
@@ -205,7 +206,7 @@ def process_audio_transcribe_summarize_v2(
|
||||
sub: OIDC subject identifier of the recording owner.
|
||||
received_at: Unix timestamp when the recording was received.
|
||||
room: room name where the recording took place.
|
||||
recording_datetime: ISO 8601 UTC datetime of the recording.
|
||||
worker_id: LiveKit egress ID used to fetch the egress JSON from S3.
|
||||
owner_timezone: IANA timezone of the recording owner (e.g. "Europe/Paris").
|
||||
language: ISO 639-1 language code for transcription.
|
||||
download_link: URL to download the original recording.
|
||||
@@ -224,11 +225,28 @@ def process_audio_transcribe_summarize_v2(
|
||||
if transcription is None:
|
||||
return
|
||||
|
||||
# Fetch recording start time from LiveKit egress JSON
|
||||
recording_datetime = None
|
||||
recording_start_dt = None
|
||||
if worker_id:
|
||||
folder = os.path.dirname(recording_filename)
|
||||
egress_json_key = f"{folder}/{worker_id}.json"
|
||||
try:
|
||||
egress_info = file_service.read_json(egress_json_key)
|
||||
started_at_ns = egress_info.get("started_at")
|
||||
if started_at_ns:
|
||||
recording_start_dt = datetime.fromtimestamp(
|
||||
started_at_ns / 1e9, tz=timezone.utc
|
||||
)
|
||||
recording_datetime = recording_start_dt.isoformat()
|
||||
except Exception:
|
||||
logger.warning(
|
||||
"Could not read egress JSON %s, falling back to no recording datetime",
|
||||
egress_json_key,
|
||||
)
|
||||
|
||||
# Assign user names from metadata and transcription
|
||||
metadata = file_service.read_json(metadata_filename)
|
||||
recording_start_dt = (
|
||||
datetime.fromisoformat(recording_datetime) if recording_datetime else None
|
||||
)
|
||||
if recording_start_dt is not None:
|
||||
assign_speakers(
|
||||
metadata, transcription, recording_start_dt, overlap_threshold=0.5
|
||||
|
||||
@@ -64,7 +64,10 @@ class AssignmentResult:
|
||||
|
||||
def _replace_speaker(item: dict[str, Any]) -> dict[str, Any]:
|
||||
if "speaker" in item and item["speaker"] in speaker_to_name:
|
||||
return {**item, "speaker": speaker_to_name[item["speaker"]]}
|
||||
return {
|
||||
**item,
|
||||
"speaker": f"{speaker_to_name[item['speaker']]}:{item['speaker']}", # We still use the original diarization
|
||||
}
|
||||
return item
|
||||
|
||||
result: dict[str, Any] = {}
|
||||
@@ -165,6 +168,7 @@ def _build_participant_timelines(
|
||||
ts = _parse_iso(event["timestamp"]).timestamp() - ref_epoch
|
||||
etype = event["type"]
|
||||
|
||||
# TODO: close open speech_start
|
||||
if etype == "speech_start":
|
||||
open_starts[pid] = max(ts, 0.0)
|
||||
elif etype == "speech_end":
|
||||
@@ -224,6 +228,14 @@ def assign_speakers(
|
||||
)
|
||||
speaker_timelines = _build_speaker_timelines(transcription)
|
||||
|
||||
logger.info("Info info info")
|
||||
logger.info(metadata)
|
||||
logger.info(recording_start_datetime)
|
||||
logger.info("participant_timelines")
|
||||
logger.info(participant_timelines)
|
||||
logger.info("participant_names")
|
||||
logger.info(participant_names)
|
||||
|
||||
result = AssignmentResult()
|
||||
|
||||
for speaker, speaker_intervals in speaker_timelines.items():
|
||||
|
||||
@@ -24,7 +24,7 @@ class TestTasks:
|
||||
"email": "user@example.com",
|
||||
"sub": "sub-123",
|
||||
"room": "room-abc",
|
||||
"recording_datetime": "2026-01-01T10:00:00+00:00",
|
||||
"worker_id": "EG_test123",
|
||||
"owner_timezone": "UTC",
|
||||
"language": None,
|
||||
"download_link": "http://example.com/file.mp4",
|
||||
@@ -43,7 +43,7 @@ class TestTasks:
|
||||
"sub-123", # sub
|
||||
1735725600.0, # frozen time
|
||||
"room-abc", # room
|
||||
"2026-01-01T10:00:00+00:00", # recording_datetime
|
||||
"EG_test123", # worker_id
|
||||
"UTC", # owner_timezone
|
||||
None, # language
|
||||
"http://example.com/file.mp4", # download_link
|
||||
|
||||
Reference in New Issue
Block a user