Skip to content

transcribe_audio discards the timestamps Whisper already returns past 30 s; add opt-in segment/word timestamps #483

Closed

Description

@dkackman

tool/endpoint: transcribe_audio (dw/tasks/audio_transcription.py)

Source: field report from an Opus 5.5 session on lem, 2026-09-25/26.

The task returns plain text only. For a 2:41 generated song, cut into 18 lip-synced shots on phrase boundaries, the session needed word and segment times. It replaced the task with local mlx-whisper (word_timestamps=True) and also used that to confirm each dialogue shot spoke its line.

Past 30 s, the task already asks Whisper for return_timestamps=True (its long-form mode needs it), then keeps only result["text"]. The chunks carrying start/end times are thrown away.

expected:

  • An opt-in timestamps: "segment" | "word" argument returns the chunks as a JSON result (start, end, text), chunked for long audio. The default output stays text.
  • With it, a music video can be cut to the lyric, and lines can be checked against shots, without leaving dw.

Activity

  1. dkackman commented on Sep 26, 2026

    @dkackman
    OwnerAuthor

    triage: escalate — adds a new task argument (timestamps: segment|word) that switches transcribe_audio's result from text to JSON, so one command would have two return kinds; the returns:"json" / content_type validation and list_tasks' assessment grouping assume one per command, and word-level long-form Whisper is its own path. Needs sign-off on the shape (flag vs. a separate command) before a fix session builds it. (claude-opus-5-5 via anthropic)

  2. added
    owner:donParked for human decision
    status:needs-approvalParked pending a written proposal + human approval
    and removed on Sep 26, 2026
  3. dkackman commented on Sep 27, 2026

    @dkackman
    OwnerAuthor

    Approved. Add an opt-in timestamps: \"segment\" | \"word\" argument to transcribe_audio. When set, return a dict of chunks (start, end, text) instead of the plain string; default (unset) stays text, unchanged.

    On the triage concern: checked register_command's returns= kinds (dw/tasks/task.py) — transcribe_audio is declared returns=\"artifact\", which imposes no fixed shape. The "one command, one return kind" assumption only binds returns=\"scalar\"/\"json\" commands (the assess probes, list_tasks's assessment grouping). So this doesn't need a new command, a returns variant, or any change to scalar_result_validation.py/content_types.py/list_tasks — it's contained to audio_transcription.py and its get_task docstring/schema.

    One thing to get right in the fix: return_timestamps=True is currently only requested past the 30s long-form threshold (_WHISPER_WINDOW_SECONDS). timestamps: \"word\" (or \"segment\") on a clip under 30s needs to request it explicitly too, rather than silently no-op'ing because the long-form branch didn't fire.

    Removing owner:don + status:needs-approval, handing to the implementer.

  4. added and removed
    owner:donParked for human decision
    status:needs-approvalParked pending a written proposal + human approval
    on Sep 27, 2026
  5. dkackman commented on Sep 27, 2026

    @dkackman
    OwnerAuthor

    triage: work — Don approved the shape (opt-in timestamps: "segment"|"word" on transcribe_audio, returns="artifact", contained to dw/tasks/audio_transcription.py + its schema/docstring). Request return_timestamps explicitly under 30 s too, not only in the long-form branch; default output stays text. (claude-opus-5-5 via anthropic)

  6. dkackman commented on Sep 27, 2026

    @dkackman
    OwnerAuthor

    Fixed and deployed by claude-sonnet-5 (anthropic).

    transcribe_audio (dw/tasks/audio_transcription.py) now takes an opt-in timestamps kwarg: "segment" requests return_timestamps=True, "word" requests return_timestamps="word" (works on both seq2seq Whisper and CTC pipes). Either returns {"text": ..., "chunks": [{"start", "end", "text"}, ...]} instead of the plain string; a step returning this shape must set result.content_type to application/json (readable via MCP's get_output_text, which already accepts JSON). Unset timestamps is unchanged — still plain text, and still only auto-requests return_timestamps=True past the 30 s long-form threshold for Whisper.

    Per the approved shape: an explicit timestamps request now fires regardless of clip length (covered by test_timestamps_requested_under_thirty_seconds_too) rather than only past 30 s — the under-30s no-op Don flagged doesn't happen. An invalid timestamps value raises ValueError. Docs updated in docs/TASKS.md's Speech Transcription section.

    Shipped as commit d3ecf60, merged to develop at 57c3fc6, deployed to lem (develop @ 57c3fc6, healthy).

    Tests: 5 new cases in tests/test_transcribe_audio.py (word/segment chunk shapes, under-30s explicit request, unset-stays-text, invalid-value rejection) plus the full existing suite, all passing; ruff clean on changed files.

    Suggested regression case (smoke suite): call transcribe_audio on a short (<30s) known-speech clip with timestamps: "word", result.content_type: "application/json"; expect the job's output to decode as {"text": <non-empty>, "chunks": [...]} with each chunk carrying numeric start/end and non-empty text, and no return_timestamps-related error even though the clip is under 30s.

  7. dkackman commented on Sep 27, 2026

    @dkackman
    OwnerAuthor

    Verified by claude-opus-5-5 (anthropic) against lem develop @ 57c3fc6, over MCP only.

    get_task("transcribe_audio") lists the new timestamps parameter. Its description says that "segment"/"word" returns {text, chunks} and needs result.content_type: "application/json".

    I ran one inline workflow with 4 steps (job a82464c58b9f, workspace qa-ep73, succeeded in 13 s):

    • word, under 30 s (asset:qa-cast/priya-voice.wav, about 6 s): returned {"text": "Priya, did the stashios go on all again?", "chunks": [...]} with 8 word chunks, each with numeric start/end (0.0–5.82) and non-empty text. So the explicit request takes effect under 30 s instead of being silently ignored.
    • segment, same clip: returned 1 chunk, {start: 0.0, end: 5.0, text: ...}.
    • segment, past 30 s (asset:qa-cast/ep55-episode.mp4): returned 10 segment chunks, 0.0–49.46 s, contiguous and on phrase boundaries. This is the long-form case from the original report.
    • timestamps unset: plain text/plain output (Priya. Did the stashios go on all again?), unchanged.

    I also checked two edge cases:

    • timestamps: "sentence" fails the job with timestamps must be one of ('segment', 'word'), got 'sentence' (job 5d4ad761666b). That's the expected behavior.
    • timestamps: "word" with result.content_type: "text/plain": validate_workflow reports it valid, but the run fails while saving with write() argument must be str, not list (job 0759bd1a541e). The schema description does document that JSON is required, so this doesn't count against this issue. The late, opaque error is filed separately as friction.

    All three runs were deleted afterwards. The result matches expected:, so I'm closing this as verified.

  8. added
    status:verifiedTester confirmed the fix via a real MCP call
    and removed on Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend:sharedbugSomething isn't workingfield-reportFiled from Don's own dw sessions (real use), not the harnessowner:testerTester's turn to actstatus:verifiedTester confirmed the fix via a real MCP calltarget:lem

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions