Skip to content

Drive Google Flow from Claude, Codex or a local control panel, on Mac or Windows — using your Google AI subscription credits instead of the pay-per-use video API. No browser extension.

Voiceover lines timed to the picture, and a tool that hears every word with its timing

GTAI-1fafd12dc58e6
diff --git a/CLAUDE.md b/CLAUDE.md
index 9b66a06..6566da3 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -475,3 +475,12 @@ The preview tool could not read the project while it lived in ~/Desktop; check t
~45 ms, one leading it goes unnoticed to ~125 ms), so every caption state now starts LEAD = 0.12 s early (`lead`
option, -0.5..0.5, MCP only). The .srt shifts with it (first cue 0.22 -> 0.10). Size is now a percentage too
(`size` small|medium|large or 40-250; the panel has a 50-180 % slider; old saved presets map to 80/100/120).
+- VOICEOVER IN THE USER'S OWN VOICE (2026-10-12): Flow's Voices tab holds only the 15 stock voices (the same as
+ Google AI Studio's); the user's own voice comes with the "Me" avatar, and the only way to make it speak is a paid
+ video take with reference_images ["asset:Me"] and the line in the prompt ("He says these exact words and nothing
+ else: ..."), keeping just the sound (Omni 1.1 Flash 360p: 4/5/6/7 credits for 4/6/8/10 s). Flow cannot time speech
+ to on-screen titles, so timing is local: flow_transcribe gives each word's start/end, and flow_assemble's
+ voice_lines places each line (file, from, to, at, max_seconds -> atempo up to 1.25x, per-line loudnorm) at its own
+ moment. The voice track is written as PCM WAV: AAC .m4a from delayed+mixed lines was unreadable ("Cannot calculate
+ dts entry length"), and whisper-cli exits 0 and writes no JSON on unreadable audio, so transcribe now checks for it.
+ Cut lines at the gap between words (midpoint), not word end + padding: padding pulled the next word's start in.
diff --git a/OVERVIEW.md b/OVERVIEW.md
index 03e0d9f..300364b 100644
--- a/OVERVIEW.md
+++ b/OVERVIEW.md
@@ -56,7 +56,7 @@ Mac is the tested platform. Windows support is new and hasn't been tried on a re
---
-## The toolkit: 19 tools
+## The toolkit: 20 tools
### Getting set up
@@ -107,7 +107,8 @@ This is a limit in Flow itself, not something we can program around. The exact j
| **Voiceover Recorder** | Narration for free, at any length. Either Google AI Studio's text-to-speech (the same voices Flow has, and you can tell it *how* to read the line; keep that note short) or a voice already on your computer (macOS voices on a Mac, Windows' own voices on a PC) |
| **Voice List** | Every narrator available to you |
| **Captions** | Puts the spoken words on screen, the way short-form videos do, on wide or vertical videos. Your computer listens to the video with whisper.cpp, a free speech-to-text program, and times every word itself; nothing is uploaded. Five styles: big capitals where the word being said lights up, a coloured block behind the word being said, words appearing as they're said, classic subtitles, and white words on a dark band. Each can use normal letters, ALL CAPITALS or all lowercase. Also writes a subtitle file for YouTube |
-| **Film Cutter** | Joins clips into one film using FFmpeg, a free video toolkit: the clips you made, or any video you pick, in the order you choose. Lays the narration on top, adds a looping music bed, and lets you turn the clips' own sound down so it doesn't drown out the voice. Sizes everything to match your best clip, and can hold the last frame if the voice runs longer than the footage |
+| **Word Finder** | Listens to any video or audio on your computer and writes down every word with the moment it is said. Free, nothing uploaded. Used to check a voice take said the right words, and to cut it into lines |
+| **Film Cutter** | Joins clips into one film using FFmpeg, a free video toolkit: the clips you made, or any video you pick, in the order you choose. Lays the narration on top, adds a looping music bed, and lets you turn the clips' own sound down so it doesn't drown out the voice. Sizes everything to match your best clip, and can hold the last frame if the voice runs longer than the footage. A narration can also be placed line by line, so each sentence lands exactly when its title appears |
---
diff --git a/README.md b/README.md
index 853e6b4..7996653 100644
--- a/README.md
+++ b/README.md
@@ -204,7 +204,8 @@ agree on what is running. That API listens on 127.0.0.1 only and needs a per-run
| `flow_narrate` | Free narration audio, any length: `gemini` (Google AI Studio text-to-speech, with the same voices Flow has, plus a `style` note) or `mac` (a voice installed on this computer, no key needed) |
| `flow_voices` | Narrator voices available, and whether a Google key is set up |
| `flow_captions` | Burn spoken-word captions into any video, landscape or vertical, in one of five styles, at any height and size, in normal, capital or lowercase letters; returns the transcript so a misheard word can be fixed and the call repeated (local whisper.cpp, Chrome and FFmpeg, no credits) |
-| `flow_assemble` | Join clips into one MP4 (a project's clips, or any you list, in order) with optional music and voiceover, and separate volume for the clips' own sound (local FFmpeg, no credits) |
+| `flow_transcribe` | Hear the words in any video or audio on your computer, with each word's start and end time (local whisper.cpp, free) |
+| `flow_assemble` | Join clips into one MP4 (a project's clips, or any you list, in order) with optional music and voiceover, and separate volume for the clips' own sound. A voiceover can also be built line by line (`voice_lines`), each line cut from a take and placed at its own moment, for narration timed to on-screen titles (local FFmpeg, no credits) |
**Continuity between shots:** `chain_previous` (this clip starts on the last frame of the previous
one), `first_frame` + `last_frame` (animate between two stills you chose), `reference_images` (keep a
diff --git a/src/assemble.ts b/src/assemble.ts
index 37b41e4..839910e 100644
--- a/src/assemble.ts
+++ b/src/assemble.ts
@@ -1,5 +1,6 @@
import { execFile } from "node:child_process";
-import { existsSync, mkdirSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
+import { existsSync, mkdirSync, mkdtempSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
import { basename, join } from "node:path";
import { promisify } from "node:util";
@@ -124,6 +125,80 @@ export async function speakLocally(text: string, voice: string, target: string):
return { output: target, duration: Number(stdout.trim()) };
}
+export interface VoiceLine {
+ file: string;
+ from?: number;
+ to?: number;
+ at: number;
+ max_seconds?: number;
+}
+
+// Builds one voiceover track from separate lines, each cut from a take (audio or video, from..to), placed at its own
+// moment in the film, and sped up slightly (at most 1.25x) when it would overrun max_seconds. Flow speaks a whole
+// take at its own pace and cannot time a word to an on-screen title, so the timing is done here instead: 2026-10-12,
+// a narration in the user's own Flow voice had to land each line on the kinetic text it describes.
+export async function voiceTrack(lines: VoiceLine[], out: string): Promise<{ file: string; lines: { at: number; seconds: number; speed: number }[]; warnings: string[] }> {
+ if (!lines.length) throw new Error("No voice lines given.");
+ const work = mkdtempSync(join(tmpdir(), "flow-voice-"));
+ try {
+ // Pass 1: cut each line and trim the silence at both ends, so a line is only sped up when the SPEECH is too long.
+ // On the first real run a cut kept 0.4 s of room tone after "Blender", was pushed to the 1.25x limit and still ran
+ // into the next line.
+ const quiet = (keep: number) => `silenceremove=start_periods=1:start_threshold=-42dB:start_silence=${keep}`;
+ const cuts: { file: string; seconds: number }[] = [];
+ for (const [i, l] of lines.entries()) {
+ if (!existsSync(l.file)) throw new Error(`File not found: ${l.file}`);
+ const from = Math.max(0, l.from ?? 0);
+ const trim = `atrim=start=${from.toFixed(3)}${l.to !== undefined ? `:end=${l.to.toFixed(3)}` : ""}`;
+ const cut = join(work, `line-${i + 1}.wav`);
+ await run(FFMPEG, ["-v", "error", "-y", "-i", l.file, "-vn", "-af", `${trim},asetpts=PTS-STARTPTS,aresample=48000,aformat=channel_layouts=stereo,${quiet(0.04)},areverse,${quiet(0.08)},areverse`, "-c:a", "pcm_s16le", cut]).catch(
+ (err: NodeJS.ErrnoException & { stderr?: string }) => {
+ throw new Error(err.code === "ENOENT" ? `ffmpeg is not installed (${FFMPEG_HINT}).` : `Could not cut voice line ${i + 1}: ${(err.stderr ?? String(err)).slice(-300)}`);
+ },
+ );
+ const { stdout } = await run(FFPROBE, ["-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0", cut]);
+ const seconds = Number(stdout.trim());
+ if (!(seconds > 0.05)) throw new Error(`Voice line ${i + 1} has no speech in it (from ${from}${l.to !== undefined ? ` to ${l.to}` : ""}).`);
+ cuts.push({ file: cut, seconds });
+ }
+ // Pass 2: speed each line to its slot only if it must, level it, and place it.
+ const args: string[] = ["-y"];
+ const filters: string[] = [];
+ const placed: { at: number; seconds: number; speed: number }[] = [];
+ for (const [i, l] of lines.entries()) {
+ const speed = l.max_seconds && cuts[i].seconds > l.max_seconds ? Math.min(1.25, cuts[i].seconds / l.max_seconds) : 1;
+ const seconds = cuts[i].seconds / speed;
+ const delay = Math.round(Math.max(0, l.at) * 1000);
+ args.push("-i", cuts[i].file);
+ // Each line is levelled on its own: separate takes come back at different loudness.
+ filters.push(
+ `[${i}:a]${speed > 1.001 ? `atempo=${speed.toFixed(3)},` : ""}loudnorm=I=-16:TP=-1.5:LRA=11,aresample=48000` +
+ `,afade=t=in:d=0.02,afade=t=out:st=${Math.max(0, seconds - 0.04).toFixed(3)}:d=0.04,adelay=${delay}|${delay}[l${i}]`,
+ );
+ placed.push({ at: l.at, seconds: Number(seconds.toFixed(2)), speed: Number(speed.toFixed(3)) });
+ }
+ const warnings: string[] = [];
+ placed.forEach((p, i) => {
+ const next = placed[i + 1];
+ if (next && p.at + p.seconds > next.at + 0.02) warnings.push(`Line ${i + 1} runs ${(p.at + p.seconds - next.at).toFixed(2)} s into line ${i + 2}.`);
+ if (lines[i].max_seconds && p.seconds > lines[i].max_seconds! + 0.02) warnings.push(`Line ${i + 1} still needs ${p.seconds} s after speeding up as far as sounds natural (1.25x).`);
+ });
+ filters.push(lines.length > 1 ? `${lines.map((_, i) => `[l${i}]`).join("")}amix=inputs=${lines.length}:duration=longest:dropout_transition=0:normalize=0[a]` : "[l0]anull[a]");
+ // Plain PCM: an AAC .m4a written from delayed, mixed lines came out unreadable ("Cannot calculate dts entry length"),
+ // and this file is only a step on the way to the film.
+ args.push("-filter_complex", filters.join(";"), "-map", "[a]", "-c:a", "pcm_s16le", out);
+ try {
+ await run(FFMPEG, args, { maxBuffer: 32 * 1024 * 1024 });
+ } catch (err) {
+ const e = err as NodeJS.ErrnoException & { stderr?: string };
+ throw new Error(e.code === "ENOENT" ? `ffmpeg is not installed (${FFMPEG_HINT}).` : `ffmpeg could not build the voice track: ${(e.stderr ?? String(e)).slice(-400)}`);
+ }
+ return { file: out, lines: placed, warnings };
+ } finally {
+ rmSync(work, { recursive: true, force: true });
+ }
+}
+
// Joins the scene clips into one film, keeping their own sound and laying music / voiceover on top.
export async function assemble(o: AssembleOptions): Promise<{ output: string; clips: string[]; duration: number; held_last_frame: number }> {
// Clips can now come from anywhere, so the project folder the film is saved into may not exist yet.
diff --git a/src/captions.ts b/src/captions.ts
index 624f457..40dfa04 100644
--- a/src/captions.ts
+++ b/src/captions.ts
@@ -165,7 +165,7 @@ function downloadSpeechModel(): Promise<string> {
return fetching;
}
-async function probe(file: string): Promise<{ width: number; height: number; duration: number; audio?: string }> {
+async function probe(file: string, needPicture = true): Promise<{ width: number; height: number; duration: number; audio?: string }> {
if (!existsSync(file)) throw new Error(`No video at ${file}.`);
const { stdout } = await run(
FFPROBE,
@@ -180,6 +180,7 @@ async function probe(file: string): Promise<{ width: number; height: number; dur
format: { duration?: string };
};
const v = data.streams.find((s) => s.codec_type === "video");
+ if (!needPicture && !v) return { width: 0, height: 0, duration: Number(data.format.duration ?? 0), audio: data.streams.find((s) => s.codec_type === "audio")?.codec_name };
if (!v?.width || !v.height) throw new Error(`"${basename(file)}" has no picture to put captions on.`);
// Phone videos are often stored sideways with a rotation flag; ffmpeg turns them upright, so measure them upright.
const rotation = Math.abs(Number(v.side_data_list?.find((d) => d.rotation !== undefined)?.rotation ?? v.tags?.rotate ?? 0)) % 180;
@@ -209,7 +210,7 @@ function wordsFromTokens(json: { transcription: { tokens?: { text: string; offse
}
export async function transcribe(video: string, language = "auto"): Promise<Transcript> {
- const info = await probe(video);
+ const info = await probe(video, false);
if (!info.audio) throw new Error(`"${basename(video)}" has no sound, so there are no words to caption.`);
let model: string;
try {
@@ -235,6 +236,8 @@ export async function transcribe(video: string, language = "auto"): Promise<Tran
if (err.code === "ENOENT") throw new Error(`Captions need whisper.cpp to hear the words. Install it: ${WHISPER_HINT}.`);
throw new Error(`whisper.cpp could not read the sound: ${String(err.stderr ?? err.message).trim().split("\n").at(-1)}`);
});
+ // whisper-cli exits 0 even when it cannot read the audio, and simply writes nothing.
+ if (!existsSync(join(work, "words.json"))) throw new Error(`whisper.cpp could not read the sound in "${basename(video)}".`);
const json = JSON.parse(readFileSync(join(work, "words.json"), "utf8")) as Parameters<typeof wordsFromTokens>[0] & { result?: { language?: string } };
const words = wordsFromTokens(json);
if (!words.length) throw new Error(`No speech was heard in "${basename(video)}".`);
diff --git a/src/core.ts b/src/core.ts
index 181b800..4e95c2c 100644
--- a/src/core.ts
+++ b/src/core.ts
@@ -2,7 +2,7 @@ import { existsSync, mkdirSync, readdirSync, statSync } from "node:fs";
import { homedir } from "node:os";
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
import { z } from "zod";
-import { assemble, localVoices, speakLocally } from "./assemble.js";
+import { assemble, localVoices, speakLocally, voiceTrack } from "./assemble.js";
import { GEMINI_VOICES, geminiKey, saveGeminiKey, speakWithGemini } from "./gemini.js";
import { extractLastFrame } from "./chain.js";
import { burnCaptions, captionedName, captionSetup, previewCaptions, transcribe } from "./captions.js";
@@ -112,10 +112,29 @@ export const shapes = {
.default(1)
.describe("Volume of the clips' own sound, 0-1. Lower it (around 0.2-0.3) so a narration sits clearly on top; 1 keeps it as recorded."),
voiceover: z.string().optional().describe("Absolute path to a voiceover audio file, starts at 0:00."),
+ voice_lines: z
+ .array(
+ z.object({
+ file: z.string().min(1).describe("Take to cut the line from: audio or video (its sound is used)."),
+ from: z.number().min(0).optional().describe("Start of the line within the take, seconds (from flow_transcribe word times)."),
+ to: z.number().min(0).optional().describe("End of the line within the take, seconds."),
+ at: z.number().min(0).describe("Where the line starts in the film, seconds."),
+ max_seconds: z.number().min(0.2).optional().describe("Longest it may last; a longer line is sped up slightly (at most 1.25x)."),
+ }),
+ )
+ .max(60)
+ .optional()
+ .describe(
+ "A timed voiceover built from separate lines, each placed at its own moment in the film - for example lines cut from several Flow takes in your avatar's voice, each landing on the title it describes. Replaces `voiceover`.",
+ ),
output_name: z.string().default("final"),
hold_last_frame: z.boolean().default(true).describe("Freeze the final frame so a longer voiceover is not cut off."),
},
- transcribe: { video: z.string().min(1), language: z.string().default("auto") },
+ transcribe: {
+ video: z.string().min(1).describe("Absolute path of a video or audio file on this computer."),
+ language: z.string().default("auto"),
+ words: z.boolean().default(true).describe("Include every word with its start and end time in seconds."),
+ },
caption_preview: captionFields,
captions: {
...captionFields,
@@ -429,14 +448,25 @@ export class LocalCore implements Core {
return { dir, files };
}
- async assemble({ project, ...rest }: Args<"assemble">) {
- return assemble({ dir: projectDir(project), ...rest });
+ async assemble({ project, voice_lines, ...rest }: Args<"assemble">) {
+ const dir = projectDir(project);
+ if (!voice_lines?.length) return assemble({ dir, ...rest });
+ mkdirSync(dir, { recursive: true });
+ const track = await voiceTrack(voice_lines, join(dir, `${rest.output_name.replace(/[^\w.-]+/g, "_")}-voice.wav`));
+ const film = await assemble({ dir, ...rest, voiceover: track.file });
+ return { ...film, voice: track };
}
// Captions never touch Flow or its queue: whisper.cpp hears the words, a headless Chrome of its own draws them.
- async transcribe({ video, language }: Args<"transcribe">) {
+ async transcribe({ video, language, words }: Args<"transcribe">) {
const t = await transcribe(video, language);
- return { text: t.text, words: t.words.length, language: t.language, model: t.model };
+ return {
+ text: t.text,
+ word_count: t.words.length,
+ language: t.language,
+ model: t.model,
+ ...(words ? { words: t.words.map((w) => ({ text: w.text, start: Number(w.start.toFixed(2)), end: Number(w.end.toFixed(2)) })) } : {}),
+ };
}
async caption_preview(a: Args<"caption_preview">) {
diff --git a/src/index.ts b/src/index.ts
index d1ff537..b1fce36 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -295,6 +295,18 @@ server.registerTool(
(args) => reply(patient("flow_assemble", core.assemble(args))),
);
+server.registerTool(
+ "flow_transcribe",
+ {
+ title: "Hear the words in a video or audio file",
+ description:
+ "Transcribe a video or audio file on this computer with every word's start and end time (whisper.cpp, local and free; the first call downloads a 148 MB speech model once). Use the times to check a take said the right words and to cut lines out of it for flow_assemble's voice_lines.",
+ inputSchema: shapes.transcribe,
+ annotations: { readOnlyHint: true, openWorldHint: false },
+ },
+ (args) => reply(patient("flow_transcribe", core.transcribe(args))),
+);
+
server.registerTool(
"flow_captions",
{