Skip to content

feat(lint): detect narration drift against narration.json - #8939

Open
DhanushMurugesanG wants to merge 2 commits into
heygen-com:mainfrom
DhanushMurugesanG:narration/2-lint
Open

DhanushMurugesanG wants to merge 2 commits into
heygen-com:mainfrom
DhanushMurugesanG:narration/2-lint

Conversation

@DhanushMurugesanG

Copy link
Copy Markdown

Part 2 of 4 for linked narration (#6708). Builds on #8938: until that merges, this PR also shows its commit. Only the last commit (feat(lint): …) is new here.

What

When a project has a narration.json, hyperframes lint (and check) now warns about drift between the script, the audio and the captions:

Code Severity When
narration_manifest_invalid warning narration.json isn't valid
narration_line_unlinked warning a line has no <audio data-narration-line> clip, or more than one; or a clip names an unknown line
narration_audio_stale warning the line's text, voice settings or WAV changed since it was voiced, or the WAV is missing
narration_clip_timing_mismatch warning the clip plays more than 0.05 s longer or shorter than audio_meta.json says the voice lasts
narration_captions_out_of_sync warning the caption words showing a line differ in number from the voice's words, or one starts more than 0.1 s off
narration_transcript_mismatch info captions in sync but reading differently from the script (often "47" for "forty-seven")

No narration.json, no findings. Everything is a warning or info, so drift never blocks a render. This part is read-only.

Why

It's useful on its own: an agent or a person editing a narrated project learns that a line's voice no longer says its text, or that captions slipped, before rendering.

Related work

Refs #6708. Follows #8938; next are narration list / init / check and narration set.

How

  • packages/lint/src/projectNarration.ts takes the main timeline's audio clips and the caption array's words in global time. project.ts adds data-narration-line to the audio spans it already collects, and records each mounted file's origin, so captions in a nested scene are placed at the scene's start.
  • A line's caption words are the ones tagged "line": "<id>", or else the untagged words inside its clip's time window, so captions made before this existed still work.
  • Lengths and word timings come from audio_meta.json by line id (see feat(parsers): narration.json model and caption-array reader #8938 for why they aren't copied into narration.json), and only when its entry describes the line's own audio file. Without it, the length isn't checked, and a tagged caption word only has to start inside its clip.
  • Fix hints point at what exists today (re-voicing with media-use). Parts 3 and 4 switch them to the new commands.

Test plan

  • Unit tests added/updated: projectNarration.test.ts, 13 cases on real projects through lintProject. No manifest; in sync; invalid manifest; text, voice and WAV changes; missing WAV; unlinked lines and clips; length within and past 0.05 s; shifted and missing caption words; no audio_meta.json; an audio_meta.json entry for another file; untagged words; captions in a mounted scene; transcript mismatch as info.
  • bun run --filter @hyperframes/lint test: 33 files, 1,379 tests pass.
  • Documentation updated: a "Narration" section in docs/reference/lint-rules.mdx.
  • Comments say why, not what.

Adds two subpaths that later narration work builds on. No behaviour
changes: nothing imports them yet.

- @hyperframes/parsers/narration: reads, checks and writes
  narration.json, the script of a narrated project (each line's text,
  voice, audio file and what it was last voiced from), keeping unknown
  keys. Lengths and word timings are not copied into it:
  narrationTimingsOf() reads them from media-use's audio_meta.json by
  line id.
- @hyperframes/parsers/caption-array: finds const/let/var `script` and
  `TRANSCRIPT` caption arrays in HTML, reads their words, and splices or
  shifts words while every other element stays byte-identical.

Refs heygen-com#6708
A project with narration.json now gets a warning when a line's text,
voice or WAV changed since it was voiced, when a line has no linked
clip or its clip is the wrong length, and when the caption words that
show it no longer match its voice. Captions that read differently from
the script get an info. No manifest, no findings, and nothing blocks a
render.

Lengths and word timings come from media-use's audio_meta.json by line
id. Without it, the length isn't checked and a line's captions only
need to fall inside its clip.

Refs heygen-com#6708
@mintlify

mintlify Bot commented Nov 26, 2026

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit a11b896.

Approve preview

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant