Repository navigation
Narrate explainer videos with the Kokoro af_heart voice - #5
Conversation
- New default engine: Kokoro (kokoro_tts.py), all sentences of a video voiced in one batch from a separate environment ($KOKORO_PYTHON or ~/.venvs/kokoro) - --engine say keeps the macOS voice; --speed for Kokoro - Scene audio loudness-normalized to -16 LUFS - README: Kokoro setup; links to the re-uploaded videos Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reviewer's GuideAPIExpose Kokoro and macOS narration options through the render function and command-line interface, including Kokoro speed control.
ImplementationBatch-synthesize narration with Kokoro or macOS
DocumentationUpdate the published video links and document Kokoro installation, narration options, and rendered outputs.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 security issue, and 1 other issue
Security issues:
- Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'. (link)
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="tools/videos/common.py" line_range="194" />
<code_context>
+ ext = ".aiff" if engine == "say" else ".wav"
+ clips = {(si, k): ((item[1] if isinstance(item, tuple) else item), work / f"s{si:02d}_{k:02d}{ext}")
+ for si, scene in enumerate(video.scenes) for k, item in enumerate(scene.narration)}
+ durations = dict(zip(clips, synthesize(list(clips.values()), engine, voice, rate, speed)))
+
for si, scene in enumerate(video.scenes):
</code_context>
<issue_to_address>
**Video and captions diverge**
When two invocations target the same video name and output directory with different narration timing, or a render stops after replacing the MP4, two render invocations for the same video name and output directory can synthesize different durations, then overwrite the shared MP4 and SRT separately; one invocation can therefore leave the other invocation’s captions paired with its video. A process stopping after the MP4 write can also leave the previous SRT beside the new video, so viewers see mistimed captions.
Stage the outputs as a versioned set and publish them together, or otherwise ensure readers cannot pair artifacts from different renders.
</issue_to_address>
### Comment 2
<location path="tools/videos/common.py" line_range="171-172" />
<code_context>
subprocess.run([_kokoro_python(), str(Path(__file__).with_name("kokoro_tts.py")), str(jobs),
"--voice", voice, "--speed", str(speed)], check=True)
</code_context>
<issue_to_address>
**security (python.lang.security.audit.dangerous-subprocess-use-audit):** Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.
*Source: opengrep*
</issue_to_address>Sourcery assessment
Approval pending. 2 findings to address first.
Blocking findings: tools/videos/common.py:194, tools/videos/common.py:172
| ext = ".aiff" if engine == "say" else ".wav" | ||
| clips = {(si, k): ((item[1] if isinstance(item, tuple) else item), work / f"s{si:02d}_{k:02d}{ext}") | ||
| for si, scene in enumerate(video.scenes) for k, item in enumerate(scene.narration)} | ||
| durations = dict(zip(clips, synthesize(list(clips.values()), engine, voice, rate, speed))) |
There was a problem hiding this comment.
🟡 Medium · Video and captions diverge
When two invocations target the same video name and output directory with different narration timing, or a render stops after replacing the MP4, two render invocations for the same video name and output directory can synthesize different durations, then overwrite the shared MP4 and SRT separately; one invocation can therefore leave the other invocation’s captions paired with its video. A process stopping after the MP4 write can also leave the previous SRT beside the new video, so viewers see mistimed captions.
Stage the outputs as a versioned set and publish them together, or otherwise ensure readers cannot pair artifacts from different renders.
Prompt for AI agents
In `tools/videos/common.py` at line 194:
**Video and captions diverge**
When two invocations target the same video name and output directory with different narration timing, or a render stops after replacing the MP4, two render invocations for the same video name and output directory can synthesize different durations, then overwrite the shared MP4 and SRT separately; one invocation can therefore leave the other invocation’s captions paired with its video. A process stopping after the MP4 write can also leave the previous SRT beside the new video, so viewers see mistimed captions.
Stage the outputs as a versioned set and publish them together, or otherwise ensure readers cannot pair artifacts from different renders.| subprocess.run([_kokoro_python(), str(Path(__file__).with_name("kokoro_tts.py")), str(jobs), | ||
| "--voice", voice, "--speed", str(speed)], check=True) |
There was a problem hiding this comment.
security (python.lang.security.audit.dangerous-subprocess-use-audit): Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.
Source: opengrep
Summary
tools/videos: Kokoro (hexgrad/Kokoro-82M, voiceaf_heart) is the default narration engine.kokoro_tts.pyvoices every sentence of a video in one batch, run from a separate environment ($KOKORO_PYTHON, the current interpreter if it haskokoro, or~/.venvs/kokoro), so PyTorch stays out of the toolkit's dependencies.--engine saykeeps the macOS voice;--speedcontrols Kokoro's pace.Checked
🤖 Generated with Claude Code
Summary by Sourcery
Modernize explainer video narration with Kokoro, consistent audio levels, and refreshed published videos.
New Features:
Bug Fixes:
Enhancements:
Documentation: