mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2026-02-04 09:56:47 +00:00
fix: use Daily API recording.duration as master source for transcript duration (#844)
Set duration early in get_participants from Daily API (seconds -> ms), ensuring post_zulip has the value before mixdown_tracks completes. Removes redundant duration update from mixdown_tracks. Co-authored-by: Igor Loskutov <igor.loskutoff@gmail.com>
This commit is contained in:
@@ -322,6 +322,7 @@ async def get_participants(input: PipelineInput, ctx: Context) -> ParticipantsRe
|
|||||||
mtg_session_id = recording.mtg_session_id
|
mtg_session_id = recording.mtg_session_id
|
||||||
async with fresh_db_connection():
|
async with fresh_db_connection():
|
||||||
from reflector.db.transcripts import ( # noqa: PLC0415
|
from reflector.db.transcripts import ( # noqa: PLC0415
|
||||||
|
TranscriptDuration,
|
||||||
TranscriptParticipant,
|
TranscriptParticipant,
|
||||||
transcripts_controller,
|
transcripts_controller,
|
||||||
)
|
)
|
||||||
@@ -330,15 +331,26 @@ async def get_participants(input: PipelineInput, ctx: Context) -> ParticipantsRe
|
|||||||
if not transcript:
|
if not transcript:
|
||||||
raise ValueError(f"Transcript {input.transcript_id} not found")
|
raise ValueError(f"Transcript {input.transcript_id} not found")
|
||||||
# Note: title NOT cleared - preserves existing titles
|
# Note: title NOT cleared - preserves existing titles
|
||||||
|
# Duration from Daily API (seconds -> milliseconds) - master source
|
||||||
|
duration_ms = recording.duration * 1000 if recording.duration else 0
|
||||||
await transcripts_controller.update(
|
await transcripts_controller.update(
|
||||||
transcript,
|
transcript,
|
||||||
{
|
{
|
||||||
"events": [],
|
"events": [],
|
||||||
"topics": [],
|
"topics": [],
|
||||||
"participants": [],
|
"participants": [],
|
||||||
|
"duration": duration_ms,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
await append_event_and_broadcast(
|
||||||
|
input.transcript_id,
|
||||||
|
transcript,
|
||||||
|
"DURATION",
|
||||||
|
TranscriptDuration(duration=duration_ms),
|
||||||
|
logger=logger,
|
||||||
|
)
|
||||||
|
|
||||||
mtg_session_id = assert_non_none_and_non_empty(
|
mtg_session_id = assert_non_none_and_non_empty(
|
||||||
mtg_session_id, "mtg_session_id is required"
|
mtg_session_id, "mtg_session_id is required"
|
||||||
)
|
)
|
||||||
@@ -561,27 +573,13 @@ async def mixdown_tracks(input: PipelineInput, ctx: Context) -> MixdownResult:
|
|||||||
|
|
||||||
Path(output_path).unlink(missing_ok=True)
|
Path(output_path).unlink(missing_ok=True)
|
||||||
|
|
||||||
duration = duration_ms_callback_capture_container[0]
|
|
||||||
|
|
||||||
async with fresh_db_connection():
|
async with fresh_db_connection():
|
||||||
from reflector.db.transcripts import ( # noqa: PLC0415
|
from reflector.db.transcripts import transcripts_controller # noqa: PLC0415
|
||||||
TranscriptDuration,
|
|
||||||
transcripts_controller,
|
|
||||||
)
|
|
||||||
|
|
||||||
transcript = await transcripts_controller.get_by_id(input.transcript_id)
|
transcript = await transcripts_controller.get_by_id(input.transcript_id)
|
||||||
if transcript:
|
if transcript:
|
||||||
await transcripts_controller.update(
|
await transcripts_controller.update(
|
||||||
transcript, {"audio_location": "storage", "duration": duration}
|
transcript, {"audio_location": "storage"}
|
||||||
)
|
|
||||||
|
|
||||||
duration_data = TranscriptDuration(duration=duration)
|
|
||||||
await append_event_and_broadcast(
|
|
||||||
input.transcript_id,
|
|
||||||
transcript,
|
|
||||||
"DURATION",
|
|
||||||
duration_data,
|
|
||||||
logger=logger,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx.log(f"mixdown_tracks complete: uploaded {file_size} bytes to {storage_path}")
|
ctx.log(f"mixdown_tracks complete: uploaded {file_size} bytes to {storage_path}")
|
||||||
|
|||||||
Reference in New Issue
Block a user