Skip to main content

video-voice

ShippedSkillFrom skills/video-voice/SKILL.md

Add narration to a video-ai video. Speaks each beat's vo line with a local voice (macOS say, espeak-ng, Piper), or times the beats from the user's own recorded take, rewrites beats.json so every beat lasts as long as its line, then muxes the voice onto the render with an optional ducked music bed at about -14 LUFS. Use when a video-basic or video-pro video needs sound, or beats are timed by guess instead of by the spoken words.

npx skills add rtorcato/video-ai --skill video-voice

video-basic renders silent MP4s and times beats at a guessed ~2.5 words a second. This skill makes the voice first and the picture follow it: the narration decides how long each beat is, then you render, then you mux.

Everything runs offline with a local voice. A hosted voice is never used unless you pass one yourself with --engine-cmd. Needs ffmpeg and ffprobe, and Python 3; no pip packages.

Copy scripts/voice.py, beats.py and beats.schema.json from this skill into your working folder (same rule as the renderers: beats.py is shared).

The flow​

Write a vo line on every beat in beats.json (the schema's vo field), then:

python3 voice.py narrate beats.json voice/ # voice/<beat id>.wav + voice.json
python3 voice.py retime beats.json voice/ # rewrites start/end; the original is kept as beats.orig.json
python3 render.py video index.html silent.mp4 # video-basic; duration now comes from the retimed beats
python3 voice.py mix silent.mp4 beats.json final.mp4 --voice-dir voice/ [--music bed.wav]

Always retime before rendering. mix refuses narration that runs past its beat.

Subtitles come from the same vo lines: after retime, run video-basic's python3 render.py subs beats.json for subs.srt and subs.vtt, or render with --captions to burn them in. Their timing then matches the narration. See video-basic's SKILL.md, Subtitles and captions.

What each step does​

  • narrate: one wav per beat that has a vo line (48 kHz mono). Lines that haven't changed are not re-spoken, so you can edit one beat and re-run in seconds.
    • Voice: --engine auto picks macOS say, else Piper (PIPER_MODEL=/path/voice.onnx), else espeak-ng. Choose a voice with --voice and speed with --rate.
    • Any other voice (Kokoro, a cloud API) plugs in with --engine cmd --engine-cmd "mytool {text_file} {out}". {text_file} is UTF-8 text to speak, {out} is the wav/aiff/mp3 to write. Hosted voices are the user's call and stay off by default.
  • retime: each beat becomes 0.25s lead-in + narration + 0.5s tail (at least 2 s). Beats with no vo keep their length. Captions in a video-pro beats.json move with their beat. Tune with --lead, --tail, --min-beat; --out new.json leaves the original untouched.
  • mix: places each clip at its beat, optionally adds a music bed that ducks under the voice, normalises to --lufs (default -14), and muxes onto the video without re-encoding it. Output audio is stereo AAC.

Your own recording instead of a synthetic voice​

Time the beats from a take where you read the vo lines in order:

python3 voice.py retime beats.json --take take.wav --model ggml-base.en.bin # runs whisper.cpp (whisper-cli) for you
python3 voice.py retime beats.json --take take.wav --transcript take.json # or reuse a whisper.cpp `-oj` transcript
python3 voice.py mix silent.mp4 beats.json final.mp4 --take take.wav

Words are matched to beats by position, so every beat needs a vo line and the take should follow the script. Each beat boundary lands in the pause between two lines. Install whisper.cpp with brew install whisper-cpp; models come from the whisper.cpp project. For video-pro, the take is your A-roll audio: use the same command, then render with render.py all.

Music bed​

--music bed.wav (any ffmpeg-readable file) loops to fit, sits at --music-gain (default 0.35) and ducks while the voice speaks. Use a CC0 or otherwise cleared track, such as one from the Free Music Archive filtered to CC0, or the user's own. The repo ships no music; check the licence of anything you add and tell the user what you used.

Checks before handing over​

  • ffmpeg -i final.mp4 -af ebur128 -f null - shows I: within about 1 LU of the target.
  • Play one beat's start and end: the voice shouldn't be cut off or sit on a cut.
  • Say in the reply which voice and engine you used, and that the narration is synthetic (or that it's their take).