Conversation
Sections from generateExplanation/generateExamples/generateProblemSection use content: [...] (array of strings), which calculateScriptDuration silently skipped. The rendered video track could then be far shorter than the real narration, and ffmpeg -shortest truncated the audio mid-sentence with no warning. Adds a countWords helper that recurses into arrays (string behavior unchanged) and a regression test in testOpenIssueRegressions. Fixes #57
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.
What was broken (root cause)
With
VIDEO_PROVIDER=slideshow,generateSlideshowVideo()sizes the video track fromcalculateScriptDuration(script)— a 150-wpm word-count estimate.calculateScriptDurationonly countedsection.contentwhen it was a string, but the template-mode sections produced bygenerateExplanation/generateExamples/generateProblemSectioninagents/script-writer-agent.jsreturncontent: [...](array of strings). Those words were silently skipped, so the estimate could undershoot the real narration by a large margin (issue reports 42.5s estimated vs 143.5s of real TTS).addAudioToVideomuxes withffmpeg -shortest, so the narration tail was dropped mid-sentence with no error or warning.What changed
utils/ai-video-generator.js: added acountWords(value)helper that recurses into arrays (string counting behavior is byte-for-byte unchanged) and used it forsection.contentincalculateScriptDuration.test.js: added a regression test totestOpenIssueRegressionsasserting array-shaped content is counted (and string-shaped content behaves exactly as before).Fixes #57
How it was tested
calculateScriptDuration ignored array section content: got 30s, expected at least 41s) and passes after.npm test— 46 passed, 0 failed.npm run lint— clean.