AI dubbing skill for Claude Code, free and MIT licensed: it lets your agent dub your videos into other languages on your own computer. It transcribes the speech, proofreads names and numbers, translates every line to be spoken, says it with a free AI voice (or your own ElevenLabs voice), fits each line to the time the speaker took, and burns in captions that say exactly what the voice says. It also works in Codex, Cursor and OpenClaw.

The free voices run locally: Kokoro for Spanish, French, Italian, Brazilian Portuguese and Hindi, and Piper for German, Dutch, Polish, Russian, Swedish and ten more. With the free voices and local transcription, no audio leaves your computer, and there is no per-minute fee. This post covers the timing problem, how the scripts solve it, and the example in the repo.

npx skills add social-media-skills/ai-dubbing-skill -g -a claude-code -y 

Repo: github.com/social-media-skills/ai-dubbing-skill

The same NASA clip three ways: the English original, then dubbed into Spanish and Brazilian Portuguese with matching captions

From the example in the repo: two clips of retired NASA astronaut Bob Behnken, dubbed with free stock voices (NASA footage, no endorsement implied; the voices are not his).

The hard part of AI dubbing is the clock

For voice-over of talking-head clips, today's text to speech is good enough. The harder problem is time. Spanish, Portuguese, French and German usually run 15 to 30% longer than English, so a word-for-word translation spoken at a natural pace runs past the speaker. Squeeze it to fit and the voice sounds rushed; let it run and the dub drifts away from the picture and from the captions.

So the skill treats a dub like a subtitler treats a subtitle: every line has a slot, and the translation is written to fit it. The agent you already use writes the translation; the scripts measure, fit and mix.

How it works

  1. transcribe.py gives every word a time (free faster-whisper on your computer, mlx-whisper on Apple Silicon, your own Groq or Deepgram key, or the video's own subtitle file).
  2. fix.py --report lists unsure words and near-misses of your names. The agent reads every line and corrects names, numbers and punctuation. Punctuation matters more than usual here: the voice phrases a sentence by its commas and full stops.
  3. captions.py writes one translation template per language, one entry per cue with the original start and end. The agent fills in each line for the ear: the same meaning, the words a native speaker would say out loud, spoken filler dropped, names and numbers kept.
  4. voices.py sample dub.json es makes every free Spanish voice say your first line, so you pick a voice by listening, not by reading a name.
  5. dub.py speaks the lines and fits them (below).
  6. render.py --preview shows a review sheet with TikTok's, Reels' and Shorts' buttons drawn on; render.py renders every shape and language with the dubbed sound and the matching captions.
  7. Optional: post_plan.py gives each language its own accounts, marks the posts as AI-generated, and writes a schedule you can post by hand or through WoopSocial after one clear yes.

Fitting each line to its slot

dub.py first joins cues into spoken lines: cues are joined while the gap is under 0.35 seconds and no sentence ends, up to 8 seconds per line, so the voice speaks a whole sentence in one breath instead of stopping at every caption break. Each line's slot runs until the next line starts.

Then for every line:

  • speak it at normal speed;
  • if it ends well before its slot, slow it a little (never below 0.9x), so a short translation doesn't leave long silences;
  • if it runs over, speak it again faster, up to 1.15x by default, using the voice engine's own speed setting so the pitch stays natural;
  • if it still doesn't fit, don't squeeze it: list it with how much shorter it must be.
talk/es: 1 line(s) don't fit even at 1.15x speed: cues 1,2 (5.7 s available, 6.5 s spoken): shorten by about 10%: "Hola a todos, soy Bob Behnken, y esto es una prueba muchísimo más larga..." Shorten those cues' text in translate.es.json (same meaning, fewer words), run captions.py, then dub.py again. 

The agent rewrites only that line, and only that line is spoken again: every spoken line is cached by voice, text and speed. If a line is too long, dub.py also removes the old soundtrack for that language, so a stale dub can never be rendered by mistake. render.py checks the other direction too: if a translation changed after it was dubbed, that version is skipped until it is dubbed again.

Mixing

The voice lines are placed on a 48 kHz stereo track with numpy and mixed with one of three backgrounds:

  • voiceover (default): the original sound stays, turned down to 18% while the voice speaks, with short fades: the voice-over style used for documentaries and interviews;
  • separate: demucs splits the original into voice and everything else, and the dub goes over the music and sound with the original voice gone (slower; about the clip's own length or longer on a laptop);
  • none: the dub alone.

The result is loudness-normalised and written next to a JSON report with every line's start, slot, spoken length and speed.

The example in the repo

examples/crew-dragon/ has two clips of Bob Behnken talking about designing the SpaceX Crew Dragon, dubbed into Spanish (Kokoro em_alex) and Brazilian Portuguese (pm_alex). The translations were written for speech: "cursing our names" became "no maldigan nuestros nombres", and "kind of" disappeared. Every line fit its slot between 0.9x and 1.0x, so nothing had to be shortened. The folder has the raw transcripts, the fixes, the translation files, the dub reports, review sheets, four rendered videos and a posting plan for four accounts in two languages.

Testing a dub without listening to it

CI runs the full pipeline on macOS, Windows and Ubuntu with a stand-in tone voice, so the timing, fitting, too-long and stale-dub paths are tested everywhere. A second job installs the real free voices, dubs a clip into Spanish with Kokoro and German with Piper, and has Whisper transcribe the dub back: the key words must be heard, every line must fit its slot, the soundtrack must be as long as the video, and the rendered file must carry the dubbed audio.

Your own voice, and the rules around it

With an ElevenLabs key you can dub in any language ElevenLabs speaks, or in your own cloned voice. dub.py counts the characters and stops until you confirm the cost. The skill only ever uses a clone of the user's own voice, or one whose speaker gave written consent, and never presents a stock voice as the speaker's own. Every dubbed post is marked as AI-generated where the platform has a flag for it, and the plan lists the "Altered or synthetic content" answer for YouTube Studio. There is no lip sync: the voice follows the speaker's timing, not their mouth.

Posting each language

TikTok and Instagram take one soundtrack per post, so a dubbed version usually goes to an account in that language. post_plan.py maps each account to a language, checks each file against each platform and schedules at most one post a day per account. Posting is optional; to have your agent do it, open a free account (2 social accounts free, no card) and follow the agent setup guide.

Install it, point your agent at a short clip, and ask for a Spanish version. Repo: github.com/social-media-skills/ai-dubbing-skill. More: the other free skills we publish.

Disclosure: I'm Frank, and I build WoopSocial, the posting API the skill can schedule through. The dubbing is done by the skill on your computer, unless you choose ElevenLabs for the voice.