fix(app): compute conversation duration from transcript, not session span#7528
fix(app): compute conversation duration from transcript, not session span#7528lucidsif wants to merge 1 commit into
Conversation
Greptile SummaryThis PR fixes a long-standing over-counting bug in
Confidence Score: 5/5Safe to merge — the change is a one-line guard in a model helper with no API, schema, or UI contract changes, and it is backed by six targeted unit tests. The fix correctly re-orders the two existing duration strategies: transcript offsets are now the primary path and the session-timestamp delta is the fallback. Both code paths already existed and are well-understood; the only change is which one runs first. Unit tests confirm the primary bug scenario (600 s session / 12 s speech → returns 12) as well as edge cases. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["getDurationInSeconds()"] --> B{transcriptSegments empty?}
B -- "Yes (no speech data)" --> C{finishedAt AND startedAt set?}
C -- Yes --> D["return finishedAt − startedAt\n(session-span fallback)"]
C -- No --> E["return 0"]
B -- "No (speech segments present)" --> F["_getDurationInSecondsByTranscripts()"]
F --> G["iterate segments,\nfind max end time"]
G --> H["return lastEndTime.toInt()\n(actual speech duration)"]
Reviews (2): Last reviewed commit: "fix(app): compute conversation duration ..." | Re-trigger Greptile |
2e9106f to
466aa5f
Compare
…span getDurationInSeconds() returned finishedAt - startedAt whenever both were set. started_at is anchored to the audio-streaming session origin (not the conversation), so for short conversations the value over-counts by however long the streaming session had been open — often 20-30+ minutes shown for 1-2 minutes of speech. Prefer the existing transcript-derived calculation when segments are present; keep the timestamp delta only as a fallback for segment-less conversations. Adds unit tests (test/unit/conversation_duration_test.dart): the new segment-span behavior (single + multi-segment), plus regression coverage that the unchanged paths still hold — segment-less + timestamps -> delta, segments + no timestamps -> transcript span, and the empty/partial cases -> 0. Fixes BasedHardware#4056
466aa5f to
1349347
Compare
kodjima33
left a comment
There was a problem hiding this comment.
thanks — transcript-based duration is the right fix
|
thank you for the review @kodjima33. looks like the lint check workflow is still awaiting maintainer approval to run (first-contribution gate). i'm not sure how this works exactly. let me know if there's anything you want me to do. |
Summary
Hello! Thanks for this wonderful omi app and open source software. I opened this draft PR to address this issue I just re-opened. Please feel free to comment, open your own PR, or provide any feedback. Please note that I updated the code and PR (mostly refactors, tests, and description changes) after the bot checked this PR.
Bug
The conversation duration is far longer than the actual conversation. This is happening whether I use my own local STT server or a cloud provider's like Deepgram's.
ServerConversation.getDurationInSeconds()returnedfinishedAt - startedAtwhenever both timestamps were set.started_atis set to the audio-streaming session origin not to the individual conversation, so for short conversations the displayed duration over-counts by however long the streaming session had been open which is often waylonger than the actual duration.Root cause
getDurationInSeconds()preferredfinishedAt.difference(startedAt). A correct transcript-based calculation already exists (_getDurationInSecondsByTranscripts()), but was only used as a fallback when timestamps were null. Becausestarted_atreflects when the streaming session opened and persists across conversations until the stream resets, multiple conversations created in one session share an earlystarted_at, and processing promptly does not help. I would notice multiple conversations have a similar length of time/duration padding.Fix
Prefer the transcript-derived duration when transcript segments exist and keep the
finishedAt - startedAtdelta only as a fallback for segment-less conversations. No API or schema changes and minimal changes in the branching.Before / After
For ~10s of speech recorded during a streaming session that had been open ~10 minutes:
Verification