fix(cli): assign w{index} ids when loading JSON transcripts - #3461
Open
santhiprakash wants to merge 1 commit into
Open
fix(cli): assign w{index} ids when loading JSON transcripts#3461santhiprakash 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>
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.
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:vitest run src/whisper/— 104/104 pass, including updated expectations (whisper-cpp / openai / words-json now carryw0…ids) and a new regression test that preserves existing ids (keep-me) while repairing empty ("" → w1) and missing (→ w2) ones.packages/clivitest suite — same 20 pre-existing environmental failures as cleanupstream/main(macOS-only telemetry tests on Linux, unbuilt workspace artifacts); zero new failures. Verified by stash/re-run on the clean tree.tsc --noEmitinpackages/cli— clean.oxlint+oxfmt --check+fallow auditvia lefthook pre-commit — all green.This change is AI-assisted; the bug analysis, fix, and tests were verified against the reproduction in #3442.