fix(cli): assign w{index} ids when loading JSON transcripts - #3770
Open
santhiprakash wants to merge 1 commit into
Open
fix(cli): assign w{index} ids when loading JSON transcripts#3770santhiprakash wants to merge 1 commit into
santhiprakash wants to merge 1 commit into
Conversation
loadTranscript assigns id: w{index} on the srt/vtt branches but never on
the JSON branches: parseWhisperCpp and parseOpenAI drop the field and the
words-json branch defaults it to "". Every engine funnels through
loadTranscript, and transcribeAudio rewrites transcript.json from its
output, so CLI-produced transcripts ship without the stable word ids that
transcribe.md documents for caption overrides — per-word overrides have
nothing to key on.
Assign id: w.id || `w{index}` across the JSON branches, matching the
srt/vtt behavior. || also repairs the empty-string ids older CLIs wrote
to words-json files, which otherwise collapse every word onto one key.
Signed-off-by: Santhi Prakash <b.santhiprakash@gmail.com>
miguel-heygen
approved these changes
Sep 8, 2026
miguel-heygen
enabled auto-merge (squash)
September 8, 2026 19:23
Contributor
Author
|
One CI note so the red X doesn't need investigating: the |
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.
Continuation of #3461, closed in the 2026-09-08 stale-PR sweep with "please reopen with a rebased version if still relevant." This is that rebased version — GitHub blocks author-reopens on PRs closed by a maintainer, so it is filed fresh. Rebased onto current main (
d66cd6dcc); the words-json loader on main still defaults missing ids to"", so the fix applies unchanged.Fixes #3442
What
loadTranscriptnow assignsid: w{i}on the JSON branches (whisper-cpp, OpenAI, words-json), matching what the srt/vtt branches already do. The words-json branch also stops defaulting missing ids to""— it repairs them tow{i}instead.Why
audio/references/transcribe.mddocuments that word ids (w0,w1, …) are "added during normalization for stable references in caption overrides", but every JSON path dropped them:parseWhisperCppandparseOpenAInever setid, and the flat words-json branch defaulted it to"", collapsing every word onto the same empty key. All engines funnel throughloadTranscript—transcribeAudiorewritestranscript.jsonfrom its output — so CLI-produced transcripts ship without ids and per-word caption overrides have nothing to key on (#3442 has the full breakdown, including the SRT round-trip workaround users currently need).How
Single normalization point: after the existing format-specific parsing in
loadTranscript, mapid: w.id || \w{i}`over the words.||rather than??so the empty-string ids written by older CLIs into words-json files are repaired on load, not preserved. SRT/VTT branches keep their existing assignment; theWord.id` doc comment already describes exactly this behavior.Test plan
packages/cli:bunx vitest run src/whisper/on the rebased head (c1f87c64b) — 108/108 pass, including updated expectations (whisper-cpp / openai / words-json now carryw0…ids) and the regression test that preserves existing ids (keep-me) while repairing empty ("" → w1) and missing (→ w2) ones. The count includes 4 newer tests from fix(cli): keep phrase-level CJK and Thai transcripts as separate cues #3436 on the rebased base.tsc --noEmitinpackages/cli— clean on the rebased head.packages/clivitest suite green apart from the same 20 pre-existing environmental failures as clean main, plusoxlint/oxfmt --checkgreen.This change is AI-assisted; the bug analysis, fix, and tests were verified against the reproduction in #3442.