Skip to content

Explainer videos and product demos made by your AI agent. Free and open source: a local voice (Kokoro), word timing (Whisper) and a canvas renderer turn a script into a narrated MP4.

Add README, agent skill, docs media, package metadata and pronunciation checks

Vincent Schmalbach2ee873943178
diff --git a/AGENTS.md b/AGENTS.md
index ef20193..1332edb 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -44,7 +44,8 @@ are your eyes and ears.
3. **Write `script.md` first.** The narration drives everything else.
- Aim for 45 to 120 seconds unless the user asks otherwise. At the default
- speed the voice speaks about 150 words a minute.
+ speed a finished video carries about 150 words a minute, pauses
+ included.
- Structure: a hook that poses the question or problem, the explanation in
small steps, one concrete example, then a short payoff line.
- One idea per scene, usually 1 to 3 sentences (4 to 15 seconds).
@@ -54,7 +55,8 @@ are your eyes and ears.
trigger at least one visual.
- Use `{shown|spoken}` for anything the voice might misread: acronyms
(`{SQL|sequel}`, `{CLI|C L I}`), versions (`{v2.1|version two point one}`),
- symbols and URLs.
+ symbols, domains (`{example.com|example dot com}`, the voice otherwise
+ says "example comm") and URLs.
4. **Generate the voice and read the report.**
@@ -165,7 +167,7 @@ videos/<slug>/
| `size` | `16:9` | `16:9`, `9:16`, `1:1`, `4:5` or `WIDTHxHEIGHT` |
| `fps` | 30 | 24, 25, 30, 50 or 60 |
| `voice` | `af_heart` | run `explainroo voices` |
-| `speed` | 1 | 0.6 to 1.6 |
+| `speed` | 0.9 | 0.6 to 1.6 (voice speed) |
| `music` | `true` | `true` (theme style), a style name, `{ "style", "volume" }` or `false` |
| `sfx` | `true` | `true`, `"minimal"` or `false` |
| `captions` | `"auto"` | burned-in captions; auto means on for vertical and square videos |
@@ -185,5 +187,9 @@ Scene attributes in `script.md`: `## id {hold=1.5 min=5 lead=0.2 transition=cut}
audio engine (`engine/audio/`).
- Run `npm test` after changes. For engine changes, render the examples in
`examples/` and look at their stills and sheets.
+- `dev/audio-lab.mjs` renders every music style and sound effect and measures
+ loudness, true peak and determinism with ffmpeg.
+- `npm run build:icons` rebuilds `engine/icons/` from `lucide-static`, and
+ `npm run build:fonts` downloads the bundled fonts again.
- Keep the scene API small and forgiving, with error messages that tell an
agent exactly what to change.
diff --git a/CLAUDE.md b/CLAUDE.md
new file mode 100644
index 0000000..43c994c
--- /dev/null
+++ b/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/README.md b/README.md
index ee19bb6..a567545 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,188 @@
# explainroo
-Narrated explainer videos made by your coding agent. Pure JavaScript, local voice, no API keys.
+Narrated explainer videos made by your coding agent. Pure JavaScript, a local
+voice, no API keys and no video model.
-Early: the first release is being built.
+[![The explainroo launch video, made with explainroo](docs/media/intro.gif)](https://github.com/vincentsch/explainroo/releases/download/v0.1.0/explainroo-intro.mp4)
+
+*The launch video above was made by a coding agent with explainroo, with sound
+([watch the MP4](https://github.com/vincentsch/explainroo/releases/download/v0.1.0/explainroo-intro.mp4)).
+Its source is in [examples/explainroo-intro](examples/explainroo-intro).*
+
+Point Claude Code, Codex or any coding agent at this repository and ask for a
+video:
+
+> Make a 60 second explainer video about how HTTPS keeps a password secret.
+
+The agent writes two files: a script of what to say and a few lines of
+JavaScript for what to show. explainroo does the rest:
+
+- **Speaks the narration** with [Kokoro](https://huggingface.co/hexgrad/Kokoro-82M), a voice model that runs on your own computer.
+- **Times every word** by listening back with Whisper, so a picture can appear exactly when it is mentioned: `at: 'database'`.
+- **Draws the frames** in headless Chrome in one of five looks, from hand-drawn paper to a dark developer style.
+- **Scores it** with music and sound effects that are generated to fit and duck under the voice.
+- **Gives your agent eyes**: still frames, contact sheets, a layout check and a speech check, because an agent cannot watch a video.
+- **Renders an MP4** with ffmpeg, normalized to -14 LUFS.
+
+Nothing leaves your machine and nothing costs money per video. The speech
+models download once (about 400 MB).
+
+## Examples
+
+| | | |
+|---|---|---|
+| [![explainroo intro](docs/media/intro-poster.jpg)](https://github.com/vincentsch/explainroo/releases/download/v0.1.0/explainroo-intro.mp4) | [![How DNS finds a website](docs/media/dns-poster.jpg)](https://github.com/vincentsch/explainroo/releases/download/v0.1.0/how-dns-works.mp4) | [![git merge vs rebase](docs/media/rebase-poster.jpg)](https://github.com/vincentsch/explainroo/releases/download/v0.1.0/merge-vs-rebase.mp4) |
+| **explainroo in 71 seconds** (paper, 16:9) · [source](examples/explainroo-intro) | **How DNS finds a website** (chalk, 16:9) · [source](examples/how-dns-works) | **git merge vs rebase** (midnight, 9:16 with captions) · [source](examples/merge-vs-rebase) |
+
+## Quick start
+
+You need Node.js 20 or newer, ffmpeg, and Google Chrome or Chromium.
+
+```bash
+git clone https://github.com/vincentsch/explainroo.git
+cd explainroo
+npm install
+node bin/explainroo.js doctor --fetch # checks your setup and downloads the speech models
+```
+
+Then open your coding agent in the `explainroo` folder and ask for a video.
+The agent follows [AGENTS.md](AGENTS.md), and your finished file lands in
+`videos/<name>/out/video.mp4`.
+
+To make one by hand:
+
+```bash
+node bin/explainroo.js init videos/hello --theme paper
+node bin/explainroo.js preview videos/hello # live preview in your browser
+node bin/explainroo.js render videos/hello # writes videos/hello/out/video.mp4
+```
+
+`npm link` puts `explainroo` on your PATH if you prefer the short command.
+
+## What the agent writes
+
+`script.md` holds the narration, one scene per `##` heading:
+
+```markdown
+## sync
+So a picture can appear exactly when it is mentioned. [#code] Write one line,
+[#say] say the word database, and there it is.
+```
+
+`[#code]` marks a moment to animate on. `{SQL|sequel}` shows "SQL" on screen
+but says "sequel", and `[pause 0.5]` adds silence.
+
+`scenes.js` draws each scene. Every element gets a time: seconds, a spoken
+word, or a marker:
+
+```js
+sync(s) {
+ s.text('Word cues', { font: 'display', size: 84, y: 160, at: 0.1 });
+ s.code("s.icon('database', {\n at: 'database',\n});", { x: 640, y: 560, at: '#code' });
+ s.icon('database', { x: 1450, y: 560, size: 260, color: 'purple', at: 'database' });
+ s.burst({ x: 1450, y: 560, at: 'database' });
+},
+```
+
+The scene API covers titles and text (typed, written on, or revealed word by
+word as it is spoken), boxes, arrows that connect elements, 1,850+
+[Lucide](https://lucide.dev) icons, lists, counters, bar, line and pie
+charts, code and terminal windows, images in browser and phone frames,
+underlines and circles for emphasis, a camera, and a raw canvas when you need
+it. See [docs/api.md](docs/api.md).
+
+## Five looks
+
+One script, five styles: set `"theme"` in `video.json`.
+
+![paper, clean, chalk, blueprint and midnight](docs/media/looks.jpg)
+
+Each look brings its own fonts, colors, entrances, transition, sound effects
+and music style. 16:9, 9:16, 1:1 and 4:5 are supported, and vertical videos
+get burned-in captions that follow the voice word by word.
+
+## How the agent checks its work
+
+An agent cannot watch a video, so explainroo turns the video into things it
+can read.
+
+```bash
+explainroo still videos/hello # a PNG of every scene when it is fully built
+explainroo sheet videos/hello --scene intro # one scene over time
+explainroo check videos/hello # layout, timing and pronunciation problems
+explainroo verify videos/hello # the finished MP4: loudness, black frames, narration
+```
+
+![A contact sheet of one scene](docs/media/contact-sheet.jpg)
+
+`check` renders every scene at several moments and reports text that runs off
+the frame, overlaps other text, is too small or low in contrast, elements
+timed after their scene ends, and long stretches where nothing changes. It
+also compares what the voice said with what the script asked for. On the
+first draft of the DNS example it caught Kokoro reading a domain the wrong way:
+
+```
+WARN question: the voice check could not confirm "example.com?". It heard: "So
+before anything loads, your browser has to ask, what is the address of example
+calm?". If a word is mispronounced, write it as {shown|spoken} in script.md.
+```
+
+Writing `{example.com|example dot com}` in the script fixed it.
+
+`verify` transcribes the final mix to confirm the narration is still
+understandable over the music. All three examples score 99 to 100%.
+
+## Commands
+
+| Command | Does |
+|---|---|
+| `init <dir>` | creates a project (`--theme`, `--size`, `--voice`, `--title`) |
+| `voice [project]` | generates narration and word timings, cached per scene |
+| `preview [project]` | live preview in your browser that reloads on save |
+| `still [project] [times…]` | PNG stills at `12.5`, `scene`, `[email protected]` |
+| `sheet [project]` | contact sheet of the video or one scene |
+| `check [project]` | layout, timing and pronunciation problems |
+| `render [project]` | the MP4 (`--draft` for a fast half-size version, `--from`, `--to`) |
+| `verify [project]` | loudness, black frames, silence and narration in the rendered file |
+| `voices`, `say "text"` | list the 28 voices, or hear one |
+| `themes`, `icons <word>` | list the looks, search the icons |
+| `doctor` | checks Node, ffmpeg, Chrome and the speech models |
+
+Every command accepts `--json`.
+
+## Speed and limits
+
+On a laptop with an 8-core Intel i9-11950H, everything on the CPU, the
+67-second DNS example renders at 1080p in about 50 seconds once its voice is
+generated. Generating the voice takes a little less time than the narration
+lasts, and only changed scenes are generated again.
+
+- Narration is English only (Kokoro's English voices, Whisper base.en).
+- Music is synthesized, not sampled. It is meant to sit under a voice, not to
+ carry a video on its own.
+- The first run downloads about 400 MB of speech models from Hugging Face.
+ Set `EXPLAINROO_TTS_DTYPE=q8` for a smaller, slower voice model.
+- explainroo draws with code. It does not generate photos or video footage,
+ though you can place your own images and screenshots.
+
+## Use it as a skill
+
+[skills/explainroo/SKILL.md](skills/explainroo/SKILL.md) lets an agent make
+videos from any folder. For Claude Code, copy `skills/explainroo` into
+`~/.claude/skills/`.
+
+## Credits
+
+explainroo stands on open work:
+[Kokoro-82M](https://huggingface.co/hexgrad/Kokoro-82M) (Apache-2.0) through
+[kokoro-js](https://github.com/hexgrad/kokoro) (Apache-2.0),
+[Whisper](https://github.com/openai/whisper) (MIT) through
+[Transformers.js](https://github.com/huggingface/transformers.js) (Apache-2.0),
+[Rough.js](https://roughjs.com) (MIT), [Lucide](https://lucide.dev) icons
+(ISC), [Playwright](https://playwright.dev) (Apache-2.0), fonts under the SIL
+Open Font License (see [fonts/licenses](fonts/licenses)), and
+[ffmpeg](https://ffmpeg.org), which you install yourself.
+
+## License
+
+MIT
diff --git a/docs/media/contact-sheet.jpg b/docs/media/contact-sheet.jpg
new file mode 100644
index 0000000..1bcf3a4
Binary files /dev/null and b/docs/media/contact-sheet.jpg differ
diff --git a/docs/media/dns-poster.jpg b/docs/media/dns-poster.jpg
new file mode 100644
index 0000000..6f2090b
Binary files /dev/null and b/docs/media/dns-poster.jpg differ
diff --git a/docs/media/intro-poster.jpg b/docs/media/intro-poster.jpg
new file mode 100644
index 0000000..f68b729
Binary files /dev/null and b/docs/media/intro-poster.jpg differ
diff --git a/docs/media/intro.gif b/docs/media/intro.gif
new file mode 100644
index 0000000..4dfb19f
Binary files /dev/null and b/docs/media/intro.gif differ
diff --git a/docs/media/looks.jpg b/docs/media/looks.jpg
new file mode 100644
index 0000000..608f557
Binary files /dev/null and b/docs/media/looks.jpg differ
diff --git a/docs/media/rebase-poster.jpg b/docs/media/rebase-poster.jpg
new file mode 100644
index 0000000..b7d1744
Binary files /dev/null and b/docs/media/rebase-poster.jpg differ
diff --git a/package.json b/package.json
index 934ba52..d6382cb 100644
--- a/package.json
+++ b/package.json
@@ -2,18 +2,51 @@
"name": "explainroo",
"version": "0.1.0",
"description": "Narrated explainer videos made by your coding agent. Pure JavaScript, local voice, no API keys.",
+ "keywords": [
+ "video",
+ "explainer",
+ "text-to-speech",
+ "kokoro",
+ "whisper",
+ "animation",
+ "canvas",
+ "claude-code",
+ "codex",
+ "agents",
+ "motion-graphics",
+ "ffmpeg"
+ ],
+ "homepage": "https://github.com/vincentsch/explainroo#readme",
+ "bugs": {
+ "url": "https://github.com/vincentsch/explainroo/issues"
+ },
"type": "module",
"bin": {
"explainroo": "bin/explainroo.js"
},
+ "files": [
+ "bin/",
+ "src/",
+ "engine/",
+ "fonts/",
+ "templates/",
+ "skills/",
+ "docs/api.md",
+ "AGENTS.md",
+ "CLAUDE.md",
+ "README.md",
+ "LICENSE"
+ ],
"engines": {
- "node": ">=20"
+ "node": ">=20.6"
},
"license": "MIT",
"author": "Vincent Schmalbach",
"repository": "github:vincentsch/explainroo",
"scripts": {
- "test": "node --test test/*.test.js"
+ "test": "node --test test/*.test.js",
+ "build:icons": "node scripts/build-icons.mjs",
+ "build:fonts": "node scripts/fetch-fonts.mjs"
},
"dependencies": {
"@huggingface/transformers": "3.8.1",
diff --git a/skills/explainroo/SKILL.md b/skills/explainroo/SKILL.md
new file mode 100644
index 0000000..df2e3d6
--- /dev/null
+++ b/skills/explainroo/SKILL.md
@@ -0,0 +1,52 @@
+---
+name: explainroo
+description: Make a narrated explainer video (MP4) from code with explainroo, using a local voice model and no API keys. Use when the user asks for an explainer, walkthrough, launch or tutorial video, an animated diagram with voice-over, or a short for YouTube, Reels or TikTok.
+---
+
+# Make an explainer video with explainroo
+
+explainroo turns a narration script and a small JavaScript scene file into a
+finished MP4: a local voice reads the script, every word is timed, frames are
+drawn in headless Chrome, and music and sound effects are generated to fit.
+
+## 1. Find or install explainroo
+
+Use the first that works:
+
+```bash
+command -v explainroo # installed with npm link
+ls "${EXPLAINROO_HOME:-$HOME/.explainroo}/bin/explainroo.js"
+```
+
+If neither exists, install it (needs Node.js 20+, ffmpeg and Chrome or Chromium):
+
+```bash
+git clone https://github.com/vincentsch/explainroo.git "$HOME/.explainroo"
+cd "$HOME/.explainroo" && npm install
+node bin/explainroo.js doctor --fetch
+```
+
+Below, `explainroo` means either the linked command or
+`node "$HOME/.explainroo/bin/explainroo.js"`.
+
+## 2. Read the guide
+
+Read `AGENTS.md` in the explainroo folder before you start, and keep
+`docs/api.md` open while writing scenes. They define the workflow, the quality
+bar and the scene API.
+
+## 3. Make the video
+
+Create the project where the user wants it (default: `./video` in the current
+folder):
+
+```bash
+explainroo init video --theme paper --title "..."
+```
+
+Then follow the workflow from AGENTS.md: write `script.md`, run
+`explainroo voice video`, write `scenes.js`, run `explainroo check video`,
+look at `explainroo still video` and `explainroo sheet video` output, then
+`explainroo render video` and `explainroo verify video`.
+
+Report the path to `video/out/video.mp4`, its length and the verify summary.
diff --git a/src/align.js b/src/align.js
index 249013f..46f70b1 100644
--- a/src/align.js
+++ b/src/align.js
@@ -109,7 +109,11 @@ export function alignWords(words, heard, duration) {
}
const spans = words.map(() => null);
- const add = (wi, s, e) => {
+ const hits = words.map(() => 0);
+ const need = words.map(() => 0);
+ for (const t of tokens) need[t.wi]++;
+ const add = (wi, s, e, n = 1) => {
+ hits[wi] += n;
const cur = spans[wi];
spans[wi] = cur ? { start: Math.min(cur.start, s), end: Math.max(cur.end, e) } : { start: s, end: e };
};
@@ -125,7 +129,7 @@ export function alignWords(words, heard, duration) {
else if (m === 5) {
let s = i - 1;
while (s > 0 && tokens[s - 1].wi === tokens[i - 1].wi) s--;
- add(tokens[i - 1].wi, H[j - 1].start, H[j - 1].end);
+ add(tokens[i - 1].wi, H[j - 1].start, H[j - 1].end, i - s);
matched += i - s;
i = s;
j--;
@@ -135,7 +139,9 @@ export function alignWords(words, heard, duration) {
// Interpolate words Whisper did not confirm, by character length, between
// the nearest confirmed neighbours.
- const out = words.map((w, wi) => ({ start: 0, end: 0, matched: !!spans[wi] }));
+ // A word counts as confirmed only when every part of it was heard, so
+ // "example.com" read as "example comm" is reported.
+ const out = words.map((w, wi) => ({ start: 0, end: 0, matched: !!spans[wi] && hits[wi] >= need[wi] }));
const weight = words.map((w) => Math.max(1, String(w.spoken).length));
let k = 0;
while (k < words.length) {
diff --git a/src/qa.js b/src/qa.js
index 1324a10..8cb9bb2 100644
--- a/src/qa.js
+++ b/src/qa.js
@@ -13,8 +13,9 @@ export async function check(project, { log = () => {}, step = 0.25 } = {}) {
const issues = [];
for (const sc of project.script.scenes) {
const v = voices[sc.id];
- if (v && v.duration && v.matchRate < 0.85) {
- issues.push({ level: 'warn', scene: sc.id, t: null, message: `the voice check heard only ${Math.round(v.matchRate * 100)}% of the words as written. Unconfirmed: ${v.unmatched.slice(0, 8).join(', ')}. Heard: "${v.transcript.slice(0, 160)}". Fix pronunciation with {shown|spoken}.` });
+ const suspicious = v ? v.unmatched.filter((w) => w.replace(/[^\p{L}\p{N}]/gu, '').length > 3) : [];
+ if (v && v.duration && (v.matchRate < 0.9 || suspicious.length)) {
+ issues.push({ level: 'warn', scene: sc.id, t: null, message: `the voice check could not confirm ${suspicious.length ? suspicious.slice(0, 8).map((w) => `"${w}"`).join(', ') : `${Math.round((1 - v.matchRate) * 100)}% of the words`}. It heard: "${v.transcript.slice(0, 200)}". If a word is mispronounced, write it as {shown|spoken} in script.md.` });
}
if (v && v.duration > 40) issues.push({ level: 'hint', scene: sc.id, t: null, message: `the narration runs ${v.duration.toFixed(0)}s; long scenes are easier to follow when split` });
}
diff --git a/src/voice.js b/src/voice.js
index 13644fe..a079768 100644
--- a/src/voice.js
+++ b/src/voice.js
@@ -9,7 +9,7 @@ import { alignWords } from './align.js';
import { loadTTS, transcribeWords, TTS_MODEL, ASR_MODEL, TTS_SAMPLE_RATE, ttsDtype } from './models.js';
import { writeWav, readWav, resample, trimSilence } from './wav.js';
-const PIPELINE = 4;
+const PIPELINE = 5;
function sceneHash(scene, chunks, config) {
return crypto