Repository navigation
feat(cli): narration set re-voices one line - #8941
Open
DhanushMurugesanG wants to merge 4 commits into
Open
DhanushMurugesanG wants to merge 4 commits into
DhanushMurugesanG wants to merge 4 commits into
Conversation
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
- init writes narration.json for a project voiced before it existed: from media-use's audio_meta.json and audio_request.json, or from clips already tagged with data-narration-line and the caption words inside them. It tags each line's clip, as one history entry. Lengths and word timings stay in audio_meta.json. - list shows each line, its length from audio_meta.json and its narration findings, or "in sync". - check prints the narration findings from lint and exits 1 while any warning remains. Every subcommand takes --dir and --json and answers the same with --json before or after it. A refusal (no narration.json, nothing to adopt) exits 2 with its message. Refs heygen-com#6708
`hyperframes narration set <id> [text]` voices the line with Kokoro in a scratch folder, transcribes that clip alone, then changes together, as one history entry: the clip's src and data-duration, that line's caption words, caption-overrides.json (indices after the line move; the line's own overrides stay only if its word count is unchanged), narration.json, and the line's voice in audio_meta.json (path, length, words). - The take goes to assets/voice/<id>-<hash>.wav and the old WAV is kept, so history undo always finds the audio it points back to. - A longer take that would run into the next narration clip is refused (--no-retime keeps it); --dry-run writes nothing; an unchanged line is left alone unless --force. - A file edited while the line is voiced refuses the write. - Only Kokoro: a local voice gives the same audio for the same text, so a re-voiced line sounds like its neighbours. Voices that may not repeat are refused with a pointer to re-voicing every line with media-use. Lint's fix hints now name narration set. Refs heygen-com#6708
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
This was referenced Nov 26, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 4 of 4 for linked narration (#6708). Builds on #8938, #8939 and #8940: until they merge, this PR also shows their commits. Only the last commit (
feat(cli): narration set re-voices one line) is new here.What
hyperframes narration set <id> [text]re-voices one line and updates everything that depends on it, together, as onehistoryentry:srcanddata-durationcaption-overrides.json: indices after the line move; the line's own overrides stay only if its word count is unchangednarration.json: the text, voice andvoicedrecordaudio_meta.json(path, length, words), withtotal_duration_ssummed againFlags:
--voice,--speed,--dry-run,--no-retime,--force,--who,--dir,--json.Why
#6708: editing one line should re-voice that line and keep its captions and timing in step, without regenerating the whole voice-over.
Voices that don't repeat
setre-voices one line on its own, so the new take has to sound like the lines around it. That holds for a local voice: Kokoro gives the same audio for the same text and settings. A service whose voices may vary between calls could make an edited line sound different from its neighbours, sosetrefuses any provider other than Kokoro and says why:If a provider can promise repeatable output later (a fixed seed, say), it could be allowed by name.
Related work
Refs #6708. Completes the series: #8938, #8939, #8940, then this.
How
synthesize) and transcribed (runTranscribe) in a scratch folder outside the project. Transcribing inside the project would rewrite every caption array in it. A take with no words heard is refused.narration/planSet.tsplans every change without writing. The apply step copies the WAV toassets/voice/<id>-<hash8>.wav, then callsapplyFileMutationswith each file's version from before the slow voicing step, so a file edited in the meantime refuses the write ("changed while the line was re-voiced; run the command again"). The old WAV is kept, sohistory undonever points a clip at a missing file.--no-retime. Moving later clips is left out of this PR.audio_meta.jsonis updated only if the project has one, written as media-use writes it (two-space JSON). Other fields of the voice entry, and the rest of the file, are kept.narration set.Test plan
narration/set.test.ts, withsynthesizeandrunTranscribemocked as intts.test.ts. It covers:audio_meta.jsonvoice change, and lint is clean afterwards--no-retime; a file changed mid-run refuses the write and leaves no WAVaudio_meta.jsonincluded)audio_meta.json; the command line with--jsonaf_heart) and whisper (small.en) on a 3-line project made the way media-use leaves one:narration init, thencheck: in sync.narration.json, thencheck:narration_audio_staleplus a transcript info.set l2 --dry-run, thenset l2: 1.707 s, 5 words; filesindex.html,audio_meta.json,narration.json.checkandlint: 0 narration findings. A take that runs into l3 is refused.history undorestores every file,audio_meta.jsonincluded.setindocs/packages/cli.mdx, and the lint fix hints.