Skip to content

idea: script-adherence probe - transcribed take vs expected lines #609

Closed
3 of 3 issues completed
Closed

Description

@dkackman

Idea, not approved work. Recorded from a comparative review; needs a decision before any implementation.

Gap

assess_output checks dead air and sync drift, but nothing checks that a take says what the script said. Comparing a transcribe-audio result against the script is left to the agent.

Idea

A probe next to assess_output (or a new rule set) that takes the expected dialogue lines and returns findings:

  • line_mismatch: Whisper text vs. each expected line, flagged below a similarity threshold (theirs is 0.85).
  • tag_spoken: delivery-tag words heard as speech (e.g. "pause").
  • speech_in_silent_shot: speech in a shot that has no dialogue.
  • line_clipped_at_end: the last line runs into the final ~0.25 s while the audio is still loud.

Notes

  • Whisper invents "Thanks for watching" over silence. Confirm with no_speech_prob (or a second model) before flagging a re-roll.
  • They also check speaker sex by pitch. Do not adopt that: voice_attribution.py already found that a pitch heuristic misgendered a tenor, so we use speaker embeddings.

Their file: skills/vrgdg-h3-film/scripts/qa.py.

Source: concept observed in vrgamegirl19/comfyui-vrgamedevgirl (assessed 2026-10-05). That repo is under a source-available license that is incompatible with our Apache-2.0: re-implement from the concept only, do not copy code, prompt text, or presets verbatim. File references below are to their repo, for understanding the mechanism.

Activity

  1. dkackman commented on Oct 5, 2026

    @dkackman
    OwnerAuthor

    Related: #608 (dialogue rules / speaker checks).

  2. added
    owner:leadFeature lead's turn (harnest R11)
    priority:2Backlog rank: solid ROI, moderate scope
    featureWork bigger than a fix: designed with Don, built in stages (harnest R11)
    and removed
    owner:donParked for human decision
    ideaAn idea for the researcher agent to assess
    on Oct 5, 2026
  3. dkackman commented on Oct 5, 2026

    @dkackman
    OwnerAuthor

    Approved by Don (2026-10-05) at priority:2. It adds MCP surface (expected lines as an assess_output input), so it goes through a plan. Sequence it so #608's probes can use it. The speaker-sex check stays on speaker embeddings, never pitch. Handing to the feature lead for a plan.

  4. dkackman commented on Oct 5, 2026

    @dkackman
    OwnerAuthor

    Plan v2: script-adherence check (#609)

    Feature lead: model claude-opus-5-5 via anthropic, 2026-10-05. v2 folds in Don's answers to Q1–Q4 from his approval of v1; no scope change.

    Verdict: build smaller. A worker task plus a catalog template, not an assess_output input

    Value. Two users gain: Don's driving sessions and the skills that tell them to check a line.

    Build cost. 3 stages at about $9–15 in total.

    Inertia.

    • One new task command (check_script), one catalog template (templates/check-script) and one TASKS.md section.
    • The skills' hand-run procedure gets replaced, not added to.
    • No new MCP tool, parameter or route, and no security boundary changes.
    • The reason it stays off assess_output: the MCP surface budget has 10 tokens of headroom (tests/test_mcp_server.py:1555, 14,255 of 14,265). On top of that, the assess route is CPU-only by design (dw/server/assess.py:5), so it cannot transcribe.

    Reversibility. A task name and a template name. Removing them would break only workflows that reference them, and today there are none.

    Cheaper alternatives.

    • (i) Do nothing. The by-eye check stays, and keeps missing what transcribe_audio plain-text mode returns only the first sentence of a multi-line clip; segment/word modes return all of it #559 showed it misses.
    • (ii) Skill text only, e.g. "compare transcript to script". This gives no findings, timings or hallucination guard, and the agent still reads every word.
    • (iii) Don's framing: expected lines as an assess_output input. See the correction below. It would still need a separate transcribe job first, then a new route or POST plus probe-signature changes, and it would break the "exactly three probes" invariant (docs/ARCHITECTURE.md:113 and 6+ tests). It also needs MCP budget we don't have. Declined by Don (Q1).

    Overlap.

    Proposed follow-up (removal), none found. transcribe-audio stays: this task calls the same code.

    Problem and non-goals

    Problem. No dw check says whether a take speaks its script, drops a line, voices a markup word, talks in a shot meant to be silent, or clips its last word.

    Non-goals.

    Corrections to the proposal (found by the sweep)

    1. assess_output cannot take this. The route runs in the server process and is CPU-only (dw/server/assess.py:1-16), while Whisper needs the worker's model cache (transcribe_audio is consumes_device=True, dw/tasks/task.py:733).
      • An assess_output input could only take a transcript that already exists. The agent's workflow would still be two jobs, so the MCP surface buys nothing.
    2. no_speech_prob isn't available. transcribe_audio uses the HF automatic-speech-recognition pipeline (dw/tasks/audio_transcription.py:89), which doesn't return it.
    3. There's no delivery-tag vocabulary to check against. <pause>, <breath> and <softer> appear nowhere in dw. Our H3 markup is <d>[Lang] …</d>, <scenetrans>, <cutoff>, [unclear] and (Sx) (dw/workflows/h3_context_ir.json:7).
    4. Shot records carry no dialogue (dw/shots.py:45-58). Expected lines must come from the caller. A line can name its shot.

    The design

    New task check_script. It lives in the new module dw/tasks/script_check.py, is registered like attribute_voices (consumes_device=True, returns json, not assessment=True), and leaves the three-probe invariant alone.

    Arguments.

    • audio: a file, video or output:/asset: reference, same as transcribe_audio.
    • lines: a list of strings or {text, shot}, in order. H3 markup is allowed and stripped (Q2). [] means "no speech expected".
    • shots: optional. Resolved as the probes resolve them: argument, then the artifact's .shots, then the manifest (dw/tasks/assess.py:228 resolve_shots, reused).
    • similarity: default 0.85 in the task; the template's default is set in stage C from measurement (Q3).
    • model_name: the task default stays openai/whisper-base, matching transcribe_audio (Q3).

    How it works.

    1. Transcribe by calling transcribe_audio(timestamps="word") (reused; no second ASR path).
    2. Drop guarded words (correction 2).
    3. Normalize both sides: lowercase, strip punctuation, keep apostrophes.
    4. Align the heard words to the expected words in order, with difflib.SequenceMatcher on word lists (stdlib; no new dependency).

    Findings. Each uses the standard finding shape {rule, severity, at, value, threshold, says}, built with dw/assessment_rules.finding().

    rule fires when at severity
    line_mismatch a line's similarity is below similarity that line's first heard word (or its shot start) warn
    tag_spoken a heard word not in the line's text equals a stripped markup token from that line the word warn
    speech_in_silent_shot a guarded heard word falls in a shot that no line names the word warn
    speech_where_silent lines is [] and any guarded speech is heard the first word warn
    line_clipped_at_end a line's last heard word ends inside the final 0.25 s of its shot (or of the file), and that 0.25 s window measures above the dead-air level the word warn

    Answer shape.

    • findings
    • lines: one entry per line with {expected, heard, similarity, start, end, shot}
    • discarded: the guarded words, each with its measured level
    • transcript: the full text
    • rules_applied, plus rules_skipped with the reason (e.g. speech_in_silent_shot skipped when no shots are known)

    The thresholds are module constants, named in TASKS.md. They are not added to RULES, because tests/test_assessment_rules.py:121-135 requires every rule to fire on a synthetic file that has no script.

    Template templates/check-script (shape utility).

    • Variables input_audio, lines and shots, which runs check_script and saves JSON.
    • Its default model_name and similarity are the ones stage A's measurement chose (Q3).
    • Agents run it with run_workflow, then read the findings with get_output_text. The tool surface needs nothing new.

    Engine/MCP/REST/syntax surfaces decided here.

    • Engine: one task command.
    • MCP: none.
    • REST: none.
    • Syntax: none.
    • Catalog: one template.

    Stages

    Stage A: check_script engine, whole-file

    Builds.

    • The module, with alignment, normalization, markup stripping and the energy guard.
    • Rules line_mismatch, tag_spoken, speech_where_silent, and line_clipped_at_end at file end.
    • The task registration and a TASKS.md section.

    Tests. Pure-function unit tests on synthetic word lists and waveforms, with no model download:

    • alignment with a dropped, an added and a reordered line;
    • markup stripping for every H3 token in the table above;
    • the guard dropping a word over silence;
    • a clipped tail versus a quiet tail;
    • [] lines.

    Model measurement (Q3). Stage A's lem verification runs openai/whisper-base and openai/whisper-large-v3-turbo on the same takes: exact lines, one swapped line, one dropped line, and lines with names and numbers. It records the similarity spread for each model on the issue, with the job ids. Stage C reads that record.

    Deploy. Server (worker restart).

    Estimate. $4–6.

    Acceptance intent. Run check_script in a one-step workflow over a transcribe-audio-able take, via run_workflow. Then:

    • With the exact lines, there are no line_mismatch findings and each lines[] entry has a similarity of about 1 or above the threshold.
    • With one line swapped for different words, exactly that line gets line_mismatch, and at points near where it was spoken.
    • With an expected line that wasn't spoken, it gets line_mismatch with heard: "".
    • With lines: [] on a spoken take, the result is speech_where_silent. On an instrumental, or on silence, there is no finding, and anything Whisper invented over the silence shows under discarded, not findings.
    • A line containing <cutoff> or [unclear] doesn't count the tag against similarity.
    • A malformed lines (not a list; an entry without text) is refused at validate time or with a clear task error naming the argument.
    • The same takes run with model_name set to each of the two models, and the similarity spread for each is recorded.

    Stage B: shot-aware findings

    Builds.

    • {text, shot} lines and the shots resolution (reusing resolve_shots, plus voice_attribution's overlap roll-up where it fits).
    • speech_in_silent_shot, and line_clipped_at_end per shot.
    • rules_skipped when no shots are known.
    • A line naming a shot that doesn't exist is refused, and the refusal names the known shots.

    Tests. Unit tests on synthetic shot maps.

    Deploy. Server.

    Estimate. $3–5.

    Acceptance intent. On a joined multi-shot cut whose shots are recorded (e.g. a concat_videos output):

    • Lines tagged with their shots come back with shot filled.
    • Leaving one dialogue shot's line out produces speech_in_silent_shot in that shot.
    • An asset: cut carrying a keep_output sidecar resolves its shots the same way.
    • A shotless file plus shot-tagged lines gives rules_skipped naming why. That is not a crash and not a false clean.
    • An unknown shot name is refused, listing the valid ones.

    Stage C: template, then retire the hand-run procedure

    Builds.

    • workflows/templates/check-script.json, with a catalog entry and shape utility. Its default model_name and similarity are whichever model separated correct takes from wrong ones in stage A's measurement, and the threshold that separated them; the commit names the job ids (Q3).
    • Replaces the transcribe-and-read-by-eye steps in series-episodes/SKILL.md, minimax-h3/SKILL.md and WORKFLOW_GUIDE loop step 6 with "run templates/check-script" (Q4).
    • Updates the pins at tests/test_mcp_server.py:489-512 and the catalog structure test.
    • Plugin version bump.

    Deploy. Server (catalog) plus plugin.

    Estimate. $2–4.

    Acceptance intent.

    • list_workflows(shape="utility") lists templates/check-script, and validate_workflow on it is clean with a plan.estimate.
    • Running it on a take returns the stage A/B answer via get_output_text.
    • The template's default model and similarity match stage A's recorded measurement.
    • get_guide("workflows", section=...) loop step 6 names the template.
    • The plugin skills' text is verified by the tester reading the installed plugin.

    Order and dependencies

    The stages run A → B → C. Each one lands alone: A is an unreferenced task until C wires it into a template and the skills. No other issue blocks any stage. If #608 is declined, nothing here changes; it only loses a consumer.

    Risks

    • Whisper mishears names and numbers ("2" vs "two", invented proper nouns), which lowers similarity on correct takes. Normalization covers punctuation and case only. The says text tells the agent to listen before re-rolling. Stage A's two-model measurement settles the threshold, as #378 stage D: field test on lem and threshold settling #386 did for the probes.
    • Word timestamps from Whisper are approximate (±0.1–0.3 s). That could make line_clipped_at_end noisy. The energy condition is the safeguard.
    • The energy guard could discard real speech that is quiet (a whisper line). Discarded words are reported, not hidden.

    Decisions (Don, approving v1, 2026-10-05)

    • Q1, where it lives: a worker task check_script plus templates/check-script. No MCP or assess_output change.
    • Q2, markup in lines: accept lines with H3 markup and strip it. The stripped tokens power tag_spoken.
    • Q3, default ASR model, by measurement: the task default stays openai/whisper-base. Stage A measures whisper-base and whisper-large-v3-turbo on the same takes; stage C sets the template's default model and similarity to whichever separates correct takes from wrong ones, naming the job ids in the commit.
    • Q4, retire the hand-run procedure: yes, in stage C.
    • Sequencing: stage A lands before idea: H3 dialogue budget validate warnings + minimax-h3 references/dialogue.md (verify on lem first) #608's A1 probes.
  5. added
    owner:donParked for human decision
    status:plan-reviewA feature plan is posted and waiting for Don
    and removed
    owner:leadFeature lead's turn (harnest R11)
    on Oct 5, 2026
  6. 12 remaining items

  7. dkackman commented on Oct 5, 2026

    @dkackman
    OwnerAuthor

    Spec for plan v2, written from the approved plan alone. Tester: claude-opus-5-5 via anthropic. Every case is in regression-suite-complete.md (workspace regression-complete), carries pending: #<stage>, and is skipped by regression until its stage verifies.

    #643, A: check_script engine, whole-file

    • C-F281: task registered, with its arguments and defaults (similarity 0.85, whisper-base).
    • C-F282: on a known generate-speech take, the exact, {text} objects, swapped, similarity 0.0, skipped-mid, unspoken-mid and unspoken-end arms. It also asserts the answer and finding shape.
    • C-F283: H3 markup (<d>[en]…</d>, (S1), [unclear], <cutoff>, <scenetrans>) doesn't lower similarity. A heard, non-H3 <pause> gives tag_spoken, which is also the check that stripping uses no fixed list.
    • C-F284: lines: [] on speech gives speech_where_silent. On room tone and on an instrumental it is clean, with any guarded words under discarded. An expected line on silence gives a mismatch with heard: "".
    • C-F285: line_clipped_at_end fires on a take sliced mid-word. A take padded with silence doesn't fire it.
    • C-F286: malformed lines (a string, a dict, an entry with no text, [42]) is refused, naming lines.
    • C-F287: the two-model measurement on #609 stage A: check_script engine, whole-file #643 covers four take types, gives a spread per model, and cites jobs that get_job/get_job_workflow agree with.

    #644, B: shot-aware findings

    • C-F288: a concat_videos cut of ep21 shot1+shot2:
      • with both lines tagged, shot is filled and there's no finding;
      • omitting shot 2's line gives speech_in_silent_shot in shot 2;
      • line_clipped_at_end is checked per shot, against a control transcript.
    • C-F289: the same arms on a keep_output asset of the cut give the same answer. An explicit shots argument works on a shotless wav.
    • C-F290: shot tags on a shotless file complete, with rules_skipped and a reason, and the whole-file rules still run. An unknown shot is refused, listing the valid names.

    #645, C: templates/check-script

    • C-F291: the template is in list_workflows(shape="utility") (needs-input-media; input_audio/lines/shots). transcribe-audio stays. Its defaults match C-F287's record, and validate is clean with plan.estimate.
    • C-F292: a run returns the A/B answer, with a swapped line giving one mismatch on L2.
    • C-F293: guide loop step 6, dw:series-episodes and dw:minimax-h3 name the template, and the by-eye procedure is gone from all three.

    Notes (none blocking):

    1. Instrumental promise vs. the energy guard. The guard discards words below the dead-air level. Over a loud score, a word Whisper invents is above that level, so the guard can't catch it. C-F284's instrumental arm (asset:qa-cast/ep20-score.wav, lines: [], expects no finding) may be where this shows. If the build can't hold that promise, say so in a re-plan rather than at verify.
    2. Shot identifiers. C-F288–C-F290 tag lines with the media.shots name, and fall back to whatever key get_task("check_script") documents. The plan doesn't fix the shots argument's form, so C-F289 uses the form the task schema documents.
    3. C-F117. C-F117 asserts that guide step 6 carries the transcribe-audio by-eye procedure. #609 stage C: check-script template, retire the by-eye procedure #645 replaces that procedure on purpose, so once #609 stage C: check-script template, retire the by-eye procedure #645 verifies, C-F117 needs a suite change request on harnest. I haven't filed one yet because it would be premature now.
  8. added
    owner:leadFeature lead's turn (harnest R11)
    and removed
    status:needs-specTester writes acceptance cases for the plan's stages
    on Oct 5, 2026
  9. dkackman commented on Oct 7, 2026

    @dkackman
    OwnerAuthor

    Close-out: all three stages closed; over to the tester for the feature's last check. (lead: claude-opus-5-5 via anthropic)

    verify: run every case whose source: names one of this feature's stages (#643, #644, #645), and close the parent if they all pass.

    Note: C-F281 was held at #643's verify pending dkackman/harnest#72 (it carried stage B's expectations).

  10. added
    status:verifiedTester confirmed the fix via a real MCP call
    and removed
    owner:leadFeature lead's turn (harnest R11)
    on Oct 7, 2026
  11. dkackman commented on Oct 7, 2026

    @dkackman
    OwnerAuthor

    Verified: feature parent close-out (claude-opus-5-5 via anthropic, tester). lem was on develop @ d977506. All calls were over MCP in workspace regression-complete.

    I ran every case whose source: names #643, #644 or #645 (C-F281..C-F293), exactly as written. All 13 pass.

    • C-F281: get_task("check_script") lists audio, lines (strings or {text, shot}), similarity (0.85), model_name and shots. I removed the leftover pending: #643 line from this case.
    • C-F282:
      • exact and objects arms: findings: [].
      • swapped arm: one line_mismatch at index 1.
      • each unspoken arm: one finding.
    • C-F283:
      • tagged: [].
      • spoken_tag: one tag_spoken "pause" at 5.58 s, and no line_mismatch.
    • C-F284:
      • speech arm: one speech_where_silent.
      • silence and instrumental arms: [], with Whisper's repetitions under discarded.
      • silence_expected: one line_mismatch.
    • C-F285:
      • cut: line_clipped_at_end at index 2, 7.88 s, value -23.07.
      • padded slice: [].
    • C-F286: validate_workflow refuses all four bad variants at steps[0].task.arguments.lines.
    • C-F287:
      • Job af5de241ca83 succeeded. Its realized workflow is one MMS take plus 8 check_script steps (exact, swapped, dropped and numbers, each on base and turbo), matching the table on #609 stage A: check_script engine, whole-file #643.
      • Spreads on correct lines: base 0.43-0.89, turbo 0.71-1.00. Wrong lines score 0.00 on both.
    • C-F288:
      • manifest-shot cut, tagged arm:
        • Lines resolve to ep21-shot1-receipt.mp4 and ep21-shot2-verdict.mp4, similarity 1.0 each, shots_source: manifest.
        • Only speech_where_silent is skipped.
        • The only finding is line_clipped_at_end on line 1 at 10.32 s.
      • omit arm: speech_in_silent_shot at 5.44 s "freezer", in shot 2.
    • C-F289:
      • The kept asset carries the same media.shots.
      • kept_tagged and kept_omit are identical to C-F288.
      • Explicit shots a/b/c: no speech_in_silent_shot.
      • ac arm: exactly one speech_in_silent_shot at 2.54 s "Nobody", in shot b.
    • C-F290:
      • shotless tags: pass.
      • shot: "nope": validate_workflow accepts it, and the run fails with "check_script 'lines'[0] names shot 'nope', which the take does not have - its shots (manifest) are 'ep21-shot1-receipt.mp4', 'ep21-shot2-verdict.mp4'".
    • C-F291:
      • list_workflows(utility) lists templates/check-script with needs-input-media and variables input_audio, lines, model_name, shots and similarity.
      • Defaults are turbo and 0.6, as #609 stage A: check_script engine, whole-file #643's record gives them.
      • Validate returns valid with plan.estimate (minutes null, basis unknown).
      • templates/transcribe-audio is still listed.
    • C-F292:
      • exact: findings: [], similarities 1.0/1.0/0.8889, model turbo, threshold 0.6.
      • swapped line 2: exactly one line_mismatch at line 1 (2.54 s, value 0.1176, heard "Nobody told me. The window had been left open.").
    • C-F293: templates/check-script is the line check in all three places below, and none of them gives a transcribe-and-compare-by-eye procedure. The only arguments any of them shows are input_audio and lines.
      • the workflows guide's "The loop" step 6;
      • the dw:series-episodes skill's "Run and judge";
      • the dw:minimax-h3 skill's "Run and judge" step 4.

    I deleted every run these cases created, plus the cf609-kept.mp4 asset.

    One observation, not a failure: a word that straddles a hard cut is not flagged. In C-F288, "The" ends at 5.44 s, past shot 1's end at 5.167 s. line_clipped_at_end only looks at the last 0.25 s inside the shot, and the case's control expects this.

  12. added a commit that references this issue on Oct 10, 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:sharedenhancementNew feature or requestfeatureWork bigger than a fix: designed with Don, built in stages (harnest R11)owner:testerTester's turn to actpriority:2Backlog rank: solid ROI, moderate scopestatus:plan-approvedDon approved the feature plan (Don only)status:verifiedTester confirmed the fix via a real MCP call

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions