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.
Captions: the speech model downloads itself the first time it is needed
GTAI-181483813910a
diff --git a/CLAUDE.md b/CLAUDE.mdindex d7e8474..31b51c7 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -444,8 +444,7 @@ The preview tool could not read the project while it lived in ~/Desktop; check t~0.3 s per preview, ~8 s to burn. Transcripts cache in ~/.flow-mcp/captions; the media route only servesOUTPUT_ROOT, uploads and that folder (previews 404'd until it was allowed). Edited text is re-timed by LCS againstthe heard words; a line break forces a new caption. Captions break at commas and sentence ends; `text-wrap:balance`- stops a lone word on line two. The model download (base.en, 148 MB, huggingface ggerganov/whisper.cpp) and- set_key are panel-only - a big download should be the user's click.+ stops a lone word on line two.- TESTING THE PANEL without touching the real one or Flow: a script that sets FLOW_MCP_PORT=8799, FLOW_MCP_HOME andFLOW_MCP_OUTPUT to scratch dirs BEFORE dynamically importing dist/core.js + dist/server.js, overridescore.status/characters/assets (status -> getFlowState -> getBrowser LAUNCHES the Flow Chrome when CDP is down), then@@ -461,3 +460,12 @@ The preview tool could not read the project while it lived in ~/Desktop; check theard. capitals and lowercase drop trailing commas and full stops (? and ! stay), the short-form convention; capitalsin a non-bold font take 1.2x the line width, lowercase in Arial Black 0.85x. Panel labels are "Normal / CAPS /lower" because "CAPITALS" and "lowercase" were cut off at 375 px wide.+- Speech model (2026-10-09, the user's call): it downloads BY ITSELF the first time words are needed - picking a video+ in the Captions tab, or the first flow_captions call - not from a button. ggml-base.en.bin, 148 MB, from+ huggingface ggerganov/whisper.cpp (FLOW_MCP_MODEL_URL for a mirror), into ~/.flow-mcp/models, via a .part file.+ It uses CURL, not fetch: Node's built-in fetch (undici) crashed the whole process with "assert(!this.paused)" when+ the server closed the connection mid-download, and that process is the panel or Claude's connector. caption_setup+ is "ready" once whisper-cli exists; the panel shows "Getting the speech model (148 MB, one time only)" while it+ downloads. Tested with a local stand-in server (HOME pointed at an empty folder): first use, two callers at once+ (one download), a second download in the same panel process, and an unreachable server (clear error, no leftovers).+ The real huggingface download has not been run from this code.diff --git a/OVERVIEW.md b/OVERVIEW.mdindex 54e4829..03e0d9f 100644--- a/OVERVIEW.md+++ b/OVERVIEW.md@@ -124,7 +124,7 @@ Eight tabs, in the order you'd use them:4. **Voice**: record the narration, free. Your saved narrations are listed here, so you can play them back or delete the ones you don't want. This is also where you paste your free Google AI Studio key. It's checked with Google and saved only on your computer, so you never have to put it in a chat5. **Restyle**: change a clip you already have6. **Cut**: join everything into a finished film. Pick the videos you want, in order (ones you made, or any video you upload), then add a narration and music, and turn the clips' own sound down so the voice sits on top-7. **Captions**: put the words on screen. Pick a video and a style, choose where the words sit (bottom, middle, top, or tap the preview to put them exactly where you want), how big they are, normal, capital or lowercase letters, and the highlight colour, and you see the result on a real frame of your video before making it. If the computer misheard a word, fix it in the text and the timing stays right; press Enter wherever you want a new caption to start. The first time, it asks for a free speech model (one click, 148 MB)+7. **Captions**: put the words on screen. Pick a video and a style, choose where the words sit (bottom, middle, top, or tap the preview to put them exactly where you want), how big they are, normal, capital or lowercase letters, and the highlight colour, and you see the result on a real frame of your video before making it. If the computer misheard a word, fix it in the text and the timing stays right; press Enter wherever you want a new caption to start. The first time you pick a video, it downloads a free speech model by itself (148 MB, once)8. **Library**: browse what Flow is holding, pull it back for free, or move things to Flow's TrashProgress and a gallery of your saved work sit alongside. The gallery shows stills or clips on the tabs where you'd use them, and on a wide screen each side scrolls on its own.diff --git a/README.md b/README.mdindex 0d2e051..59aa154 100644--- a/README.md+++ b/README.md@@ -27,7 +27,7 @@ New here? [GETTING-STARTED.md](GETTING-STARTED.md) takes you from nothing to you| **A Google account** | Free. Flow gives every account 50 credits a day; a paid Google AI plan adds more and unlocks 1080p downloads. Developed on a Pro plan || **FFmpeg** *(optional)* | Mac: `brew install ffmpeg` · Windows: `winget install Gyan.FFmpeg`. Needed only to join clips, mix music or record narration || **A Google AI Studio key** *(optional, free)* | Only for the Google narration voices. See below |-| **whisper.cpp** *(optional, free)* | Only for captions: it hears the words, on your computer. Mac: `brew install whisper-cpp` · Windows: `whisper-cli.exe` from [the whisper.cpp releases](https://github.com/ggml-org/whisper.cpp/releases), on your PATH. The speech model it needs (148 MB) is one click in the Captions tab |+| **whisper.cpp** *(optional, free)* | Only for captions: it hears the words, on your computer. Mac: `brew install whisper-cpp` · Windows: `whisper-cli.exe` from [the whisper.cpp releases](https://github.com/ggml-org/whisper.cpp/releases), on your PATH. The speech model it needs (148 MB) downloads by itself the first time you caption a video |A display must stay awake: the Chrome window is really being driven, so the machine cannot beheadless or asleep mid-run.diff --git a/src/captions.ts b/src/captions.tsindex ef6fc7a..c9ccb7a 100644--- a/src/captions.ts+++ b/src/captions.ts@@ -1,11 +1,8 @@import { execFile } from "node:child_process";import { createHash } from "node:crypto";-import { createWriteStream, existsSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";+import { existsSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";import { cpus, homedir, tmpdir } from "node:os";import { basename, extname, join } from "node:path";-import { Readable } from "node:stream";-import { pipeline } from "node:stream/promises";-import type { ReadableStream } from "node:stream/web";import { promisify } from "node:util";import { chromium, type Browser, type Page } from "playwright-core";@@ -24,6 +21,9 @@ const WHISPER = process.env.FLOW_MCP_WHISPER ?? "whisper-cli";// Transcripts and preview stills; the panel is allowed to show pictures from here.export const CACHE_DIR = join(HOME_DIR, "captions");const MODEL_DIR = join(HOME_DIR, "models");+// The model fetched on first use: whisper.cpp's own base.en, 148 MB. FLOW_MCP_MODEL_URL points it at a mirror.+const MODEL_NAME = "ggml-base.en.bin";+const MODEL_URL = process.env.FLOW_MCP_MODEL_URL ?? `https://huggingface.co/ggerganov/whisper.cpp/resolve/main/${MODEL_NAME}`;const BIG = { maxBuffer: 64 * 1024 * 1024 };type RunError = NodeJS.ErrnoException & { stderr?: string };@@ -89,6 +89,8 @@ const MODEL_PREFERENCE = ["ggml-large-v3.bin",];+class NoModel extends Error {}+function findModel(language: string): string {if (process.env.FLOW_MCP_WHISPER_MODEL) return process.env.FLOW_MCP_WHISPER_MODEL;const dirs = [MODEL_DIR, join(homedir(), ".cache", "whisper-models"), join(homedir(), ".cache", "whisper.cpp")];@@ -96,10 +98,7 @@ function findModel(language: string): string {// An English-only model cannot hear another language, so prefer a multilingual one when one is asked for.const wantOther = language !== "auto" && language !== "en";const pick = (wantOther ? found.find((p) => !p.includes(".en.")) : undefined) ?? found[0];- if (!pick)- throw new Error(- `Captions need a speech model to hear the words. Download ggml-small.en.bin (466 MB) or ggml-base.en.bin (148 MB) from huggingface.co/ggerganov/whisper.cpp and put it in ${MODEL_DIR}.`,- );+ if (!pick) throw new NoModel();return pick;}@@ -121,28 +120,35 @@ export async function captionSetup(): Promise<{ ready: boolean; whisper: boolean} catch {model = undefined;}- return { ready: whisper && Boolean(model), whisper, whisper_hint: whisper ? undefined : WHISPER_HINT, model, models_dir: MODEL_DIR };+ // The model is not a precondition: it downloads itself the first time it is needed.+ return { ready: whisper, whisper, whisper_hint: whisper ? undefined : WHISPER_HINT, model, models_dir: MODEL_DIR };}-// The one-click "Get the speech model" in the panel: base.en from whisper.cpp's own model page, 148 MB.-let fetching: Promise<{ model: string; size: number }> | null = null;-export function downloadSpeechModel(): Promise<{ model: string; size: number }> {+// Fetched by itself the first time captions are needed (the user chose this over a button, 2026-10-09). One download+// at a time even if the panel and an assistant ask together; written to .part and renamed, so a cut-off download is+// never mistaken for a model.+let fetching: Promise<string> | null = null;+function downloadSpeechModel(): Promise<string> {fetching ??= (async () => {- const name = "ggml-base.en.bin";- const dest = join(MODEL_DIR, name);- if (existsSync(dest)) return { model: name, size: statSync(dest).size };+ const dest = join(MODEL_DIR, MODEL_NAME);+ if (existsSync(dest)) return dest;mkdirSync(MODEL_DIR, { recursive: true });- const res = await fetch(`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/${name}`);- if (!res.ok || !res.body) throw new Error(`The speech model could not be downloaded (${res.status}). Try again in a moment.`);+ // curl, not fetch: Node's built-in fetch can crash the whole process on an assertion (undici, "assert(!this.paused)")+ // when a server closes the connection mid-stream - seen while testing this, and here that process is the panel or+ // Claude's connector. curl ships with macOS and Windows 10+, follows the redirect to the download host, and can+ // only fail itself.const part = `${dest}.part`;- await pipeline(Readable.fromWeb(res.body as unknown as ReadableStream), createWriteStream(part));+ await run("curl", ["-L", "--fail", "--silent", "--show-error", "--connect-timeout", "20", "--retry", "2", "-o", part, MODEL_URL], BIG).catch((err: RunError) => {+ rmSync(part, { force: true });+ throw new Error(err.code === "ENOENT" ? "curl is not installed" : String(err.stderr || err.message).trim().split("\n").at(-1));+ });const size = statSync(part).size;if (size < 100_000_000) {rmSync(part, { force: true });- throw new Error("The speech model arrived incomplete. Try again.");+ throw new Error("it arrived incomplete");}renameSync(part, dest);- return { model: name, size };+ return dest;})().finally(() => {fetching = null;});@@ -195,7 +201,15 @@ function wordsFromTokens(json: { transcription: { tokens?: { text: string; offseexport async function transcribe(video: string, language = "auto"): Promise<Transcript> {const info = await probe(video);if (!info.audio) throw new Error(`"${basename(video)}" has no sound, so there are no words to caption.`);- const model = findModel(language);+ let model: string;+ try {+ model = findModel(language);+ } catch (err) {+ if (!(err instanceof NoModel)) throw err;+ model = await downloadSpeechModel().catch((e: Error) => {+ throw new Error(`Captions need a speech model, downloaded once (148 MB), and the download failed: ${e.message}. Check the internet connection and try again, or put ${MODEL_NAME} in ${MODEL_DIR} yourself.`);+ });+ }const lang = basename(model).includes(".en.") ? "en" : language;const st = statSync(video);const key = createHash("sha1").update(`${video}|${st.size}|${st.mtimeMs}|${basename(model)}|${lang}`).digest("hex").slice(0, 16);diff --git a/src/core.ts b/src/core.tsindex d7dfd28..a7dc885 100644--- a/src/core.ts+++ b/src/core.ts@@ -5,7 +5,7 @@ import { z } from "zod";import { assemble, localVoices, speakLocally } from "./assemble.js";import { GEMINI_VOICES, geminiKey, saveGeminiKey, speakWithGemini } from "./gemini.js";import { extractLastFrame } from "./chain.js";-import { burnCaptions, captionedName, captionSetup, downloadSpeechModel, previewCaptions, transcribe } from "./captions.js";+import { burnCaptions, captionedName, captionSetup, previewCaptions, transcribe } from "./captions.js";import { characterLook, createCharacter, downloadAsset, trashAsset, editCharacter, getFlowState, listAssets, listCharacters, rememberCharacter, runAgentBatch, runContinue, runEdit, runGeneration } from "./flow.js";import { JobQueue, type Job } from "./queue.js";import { BIN, COMPUTER, IS_MAC, IS_WIN, moveToBin } from "./platform.js";@@ -113,7 +113,6 @@ export const shapes = {project: z.string().optional().describe("Films folder to save into. Default: the video's own folder when it is already in the films folder, otherwise 'Captions'."),},caption_setup: {},- caption_model: {},agent: {project: z.string().min(1).describe("Folder name for the downloaded images."),scenes: z.array(z.string().min(1)).min(1).max(50).describe("One image description per scene, in order."),@@ -254,7 +253,6 @@ export interface Core {caption_preview(a: Args<"caption_preview">): Promise<unknown>;captions(a: Args<"captions">): Promise<unknown>;caption_setup(): Promise<unknown>;- caption_model(): Promise<unknown>;}// Flow's own voices: still offered when giving a character a voice, but narration no longer goes through Flow.@@ -449,11 +447,6 @@ export class LocalCore implements Core {return captionSetup();}- // Panel only, like set_key: a 148 MB download should be the user's own click.- async caption_model() {- return downloadSpeechModel();- }-// Everything already downloaded, newest project first, so the panel can show past work after a restart.async outputs() {if (!existsSync(OUTPUT_ROOT)) return { root: OUTPUT_ROOT, projects: [] };diff --git a/src/index.ts b/src/index.tsindex 0bae12b..d1ff537 100644--- a/src/index.ts+++ b/src/index.ts@@ -300,7 +300,7 @@ server.registerTool({title: "Add captions to a video",description:- "Burn spoken-word captions into a video, in the style short-form apps use, for landscape or vertical footage (local and free: whisper.cpp hears the words on this computer, nothing is uploaded). Styles: bold (big capitals, the spoken word lights up), highlight, reveal, clean, boxed. Saves <name>-captions.mp4 plus an .srt, and returns the transcript: if a word was misheard, call again with the corrected `text` - matching words keep their timing.",+ "Burn spoken-word captions into a video, in the style short-form apps use, for landscape or vertical footage (local and free: whisper.cpp hears the words on this computer, nothing is uploaded). Styles: bold (big capitals, the spoken word lights up), highlight, reveal, clean, boxed. The first call on a computer downloads a 148 MB speech model once. Saves <name>-captions.mp4 plus an .srt, and returns the transcript: if a word was misheard, call again with the corrected `text` - matching words keep their timing.",inputSchema: shapes.captions,annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },},diff --git a/src/remote.ts b/src/remote.tsindex afc3d1e..be2f64c 100644--- a/src/remote.ts+++ b/src/remote.ts@@ -39,7 +39,6 @@ export class RemoteCore implements Core {caption_preview = (a: unknown) => call("caption_preview", a);captions = (a: unknown) => call("captions", a);caption_setup = () => call("caption_setup", {});- caption_model = () => call("caption_model", {});// Long waits are split up so no single HTTP request outlives fetch's header timeout.async wait(a: { job_ids?: string[]; timeout_seconds: number }): Promise<unknown> {diff --git a/studio/index.html b/studio/index.htmlindex c0025cc..bd8ee2c 100644--- a/studio/index.html+++ b/studio/index.html@@ -875,15 +875,13 @@ function showPreview(src, msg, bad) {const e = $("#cap_previewEmpty"); e.hidden = Boolean(src);e.textContent = msg ?? "Pick a video to see your captions on it."; e.style.color = bad ? "var(--bad)" : "";}-// Setup is checked once: whisper.cpp to hear the words, and a speech model it listens with.+// Setup is checked once. whisper.cpp has to be installed by the user; the speech model downloads itself on first use.async function capReady() {if (capSetup?.ready) return true;try { capSetup = await api("caption_setup"); } catch (err) { toast(err.message, true); return false; }const s = capSetup;- $("#cap_setup").innerHTML = s.ready ? "" : `<div class="hint" style="margin:0 0 18px"><b>One-time setup.</b> To hear the words, captions need two free things on ${PLACE.computer}:<br>- ${s.whisper ? "✓ whisper.cpp is installed" : `<b>1.</b> whisper.cpp: ${esc(s.whisper_hint)}`}<br>- ${s.model ? `✓ Speech model: ${esc(s.model)}` : `<b>2.</b> A speech model (148 MB, from whisper.cpp's own page) <div class="rowbtns" style="margin-top:10px"><button class="btn small" id="cap_getmodel" type="button">Get the speech model</button></div>`}- ${s.whisper ? "" : `<div class="rowbtns" style="margin-top:10px"><button class="btn small ghost" id="cap_recheck" type="button">I've installed it — check again</button></div>`}</div>`;+ $("#cap_setup").innerHTML = s.ready ? "" : `<div class="hint" style="margin:0 0 18px"><b>One-time setup.</b> To hear the words, captions need whisper.cpp, a free program, on ${PLACE.computer}: ${esc(s.whisper_hint)}+ <div class="rowbtns" style="margin-top:10px"><button class="btn small ghost" id="cap_recheck" type="button">I've installed it, check again</button></div></div>`;return s.ready;}async function setCapVideo(v) {@@ -894,9 +892,12 @@ async function setCapVideo(v) {async function capListen() {const c = S.captions;if (!c.video || !guard() || !(await capReady())) return;- showPreview(null, "Listening to the video…"); $("#cap_textNote").textContent = "";+ // The very first time, the speech model downloads before anything can be heard.+ showPreview(null, capSetup?.model ? "Listening to the video…" : "Getting the speech model (148 MB, one time only), then listening to the video…");+ $("#cap_textNote").textContent = "";try {const out = await api("transcribe", { video: c.video.path });+ if (capSetup) capSetup.model = out.model;capHeard = out.text; capFor = c.video.path;$("#cap_text").value = c.text || out.text;$("#cap_textNote").textContent = `· ${out.words} words heard`;@@ -931,12 +932,6 @@ document.addEventListener("click", async (e) => {const take = e.target.closest("[data-capthis]");if (take) { const p = take.dataset.capthis; showTab("captions"); return void setCapVideo({ path: p, name: p.split(/[\\/]/).pop() }); }if (e.target.closest("#cap_recheck")) { capSetup = null; if (await capReady()) capListen(); }- const get = e.target.closest("#cap_getmodel");- if (get) {- get.disabled = true; get.textContent = "Downloading 148 MB…";- try { await api("caption_model"); capSetup = null; if (await capReady()) { toast("Speech model ready"); capListen(); } }- catch (err) { toast(err.message, true); get.disabled = false; get.textContent = "Get the speech model"; }- }});$("#cap_go").onclick = async () => {const c = S.captions;