Open source CapCut alternative.
TypeScript
feat(site): persona voice picker with hosted samples
David Lee3988f88dd4c
diff --git a/site/public/cut/voices/achernar.mp3 b/site/public/cut/voices/achernar.mp3new file mode 100644index 00000000..613ffb69Binary files /dev/null and b/site/public/cut/voices/achernar.mp3 differdiff --git a/site/public/cut/voices/achernar.webp b/site/public/cut/voices/achernar.webpnew file mode 100644index 00000000..9e15bb2fBinary files /dev/null and b/site/public/cut/voices/achernar.webp differdiff --git a/site/public/cut/voices/achird.mp3 b/site/public/cut/voices/achird.mp3new file mode 100644index 00000000..ea84d76aBinary files /dev/null and b/site/public/cut/voices/achird.mp3 differdiff --git a/site/public/cut/voices/achird.webp b/site/public/cut/voices/achird.webpnew file mode 100644index 00000000..69cecd09Binary files /dev/null and b/site/public/cut/voices/achird.webp differdiff --git a/site/public/cut/voices/algenib.mp3 b/site/public/cut/voices/algenib.mp3new file mode 100644index 00000000..c4d89863Binary files /dev/null and b/site/public/cut/voices/algenib.mp3 differdiff --git a/site/public/cut/voices/algenib.webp b/site/public/cut/voices/algenib.webpnew file mode 100644index 00000000..b030ced0Binary files /dev/null and b/site/public/cut/voices/algenib.webp differdiff --git a/site/public/cut/voices/algieba.mp3 b/site/public/cut/voices/algieba.mp3new file mode 100644index 00000000..e63490d9Binary files /dev/null and b/site/public/cut/voices/algieba.mp3 differdiff --git a/site/public/cut/voices/algieba.webp b/site/public/cut/voices/algieba.webpnew file mode 100644index 00000000..be453f25Binary files /dev/null and b/site/public/cut/voices/algieba.webp differdiff --git a/site/public/cut/voices/alnilam.mp3 b/site/public/cut/voices/alnilam.mp3new file mode 100644index 00000000..179f679aBinary files /dev/null and b/site/public/cut/voices/alnilam.mp3 differdiff --git a/site/public/cut/voices/alnilam.webp b/site/public/cut/voices/alnilam.webpnew file mode 100644index 00000000..3089efdbBinary files /dev/null and b/site/public/cut/voices/alnilam.webp differdiff --git a/site/public/cut/voices/aoede.mp3 b/site/public/cut/voices/aoede.mp3new file mode 100644index 00000000..205c7319Binary files /dev/null and b/site/public/cut/voices/aoede.mp3 differdiff --git a/site/public/cut/voices/aoede.webp b/site/public/cut/voices/aoede.webpnew file mode 100644index 00000000..d3c55b70Binary files /dev/null and b/site/public/cut/voices/aoede.webp differdiff --git a/site/public/cut/voices/autonoe.mp3 b/site/public/cut/voices/autonoe.mp3new file mode 100644index 00000000..7257a7feBinary files /dev/null and b/site/public/cut/voices/autonoe.mp3 differdiff --git a/site/public/cut/voices/autonoe.webp b/site/public/cut/voices/autonoe.webpnew file mode 100644index 00000000..3e2ad51bBinary files /dev/null and b/site/public/cut/voices/autonoe.webp differdiff --git a/site/public/cut/voices/callirrhoe.mp3 b/site/public/cut/voices/callirrhoe.mp3new file mode 100644index 00000000..c4ef8055Binary files /dev/null and b/site/public/cut/voices/callirrhoe.mp3 differdiff --git a/site/public/cut/voices/callirrhoe.webp b/site/public/cut/voices/callirrhoe.webpnew file mode 100644index 00000000..d4a7581eBinary files /dev/null and b/site/public/cut/voices/callirrhoe.webp differdiff --git a/site/public/cut/voices/charon.mp3 b/site/public/cut/voices/charon.mp3new file mode 100644index 00000000..d4655712Binary files /dev/null and b/site/public/cut/voices/charon.mp3 differdiff --git a/site/public/cut/voices/charon.webp b/site/public/cut/voices/charon.webpnew file mode 100644index 00000000..4fe20f7cBinary files /dev/null and b/site/public/cut/voices/charon.webp differdiff --git a/site/public/cut/voices/despina.mp3 b/site/public/cut/voices/despina.mp3new file mode 100644index 00000000..6c5f08b8Binary files /dev/null and b/site/public/cut/voices/despina.mp3 differdiff --git a/site/public/cut/voices/despina.webp b/site/public/cut/voices/despina.webpnew file mode 100644index 00000000..04be43c7Binary files /dev/null and b/site/public/cut/voices/despina.webp differdiff --git a/site/public/cut/voices/enceladus.mp3 b/site/public/cut/voices/enceladus.mp3new file mode 100644index 00000000..9c5beea0Binary files /dev/null and b/site/public/cut/voices/enceladus.mp3 differdiff --git a/site/public/cut/voices/enceladus.webp b/site/public/cut/voices/enceladus.webpnew file mode 100644index 00000000..536ab6c6Binary files /dev/null and b/site/public/cut/voices/enceladus.webp differdiff --git a/site/public/cut/voices/erinome.mp3 b/site/public/cut/voices/erinome.mp3new file mode 100644index 00000000..8854ef75Binary files /dev/null and b/site/public/cut/voices/erinome.mp3 differdiff --git a/site/public/cut/voices/erinome.webp b/site/public/cut/voices/erinome.webpnew file mode 100644index 00000000..45fd46b0Binary files /dev/null and b/site/public/cut/voices/erinome.webp differdiff --git a/site/public/cut/voices/fenrir.mp3 b/site/public/cut/voices/fenrir.mp3new file mode 100644index 00000000..485b4694Binary files /dev/null and b/site/public/cut/voices/fenrir.mp3 differdiff --git a/site/public/cut/voices/fenrir.webp b/site/public/cut/voices/fenrir.webpnew file mode 100644index 00000000..87228236Binary files /dev/null and b/site/public/cut/voices/fenrir.webp differdiff --git a/site/public/cut/voices/gacrux.mp3 b/site/public/cut/voices/gacrux.mp3new file mode 100644index 00000000..57d1fcd0Binary files /dev/null and b/site/public/cut/voices/gacrux.mp3 differdiff --git a/site/public/cut/voices/gacrux.webp b/site/public/cut/voices/gacrux.webpnew file mode 100644index 00000000..9c143f15Binary files /dev/null and b/site/public/cut/voices/gacrux.webp differdiff --git a/site/public/cut/voices/iapetus.mp3 b/site/public/cut/voices/iapetus.mp3new file mode 100644index 00000000..7bfbc839Binary files /dev/null and b/site/public/cut/voices/iapetus.mp3 differdiff --git a/site/public/cut/voices/iapetus.webp b/site/public/cut/voices/iapetus.webpnew file mode 100644index 00000000..f8c0f4a2Binary files /dev/null and b/site/public/cut/voices/iapetus.webp differdiff --git a/site/public/cut/voices/kore.mp3 b/site/public/cut/voices/kore.mp3new file mode 100644index 00000000..43616118Binary files /dev/null and b/site/public/cut/voices/kore.mp3 differdiff --git a/site/public/cut/voices/kore.webp b/site/public/cut/voices/kore.webpnew file mode 100644index 00000000..2f2c37d5Binary files /dev/null and b/site/public/cut/voices/kore.webp differdiff --git a/site/public/cut/voices/laomedeia.mp3 b/site/public/cut/voices/laomedeia.mp3new file mode 100644index 00000000..7e373958Binary files /dev/null and b/site/public/cut/voices/laomedeia.mp3 differdiff --git a/site/public/cut/voices/laomedeia.webp b/site/public/cut/voices/laomedeia.webpnew file mode 100644index 00000000..ebeed8cfBinary files /dev/null and b/site/public/cut/voices/laomedeia.webp differdiff --git a/site/public/cut/voices/leda.mp3 b/site/public/cut/voices/leda.mp3new file mode 100644index 00000000..d6bdc72cBinary files /dev/null and b/site/public/cut/voices/leda.mp3 differdiff --git a/site/public/cut/voices/leda.webp b/site/public/cut/voices/leda.webpnew file mode 100644index 00000000..f6b4cdc4Binary files /dev/null and b/site/public/cut/voices/leda.webp differdiff --git a/site/public/cut/voices/orus.mp3 b/site/public/cut/voices/orus.mp3new file mode 100644index 00000000..98109b64Binary files /dev/null and b/site/public/cut/voices/orus.mp3 differdiff --git a/site/public/cut/voices/orus.webp b/site/public/cut/voices/orus.webpnew file mode 100644index 00000000..1d59bf9dBinary files /dev/null and b/site/public/cut/voices/orus.webp differdiff --git a/site/public/cut/voices/puck.mp3 b/site/public/cut/voices/puck.mp3new file mode 100644index 00000000..46aedccbBinary files /dev/null and b/site/public/cut/voices/puck.mp3 differdiff --git a/site/public/cut/voices/puck.webp b/site/public/cut/voices/puck.webpnew file mode 100644index 00000000..0867eb3cBinary files /dev/null and b/site/public/cut/voices/puck.webp differdiff --git a/site/public/cut/voices/pulcherrima.mp3 b/site/public/cut/voices/pulcherrima.mp3new file mode 100644index 00000000..2d47f8c6Binary files /dev/null and b/site/public/cut/voices/pulcherrima.mp3 differdiff --git a/site/public/cut/voices/pulcherrima.webp b/site/public/cut/voices/pulcherrima.webpnew file mode 100644index 00000000..9f4116a8Binary files /dev/null and b/site/public/cut/voices/pulcherrima.webp differdiff --git a/site/public/cut/voices/rasalgethi.mp3 b/site/public/cut/voices/rasalgethi.mp3new file mode 100644index 00000000..74c40fabBinary files /dev/null and b/site/public/cut/voices/rasalgethi.mp3 differdiff --git a/site/public/cut/voices/rasalgethi.webp b/site/public/cut/voices/rasalgethi.webpnew file mode 100644index 00000000..9159882aBinary files /dev/null and b/site/public/cut/voices/rasalgethi.webp differdiff --git a/site/public/cut/voices/sadachbia.mp3 b/site/public/cut/voices/sadachbia.mp3new file mode 100644index 00000000..5934649dBinary files /dev/null and b/site/public/cut/voices/sadachbia.mp3 differdiff --git a/site/public/cut/voices/sadachbia.webp b/site/public/cut/voices/sadachbia.webpnew file mode 100644index 00000000..6d7d720aBinary files /dev/null and b/site/public/cut/voices/sadachbia.webp differdiff --git a/site/public/cut/voices/sadaltager.mp3 b/site/public/cut/voices/sadaltager.mp3new file mode 100644index 00000000..a561aa87Binary files /dev/null and b/site/public/cut/voices/sadaltager.mp3 differdiff --git a/site/public/cut/voices/sadaltager.webp b/site/public/cut/voices/sadaltager.webpnew file mode 100644index 00000000..8aa0d484Binary files /dev/null and b/site/public/cut/voices/sadaltager.webp differdiff --git a/site/public/cut/voices/schedar.mp3 b/site/public/cut/voices/schedar.mp3new file mode 100644index 00000000..57278d7bBinary files /dev/null and b/site/public/cut/voices/schedar.mp3 differdiff --git a/site/public/cut/voices/schedar.webp b/site/public/cut/voices/schedar.webpnew file mode 100644index 00000000..3cb4990eBinary files /dev/null and b/site/public/cut/voices/schedar.webp differdiff --git a/site/public/cut/voices/sulafat.mp3 b/site/public/cut/voices/sulafat.mp3new file mode 100644index 00000000..2f11d470Binary files /dev/null and b/site/public/cut/voices/sulafat.mp3 differdiff --git a/site/public/cut/voices/sulafat.webp b/site/public/cut/voices/sulafat.webpnew file mode 100644index 00000000..80ea3337Binary files /dev/null and b/site/public/cut/voices/sulafat.webp differdiff --git a/site/public/cut/voices/umbriel.mp3 b/site/public/cut/voices/umbriel.mp3new file mode 100644index 00000000..516351d9Binary files /dev/null and b/site/public/cut/voices/umbriel.mp3 differdiff --git a/site/public/cut/voices/umbriel.webp b/site/public/cut/voices/umbriel.webpnew file mode 100644index 00000000..c36a25dcBinary files /dev/null and b/site/public/cut/voices/umbriel.webp differdiff --git a/site/public/cut/voices/vindemiatrix.mp3 b/site/public/cut/voices/vindemiatrix.mp3new file mode 100644index 00000000..f36ec3d0Binary files /dev/null and b/site/public/cut/voices/vindemiatrix.mp3 differdiff --git a/site/public/cut/voices/vindemiatrix.webp b/site/public/cut/voices/vindemiatrix.webpnew file mode 100644index 00000000..74c90d63Binary files /dev/null and b/site/public/cut/voices/vindemiatrix.webp differdiff --git a/site/public/cut/voices/zephyr.mp3 b/site/public/cut/voices/zephyr.mp3new file mode 100644index 00000000..5a1fff1bBinary files /dev/null and b/site/public/cut/voices/zephyr.mp3 differdiff --git a/site/public/cut/voices/zephyr.webp b/site/public/cut/voices/zephyr.webpnew file mode 100644index 00000000..6b6bd144Binary files /dev/null and b/site/public/cut/voices/zephyr.webp differdiff --git a/site/public/cut/voices/zubenelgenubi.mp3 b/site/public/cut/voices/zubenelgenubi.mp3new file mode 100644index 00000000..b7bce266Binary files /dev/null and b/site/public/cut/voices/zubenelgenubi.mp3 differdiff --git a/site/public/cut/voices/zubenelgenubi.webp b/site/public/cut/voices/zubenelgenubi.webpnew file mode 100644index 00000000..86bc7ef5Binary files /dev/null and b/site/public/cut/voices/zubenelgenubi.webp differdiff --git a/site/scripts/generate-voices.ts b/site/scripts/generate-voices.tsnew file mode 100644index 00000000..2ba5b766--- /dev/null+++ b/site/scripts/generate-voices.ts@@ -0,0 +1,233 @@+// Renders the hosted voice-persona assets the Cut voice picker shows: one+// square portrait and one spoken sample clip per prebuilt speech voice. Both are+// produced with the same Vertex models the app uses — gemini-2.5-flash-image for+// the portrait, the Gemini TTS model for the sample — and written into+// public/cut/voices as <id>.webp and <id>.mp3 (lowercased ids, matching+// voicePortraitUrl / voiceSampleUrl). Idempotent: a voice whose portrait and+// sample already exist is skipped, so re-running fills gaps or picks up voices+// added to the catalog only.+//+// cd site && ./node_modules/.bin/bun scripts/generate-voices.ts+//+// Needs GOOGLE_APPLICATION_CREDENTIALS_JSON (bun auto-loads site/.env) and+// ffmpeg on PATH (raw PCM -> MP3). Force a re-render with `--force`.++import { spawn } from "node:child_process";+import { existsSync } from "node:fs";+import { mkdir, writeFile } from "node:fs/promises";+import path from "node:path";+import { GoogleGenAI, Modality } from "@google/genai";+import { JWT } from "google-auth-library";+import sharp from "sharp";++import { geminiModels, geminiTtsModels } from "../src/lib/inference/gemini-models";+import { SPEECH_VOICES, VOICE_SAMPLE_TEXT } from "../src/cut/lib/voices";++const IMAGE_MODEL = geminiModels.flashImage;+const TTS_MODEL = geminiTtsModels.flash;+const OUT_DIR = path.join(import.meta.dirname, "..", "public", "cut", "voices");+const PORTRAIT_EDGE = 512;+const CONCURRENCY = 3;+const FORCE = process.argv.includes("--force");++// Gemini TTS returns raw little-endian 16-bit mono PCM (audio/L16), 24 kHz default.+const PCM_SAMPLE_RATE = 24_000;++/** Per-voice portrait subject. Kept beside — not inside — the shared catalog so+ * the art direction stays out of the client bundle. One diverse persona per+ * voice, matched loosely to its style word; the wrapper adds the framing. */+const PORTRAIT_SUBJECT: Record<string, string> = {+ Zephyr: "a bright, cheerful woman in her late 20s with short wavy auburn hair and light freckles",+ Puck: "an upbeat young man in his mid-20s with tousled dark hair and a playful half-smile",+ Charon: "a composed man in his 40s with a trimmed salt-and-pepper beard and glasses, thoughtful",+ Kore: "a confident woman in her 30s with sleek black hair pulled back and a calm, resolute look",+ Fenrir: "an energetic young woman in her 20s with curly hair and animated, wide bright eyes",+ Leda: "a youthful woman in her early 20s with an open, fresh face and shoulder-length light-brown hair",+ Orus: "a steady man in his late 30s with a strong jaw and short cropped hair, quietly assertive",+ Aoede: "a relaxed woman in her late 20s with loose beachy waves and a soft, easy smile",+ Callirrhoe: "a laid-back woman in her 30s with warm brown skin and natural curls, gentle and unhurried",+ Autonoe: "a radiant woman in her late 20s with a wide bright smile and neat dark hair",+ Enceladus: "a soft-spoken man in his 30s with fair skin, light stubble, and a gentle expression",+ Iapetus: "a clear-eyed man in his early 30s with clean-cut short hair and an attentive look",+ Umbriel: "an easy-going man in his 40s with a relaxed smile and slightly greying temples",+ Algieba: "a poised man in his 30s with dark skin and a neat short fade, smooth and self-assured",+ Despina: "a poised woman in her 30s with straight dark hair and a serene, elegant expression",+ Erinome: "a crisp, professional woman in her late 20s with a tidy bob and bright attentive eyes",+ Algenib: "a rugged man in his 50s with a weathered face, grey stubble, and deep-set eyes",+ Rasalgethi: "a knowledgeable man in his 40s with glasses and neat dark hair, warm and precise",+ Laomedeia: "an upbeat woman in her mid-20s with a lively grin and a bouncy ponytail",+ Achernar: "a gentle woman in her 30s with soft features, pale skin, and a quiet, kind expression",+ Alnilam: "a firm, dependable man in his 40s with short greying hair and a level gaze",+ Schedar: "a calm, even-tempered man in his 40s with a warm medium skin tone and neat short hair",+ Gacrux: "a mature woman in her 50s with elegant silver hair and a warm, wise smile",+ Pulcherrima: "a bold woman in her early 30s with a confident chin-up pose and sleek hair",+ Achird: "a friendly man in his 30s with a warm, approachable smile and a light beard",+ Zubenelgenubi: "a casual young man in his late 20s with messy hair and a relaxed, offhand smile",+ Vindemiatrix: "a gentle woman in her 50s with kind eyes, glasses, and soft silver-grey hair",+ Sadachbia: "a lively young woman in her mid-20s with an animated smile and warm energy",+ Sadaltager: "a knowledgeable man in his 40s with a scholarly look, glasses, and neat dark hair",+ Sulafat: "a warm woman in her late 30s with golden-brown skin, soft curls, and an inviting smile",+};++// Muted, editorial studio backdrop tones — assigned per voice by catalog+// position so each persona gets a distinct wall color and re-runs stay stable.+const BACKDROPS = [+ "soft terracotta",+ "muted sage green",+ "dusty slate blue",+ "warm blush pink",+ "muted mustard ochre",+ "deep teal",+ "soft lavender grey",+ "warm caramel",+ "muted plum",+ "soft coral",+ "cool olive green",+ "warm sand beige",+ "dusty rose",+ "steel blue grey",+ "soft amber",+ "muted forest green",+];+const backdropFor = (id: string) =>+ BACKDROPS[Math.max(0, SPEECH_VOICES.findIndex((v) => v.id === id)) % BACKDROPS.length];++const portraitPrompt = (subject: string, backdrop: string) =>+ `Editorial studio headshot portrait of ${subject}. Soft diffused key light, plain ${backdrop} studio backdrop softly lit and slightly out of focus, shallow depth of field, sharp focus on the eyes, natural skin texture, relaxed friendly expression, looking toward the camera, shoulders-up and centered in a square frame. Photorealistic. No text, no watermark, no logo, no props, no border.`;++function makeClient(): { client: GoogleGenAI; project: string } {+ const raw = process.env.GOOGLE_APPLICATION_CREDENTIALS_JSON?.trim();+ if (!raw) throw new Error("GOOGLE_APPLICATION_CREDENTIALS_JSON is not set (run from site/ so bun loads .env).");+ const creds = JSON.parse(raw) as {+ project_id?: string;+ client_email?: string;+ private_key?: string;+ private_key_id?: string;+ };+ if (!creds.project_id || !creds.client_email || !creds.private_key) {+ throw new Error("Service account JSON is missing project_id/client_email/private_key.");+ }+ const authClient = new JWT({+ email: creds.client_email,+ key: creds.private_key,+ keyId: creds.private_key_id,+ scopes: ["https://www.googleapis.com/auth/cloud-platform"],+ });+ const client = new GoogleGenAI({+ vertexai: true,+ location: "global",+ project: creds.project_id,+ googleAuthOptions: { authClient },+ });+ return { client, project: creds.project_id };+}++const portraitPath = (id: string) => path.join(OUT_DIR, `${id.toLowerCase()}.webp`);+const samplePath = (id: string) => path.join(OUT_DIR, `${id.toLowerCase()}.mp3`);+const hasAssets = (id: string) => existsSync(portraitPath(id)) && existsSync(samplePath(id));++/** One portrait: generate a square image, crop-cover to the tile size, write WebP. */+async function renderPortrait(client: GoogleGenAI, id: string): Promise<void> {+ const subject = PORTRAIT_SUBJECT[id] ?? "a friendly person with a calm, approachable expression";+ const contents = [{ role: "user", parts: [{ text: portraitPrompt(subject, backdropFor(id)) }] }];+ let response;+ try {+ response = await client.models.generateContent({+ model: IMAGE_MODEL,+ contents,+ config: {+ responseModalities: [Modality.IMAGE, Modality.TEXT],+ imageConfig: { aspectRatio: "1:1" },+ } as Record<string, unknown>,+ });+ } catch {+ response = await client.models.generateContent({+ model: IMAGE_MODEL,+ contents,+ config: { responseModalities: [Modality.IMAGE, Modality.TEXT] },+ });+ }+ const parts = response.candidates?.[0]?.content?.parts ?? [];+ const data = parts.find((p) => p.inlineData?.data)?.inlineData?.data;+ if (!data) throw new Error("no image in response");+ const webp = await sharp(Buffer.from(data, "base64"))+ .resize(PORTRAIT_EDGE, PORTRAIT_EDGE, { fit: "cover", position: "attention" })+ .webp({ quality: 82, smartSubsample: true })+ .toBuffer();+ await writeFile(portraitPath(id), webp);+}++/** One sample: speak VOICE_SAMPLE_TEXT in this voice, then transcode the raw PCM to MP3. */+async function renderSample(client: GoogleGenAI, id: string): Promise<void> {+ let pcm: Buffer | null = null;+ let rate = PCM_SAMPLE_RATE;+ // The TTS model intermittently returns an empty candidate (no audio); a resend+ // usually clears it, so retry a few times before giving up.+ for (let attempt = 1; attempt <= 4 && !pcm; attempt += 1) {+ const response = await client.models.generateContent({+ model: TTS_MODEL,+ contents: [{ role: "user", parts: [{ text: VOICE_SAMPLE_TEXT }] }],+ config: {+ responseModalities: [Modality.AUDIO],+ speechConfig: { voiceConfig: { prebuiltVoiceConfig: { voiceName: id } } },+ },+ });+ const inline = response.candidates?.[0]?.content?.parts?.find((p) => p.inlineData?.data)?.inlineData;+ if (inline?.data) {+ pcm = Buffer.from(inline.data, "base64");+ rate = Number(inline.mimeType?.match(/rate=(\d+)/)?.[1]) || PCM_SAMPLE_RATE;+ }+ }+ if (!pcm) throw new Error("no audio after retries");+ await pcmToMp3(pcm, rate, samplePath(id));+}++/** Pipe raw 16-bit mono PCM through ffmpeg to a VBR MP3. */+function pcmToMp3(pcm: Buffer, rate: number, out: string): Promise<void> {+ return new Promise((resolve, reject) => {+ const ff = spawn("ffmpeg", [+ "-y", "-hide_banner", "-loglevel", "error",+ "-f", "s16le", "-ar", String(rate), "-ac", "1", "-i", "pipe:0",+ "-codec:a", "libmp3lame", "-q:a", "4", out,+ ]);+ let stderr = "";+ ff.stderr.on("data", (d) => (stderr += d));+ ff.on("error", reject);+ ff.on("close", (code) =>+ code === 0 ? resolve() : reject(new Error(`ffmpeg exited ${code}: ${stderr.trim()}`))+ );+ ff.stdin.write(pcm);+ ff.stdin.end();+ });+}++async function main() {+ const { client, project } = makeClient();+ await mkdir(OUT_DIR, { recursive: true });++ const todo = FORCE ? [...SPEECH_VOICES] : SPEECH_VOICES.filter((v) => !hasAssets(v.id));+ console.log(+ `image=${IMAGE_MODEL} tts=${TTS_MODEL} project=${project} generating=${todo.length}/${SPEECH_VOICES.length}`+ );++ let failed = 0;+ const queue = [...todo];+ const worker = async () => {+ for (let v = queue.shift(); v; v = queue.shift()) {+ try {+ if (FORCE || !existsSync(portraitPath(v.id))) await renderPortrait(client, v.id);+ if (FORCE || !existsSync(samplePath(v.id))) await renderSample(client, v.id);+ console.log(`✓ ${v.id} · ${v.style}`);+ } catch (e) {+ failed++;+ console.error(`✗ ${v.id}: ${e instanceof Error ? e.message : e}`);+ }+ }+ };+ await Promise.all(Array.from({ length: CONCURRENCY }, worker));++ console.log(`done: ${todo.length - failed}/${todo.length} voices${failed ? `, ${failed} failed` : ""}`);+ if (failed) process.exitCode = 1;+}++await main();diff --git a/site/src/cut/components/AudioPanel.tsx b/site/src/cut/components/AudioPanel.tsxindex c3e6a79b..d37f3917 100644--- a/site/src/cut/components/AudioPanel.tsx+++ b/site/src/cut/components/AudioPanel.tsx@@ -160,7 +160,10 @@ function VoiceGenerator({ projectId }: { projectId: string }) {return (<div className="voice-generator flex flex-col gap-3.5">{/* Voice settings first — pick how the voice sounds, then script it. */}- <VoicePicker onError={(e) => fail(e, "Could not play the sample.")} />+ <VoicePicker+ direction={direction}+ onError={(e) => fail(e, "Could not play the sample.")}+ /><div className="flex flex-col gap-1.5"><div className="flex items-center gap-1">@@ -477,7 +480,7 @@ function ProjectAudio({variant="destructive"onClick={() => useEditor.getState().removeAsset(a.id)}>- <Trash2 /> Remove from project+ <Trash2 /> Delete</DropdownMenuItem>}/>diff --git a/site/src/cut/components/VoicePicker.tsx b/site/src/cut/components/VoicePicker.tsxindex 62816b6a..c62761f3 100644--- a/site/src/cut/components/VoicePicker.tsx+++ b/site/src/cut/components/VoicePicker.tsx@@ -1,20 +1,25 @@"use client";import { useEffect, useRef, useState, useSyncExternalStore } from "react";-import { Captions, ChevronDown, Languages, Loader2, Pause, Play } from "lucide-react";+import { Captions, ChevronDown, Loader2, Pause, Play } from "lucide-react";import { Button } from "@/components/ui/button";+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuTrigger,+} from "@/components/ui/dropdown-menu";import { SectionTitle } from "@/cut/components/SectionTitle";import { creditsUrl, signInUrl, useSignedIn } from "@/cut/lib/generate";import { useEditor, type EditorState } from "@/cut/lib/store";+import { NoCreditsError, renderSpeechClip, resolveLanguage, resolveVoice } from "@/cut/lib/tts";import {- NoCreditsError,- resolveLanguage,- resolveVoice,- speechSampleUrl,- SPEECH_LANGUAGES,SPEECH_VOICES,-} from "@/cut/lib/tts";-import { generateSubtitlesReadout, previewSubtitlesReadout } from "@/cut/lib/voiceover";+ VOICE_SAMPLE_TEXT,+ voicePortraitUrl,+ voiceSampleUrl,+} from "@/cut/lib/voices";+import { generateSubtitlesReadout } from "@/cut/lib/voiceover";+import { cn } from "@/lib/utils";// Shared speech preferences (speaker voice, spoken language) for every surface// that generates audio (Audio tab, Subtitles tab, clip settings). Module-level@@ -65,132 +70,206 @@ export function useSpeechLanguage(): string {);}+/** A small round persona portrait, used in the trigger and each grid tile. */+function VoiceAvatar({ id, style, className }: { id: string; style: string; className?: string }) {+ return (+ // eslint-disable-next-line @next/next/no-img-element -- bundled static portrait on a client-only page+ <img+ src={voicePortraitUrl(id)}+ alt={`${id}, a ${style.toLowerCase()} voice`}+ loading="lazy"+ className={cn("object-cover", className)}+ />+ );+}++// Women first, then men (grouped, no headers); alphabetical by name within each.+const ORDERED_VOICES = [...SPEECH_VOICES].sort((a, b) =>+ a.gender === b.gender ? a.name.localeCompare(b.name) : a.gender === "f" ? -1 : 1+);+/**- * Speaker-voice row: a play button that samples the voice plus the voice- * select. Drop it into any surface that generates speech — they all share one- * persisted voice choice. Pass `sample` to make the play button preview real- * content (e.g. the subtitle readout) instead of the canned voice sample.+ * Speaker-voice picker: a play button plus a compact dropdown showing the chosen+ * persona. Opening the dropdown reveals a grid of persona portraits — hovering a+ * tile plays that voice's pre-generated sample clip (a static hosted file, so it+ * works signed out and costs nothing), clicking selects it and closes.+ *+ * The play button samples the selected voice reading a fixed line. With no+ * `direction` it just plays the hosted clip; once a delivery `direction` is+ * given ("like a hype announcer") it can't be pre-baked, so it synthesizes a+ * fresh sample through the hosted model instead (signed in, uses credits).+ *+ * Drop it into any surface that generates speech — they all share one persisted+ * voice choice.*/export function VoicePicker({- onError,title = "Speaker voice",- sample: sampleOverride,+ direction,+ onError,}: {- onError?: (e: unknown) => void;title?: string;- sample?: { run: () => Promise<string>; title?: string; disabled?: boolean };+ /** Free-text delivery direction; when non-empty the play button previews via+ * the model instead of the pre-built clip. */+ direction?: string;+ /** Surfaced when a live (direction) preview fails — e.g. no credits. */+ onError?: (e: unknown) => void;}) {const voice = useSpeakerVoice();const language = useSpeechLanguage();- const signedOut = useSignedIn() === false;+ const selected = SPEECH_VOICES.find((v) => v.id === voice) ?? SPEECH_VOICES[0];+ const [open, setOpen] = useState(false);const [sampling, setSampling] = useState<null | "loading" | "playing">(null);- const sampler = useRef<HTMLAudioElement | null>(null);+ const audio = useRef<HTMLAudioElement | null>(null);const sampleSeq = useRef(0);- useEffect(- () => () => {- sampler.current?.pause();- },- []- );+ // Stop any preview when the picker unmounts (menu close is handled in onOpenChange).+ useEffect(() => () => audio.current?.pause(), []);++ const preview = (id: string) => {+ const el = (audio.current ??= new Audio());+ el.src = voiceSampleUrl(id);+ el.currentTime = 0;+ // Autoplay refusal or a missing file just leaves it silent.+ void el.play().catch(() => {});+ };++ const leave = (id: string) => {+ // Only silence the element if this tile owned the current clip.+ if (audio.current?.src.endsWith(`${id.toLowerCase()}.mp3`)) audio.current.pause();+ };- const play = () => {- const el = (sampler.current ??= new Audio());+ // Play button: sample the selected voice. A delivery direction can't be+ // pre-baked, so it routes through the model; otherwise the hosted clip plays.+ const sample = async () => {+ const el = (audio.current ??= new Audio());if (sampling) {- sampleSeq.current++;el.pause();setSampling(null);+ sampleSeq.current++;return;}+ const dir = direction?.trim();const seq = ++sampleSeq.current;setSampling("loading");- (sampleOverride?.run ?? (() => speechSampleUrl(voice, language)))()- .then((url) => {- if (seq !== sampleSeq.current) return;- el.src = url;- el.onended = () => setSampling(null);- el.onerror = () => setSampling(null);- setSampling("playing");- return el.play();- })- .catch((e: unknown) => {- if (seq !== sampleSeq.current) return;- setSampling(null);- onError?.(e);- });+ try {+ let url: string;+ if (dir) {+ const { blob } = await renderSpeechClip([{ text: VOICE_SAMPLE_TEXT, at: 0 }], {+ voice: selected.id,+ direction: dir,+ language,+ });+ url = URL.createObjectURL(blob);+ } else {+ url = voiceSampleUrl(selected.id);+ }+ if (seq !== sampleSeq.current) return;+ el.src = url;+ el.onended = () => setSampling(null);+ el.onerror = () => setSampling(null);+ setSampling("playing");+ await el.play();+ } catch (e) {+ if (seq !== sampleSeq.current) return;+ setSampling(null);+ onError?.(e);+ }};- const sampleTitle = sampleOverride?.title ?? "Hear this voice";-return (<div className="voice-picker flex flex-col gap-1.5"><SectionTitle>{title}</SectionTitle>- <div className="flex items-center gap-2">+ <div className="flex items-stretch gap-2"><buttontype="button"- className="voice-sample grid size-8 shrink-0 place-items-center rounded-full bg-muted text-foreground transition-colors hover:bg-muted-foreground/20 disabled:opacity-40"- title={sampleTitle}- aria-label={sampleTitle}- disabled={signedOut || sampleOverride?.disabled === true}- onClick={play}+ className="voice-sample grid aspect-square shrink-0 place-items-center rounded-lg border border-input text-foreground transition-colors hover:bg-muted"+ title={direction?.trim() ? "Hear this voice with your direction" : "Hear this voice"}+ aria-label="Play a sample of the selected voice"+ onClick={() => void sample()}>{sampling === "loading" ? (- <Loader2 className="size-3.5 animate-spin" />+ <Loader2 className="size-4 animate-spin" />) : sampling === "playing" ? (- <Pause className="size-3.5" />+ <Pause className="size-4" />) : (- <Play className="size-3.5" />+ <Play className="size-4" />)}</button>- <div className="relative min-w-0 flex-1">- <select- className="voice-select w-full appearance-none truncate rounded-lg border border-input bg-transparent py-2 pr-8 pl-2.5 text-[12.5px] outline-none focus:border-ring"- value={voice}- onChange={(e) => voicePref.write(e.target.value)}- >- {SPEECH_VOICES.map((v) => (- <option key={v.id} value={v.id}>- {v.id} · {v.style}- </option>+ <DropdownMenu+ open={open}+ onOpenChange={(next) => {+ setOpen(next);+ if (!next && !sampling) audio.current?.pause();+ }}+ >+ <DropdownMenuTrigger className="voice-select flex min-w-0 flex-1 items-center gap-2.5 overflow-hidden rounded-lg border border-input bg-transparent pr-2.5 text-left outline-none transition-colors focus:border-ring">+ <VoiceAvatar+ id={selected.id}+ style={selected.style}+ className="size-8 shrink-0 bg-muted"+ />+ <span className="min-w-0 flex-1 truncate text-[12.5px]">+ <span className="font-semibold">{selected.name}</span>{" "}+ <span className="text-muted-foreground">· {selected.style}</span>+ </span>+ <ChevronDown className="size-4 shrink-0 text-muted-foreground" />+ </DropdownMenuTrigger>+ <DropdownMenuContent className="max-h-96 w-96 max-w-[calc(100vw-2rem)] p-2.5">+ {/* Women and men each get their own grid so the men always start on a+ fresh row (grouped, no section headers). */}+ <div className="flex flex-col gap-3">+ {[+ ORDERED_VOICES.filter((v) => v.gender === "f"),+ ORDERED_VOICES.filter((v) => v.gender === "m"),+ ].map((group, i) => (+ <div key={i} className="voice-grid grid grid-cols-5 gap-2">+ {group.map((v) => {+ const isSelected = v.id === voice;+ return (+ <button+ key={v.id}+ type="button"+ className="voice-tile group flex flex-col gap-1 text-left"+ aria-pressed={isSelected}+ title={`${v.name} · ${v.style}`}+ onClick={() => {+ voicePref.write(v.id);+ setOpen(false);+ }}+ onMouseEnter={() => preview(v.id)}+ onMouseLeave={() => leave(v.id)}+ onFocus={() => preview(v.id)}+ onBlur={() => leave(v.id)}+ >+ <span+ className={cn(+ "block aspect-square overflow-hidden rounded-lg border bg-muted ring-offset-2 ring-offset-popover transition",+ isSelected+ ? "border-transparent ring-2 ring-[#0a84ff]"+ : "border-input group-hover:border-transparent group-hover:ring-2 group-hover:ring-[#0a84ff]/40"+ )}+ >+ <VoiceAvatar id={v.id} style={v.style} className="size-full" />+ </span>+ <span className="min-w-0 px-0.5 leading-tight">+ <span className="block truncate text-[11px] font-semibold">{v.name}</span>+ <span className="block truncate text-[10px] text-muted-foreground">+ {v.style}+ </span>+ </span>+ </button>+ );+ })}+ </div>))}- </select>- <ChevronDown className="pointer-events-none absolute top-1/2 right-2.5 size-4 -translate-y-1/2 text-muted-foreground" />- </div>+ </div>+ </DropdownMenuContent>+ </DropdownMenu></div>- <label- className="voice-language-field relative inline-flex max-w-full items-center gap-2 self-end rounded-full border border-input py-1 pr-2.5 pl-3 text-muted-foreground transition-colors focus-within:border-ring"- title="Spoken language"- >- <Languages className="size-3.5 shrink-0" />- <span className="relative inline-flex min-w-0 items-center">- <select- className="voice-language max-w-full appearance-none truncate bg-transparent pr-5 text-[12.5px] text-foreground outline-none"- value={language}- onChange={(e) => languagePref.write(e.target.value)}- >- {SPEECH_LANGUAGES.map((l) => (- <option key={l.id} value={l.id}>- {l.label}- </option>- ))}- </select>- <ChevronDown className="pointer-events-none absolute top-1/2 right-0 size-3.5 -translate-y-1/2" />- </span>- </label>- {language !== "auto" && (- <p className="voice-language-hint text-[11px] leading-relaxed text-muted-foreground">- {`The voice reads your script as written — write it in ${languageLabel(language)} for ${languageLabel(language)} audio.`}- </p>- )}</div>);}-/** Display name for a resolved language code, for the pronunciation hint. */-function languageLabel(code: string): string {- return SPEECH_LANGUAGES.find((l) => l.id === code)?.label ?? code;-}-/** The cue ids the readout covers: `select`'s scope, or every non-empty cue. */function scopedCueIds(s: EditorState, select?: (s: EditorState) => string[]): string[] {return select ? select(s) : s.subtitles.cues.filter((c) => c.text.trim()).map((c) => c.id);@@ -261,21 +340,7 @@ export function GenerateSubtitlesAudio({return (<div className="subtitles-audio flex flex-col gap-2.5">- <VoicePicker- title="Generated audio"- // Play previews the subtitle readout itself; Generate commits it. The- // preview is cached, so committing afterward reuses the same audio.- sample={{- run: () =>- previewSubtitlesReadout(voice, {- cueIds: selectCueIds?.(useEditor.getState()),- language,- }),- title: "Play the subtitles",- disabled: cueCount === 0,- }}- onError={(e) => setError({ text: e instanceof Error ? e.message : "Could not play the subtitles.", credits: e instanceof NoCreditsError })}- />+ <VoicePicker title="Generated audio" /><Buttonvariant="outline"className="voice-readout w-full"diff --git a/site/src/cut/lib/aiTools.ts b/site/src/cut/lib/aiTools.tsindex b158824d..fb875cb8 100644--- a/site/src/cut/lib/aiTools.ts+++ b/site/src/cut/lib/aiTools.ts@@ -814,7 +814,7 @@ export async function runAiTool(case "list_voices": {// Gemini's prebuilt voice catalog is fixed and ships hardcoded.return {- voices: SPEECH_VOICES.map((v) => ({ id: v.id, style: v.style })),+ voices: SPEECH_VOICES.map((v) => ({ name: v.name, style: v.style })),total: SPEECH_VOICES.length,};}diff --git a/site/src/cut/lib/tts.ts b/site/src/cut/lib/tts.tsindex e20d0401..7560fc1d 100644--- a/site/src/cut/lib/tts.ts+++ b/site/src/cut/lib/tts.ts@@ -3,6 +3,17 @@import { geminiModels } from "@/lib/inference/gemini-models";import { importFileToProject } from "./media";import type { MediaAsset } from "./types";+import {+ DEFAULT_VOICE,+ resolveVoice,+ SPEECH_VOICES,+ VOICE_SAMPLE_TEXT,+ type SpeechVoice,+} from "./voices";++// The voice catalog lives in the dependency-light `voices` module (shared with+// the build script); re-exported here so existing importers keep working.+export { DEFAULT_VOICE, resolveVoice, SPEECH_VOICES, type SpeechVoice };// Client side of AI voiceovers: Gemini speech generation on Donkey's hosted// inference routes, with the user's Donkey sign-in and credits (same-origin on@@ -11,55 +22,12 @@ import type { MediaAsset } from "./types";// one WAV, and saves it into the project through the local engine like any// other media file.-export interface SpeechVoice {- id: string;- /** One-word character from the voice catalog ("Warm", "Upbeat"). */- style: string;-}-export interface SpeechSegment {text: string;/** Timeline offset this line should land at, seconds. */at: number;}-/** Gemini's prebuilt voices. The set is fixed by the model, so it ships- * hardcoded — no listing round-trip. */-export const SPEECH_VOICES: SpeechVoice[] = [- { id: "Zephyr", style: "Bright" },- { id: "Puck", style: "Upbeat" },- { id: "Charon", style: "Informative" },- { id: "Kore", style: "Firm" },- { id: "Fenrir", style: "Excitable" },- { id: "Leda", style: "Youthful" },- { id: "Orus", style: "Firm" },- { id: "Aoede", style: "Breezy" },- { id: "Callirrhoe", style: "Easy-going" },- { id: "Autonoe", style: "Bright" },- { id: "Enceladus", style: "Breathy" },- { id: "Iapetus", style: "Clear" },- { id: "Umbriel", style: "Easy-going" },- { id: "Algieba", style: "Smooth" },- { id: "Despina", style: "Smooth" },- { id: "Erinome", style: "Clear" },- { id: "Algenib", style: "Gravelly" },- { id: "Rasalgethi", style: "Informative" },- { id: "Laomedeia", style: "Upbeat" },- { id: "Achernar", style: "Soft" },- { id: "Alnilam", style: "Firm" },- { id: "Schedar", style: "Even" },- { id: "Gacrux", style: "Mature" },- { id: "Pulcherrima", style: "Forward" },- { id: "Achird", style: "Friendly" },- { id: "Zubenelgenubi", style: "Casual" },- { id: "Vindemiatrix", style: "Gentle" },- { id: "Sadachbia", style: "Lively" },- { id: "Sadaltager", style: "Knowledgeable" },- { id: "Sulafat", style: "Warm" },-];--export const DEFAULT_VOICE = "Puck";-export interface SpeechLanguage {id: string;label: string;@@ -67,10 +35,9 @@ export interface SpeechLanguage {sample: string;}-// Sample lines stay full declarative sentences — "Hey!"-style leads make the-// TTS model intermittently return an empty clip. Change with care and re-check-// reliability across voices.-const SAMPLE_TEXT = "This is how I sound. Let's make something worth remembering.";+// The neutral sample line, shared with the persona catalog; also the default+// text for every language whose own sample is not written out below.+const SAMPLE_TEXT = VOICE_SAMPLE_TEXT;/** Languages the speech model speaks (BCP-47, fixed by the model). "auto" lets* the model match the text; a concrete pick pins pronunciation and picks the@@ -118,21 +85,6 @@ export function resolveLanguage(wanted?: string): string {return bare?.id ?? DEFAULT_LANGUAGE;}-/** Resolve a requested voice against the catalog: an exact (or- * case-insensitive) id match, else the default. Shared by the Audio panel and- * the AI copilot so both land on the same voice. */-export function resolveVoice(wanted?: string): string {- if (typeof wanted === "string" && wanted.trim()) {- const exact = SPEECH_VOICES.find((v) => v.id === wanted.trim());- if (exact) return exact.id;- const ci = SPEECH_VOICES.find(- (v) => v.id.toLowerCase() === wanted.trim().toLowerCase()- );- if (ci) return ci.id;- }- return DEFAULT_VOICE;-}-const CLIENT_ID = "donkey-cut";/** What a free-text voice direction resolves to once a model has read it. */@@ -481,23 +433,6 @@ export async function synthesizeSpeech(return { asset, offset, layout };}-/** A short spoken sample for the voice picker, in the picked language. Each- * voice+language pair is synthesized once per session and cached as a blob URL. */-const samples = new Map<string, string>();--export async function speechSampleUrl(voice: string, language?: string): Promise<string> {- const id = resolveVoice(voice);- const lang = resolveLanguage(language);- const key = `${id}|${lang}`;- const cached = samples.get(key);- if (cached) return cached;- const text = SPEECH_LANGUAGES.find((l) => l.id === lang)?.sample ?? SAMPLE_TEXT;- const clip = await synthesizeSegment(text, id, undefined, lang);- const url = URL.createObjectURL(assembleWav([clip], [0]));- samples.set(key, url);- return url;-}-function slug(name: string) {return (namediff --git a/site/src/cut/lib/voiceover.ts b/site/src/cut/lib/voiceover.tsindex 12ff8508..46d6d839 100644--- a/site/src/cut/lib/voiceover.ts+++ b/site/src/cut/lib/voiceover.ts@@ -57,22 +57,6 @@ async function renderReadout(return cached;}-/**- * Voice the subtitle cues and return a blob URL to play in-panel — a preview of- * exactly what "Generate" will drop on the timeline, without creating an asset.- * The render is cached, so committing that same readout afterward reuses this- * audio rather than paying to synthesize it twice.- */-export async function previewSubtitlesReadout(- voice: string,- opts?: { cueIds?: string[]; direction?: string; language?: string }-): Promise<string> {- const cues = readoutCues(opts?.cueIds);- if (cues.length === 0) throw new Error("No subtitles to read.");- const { blob } = await renderReadout(voice, cues, opts);- return URL.createObjectURL(blob);-}-/*** Voice the subtitle cues (all of them, or just `opts.cueIds`) and drop the* result on the soundtrack at the first cue. The spoken pace differs from thediff --git a/site/src/cut/lib/voices.ts b/site/src/cut/lib/voices.tsnew file mode 100644index 00000000..16dc788d--- /dev/null+++ b/site/src/cut/lib/voices.ts@@ -0,0 +1,97 @@+// Speech persona catalog: the fixed set of prebuilt voices the speech model+// offers, plus the hosted-asset URLs the picker shows. Shared by the client+// (voice picker, AI copilot) and the build script that renders each persona's+// portrait and sample clip. Dependency-light on purpose — no browser or server+// imports — so scripts/generate-voices.ts can import it directly.++export interface SpeechVoice {+ /** The model's own voice identifier (a star/mythology name like+ * "Zubenelgenubi"). The API and the hosted asset filenames key off this; it+ * is never shown to the user. */+ id: string;+ /** Friendly, memorable display name shown everywhere in the UI. */+ name: string;+ /** One-word character from the voice catalog ("Warm", "Upbeat"). */+ style: string;+ /** Apparent gender of the voice, used to group the picker (women first). */+ gender: "f" | "m";+}++/** Gemini's prebuilt voices, women first then men (the picker groups by+ * gender). The set is fixed by the model, so it ships hardcoded — no listing+ * round-trip. Each carries a plain display `name` (the raw `id` is+ * unpronounceable and unmemorable) matched to the persona's look. */+export const SPEECH_VOICES: SpeechVoice[] = [+ // Women+ { id: "Zephyr", name: "Zoe", style: "Bright", gender: "f" },+ { id: "Kore", name: "Kate", style: "Firm", gender: "f" },+ { id: "Fenrir", name: "Fiona", style: "Excitable", gender: "f" },+ { id: "Leda", name: "Lily", style: "Youthful", gender: "f" },+ { id: "Aoede", name: "Ava", style: "Breezy", gender: "f" },+ { id: "Callirrhoe", name: "Callie", style: "Easy-going", gender: "f" },+ { id: "Autonoe", name: "Nora", style: "Bright", gender: "f" },+ { id: "Despina", name: "Daphne", style: "Smooth", gender: "f" },+ { id: "Erinome", name: "Erin", style: "Clear", gender: "f" },+ { id: "Laomedeia", name: "Layla", style: "Upbeat", gender: "f" },+ { id: "Achernar", name: "Aria", style: "Soft", gender: "f" },+ { id: "Gacrux", name: "Grace", style: "Mature", gender: "f" },+ { id: "Pulcherrima", name: "Piper", style: "Forward", gender: "f" },+ { id: "Vindemiatrix", name: "Vivian", style: "Gentle", gender: "f" },+ { id: "Sadachbia", name: "Sadie", style: "Lively", gender: "f" },+ { id: "Sulafat", name: "Sofia", style: "Warm", gender: "f" },+ // Men+ { id: "Puck", name: "Max", style: "Upbeat", gender: "m" },+ { id: "Charon", name: "Charlie", style: "Informative", gender: "m" },+ { id: "Orus", name: "Oscar", style: "Firm", gender: "m" },+ { id: "Enceladus", name: "Ellis", style: "Breathy", gender: "m" },+ { id: "Iapetus", name: "Ian", style: "Clear", gender: "m" },+ { id: "Umbriel", name: "Milo", style: "Easy-going", gender: "m" },+ { id: "Algieba", name: "Andre", style: "Smooth", gender: "m" },+ { id: "Algenib", name: "Gus", style: "Gravelly", gender: "m" },+ { id: "Rasalgethi", name: "Russell", style: "Informative", gender: "m" },+ { id: "Alnilam", name: "Neil", style: "Firm", gender: "m" },+ { id: "Schedar", name: "Seth", style: "Even", gender: "m" },+ { id: "Achird", name: "Archie", style: "Friendly", gender: "m" },+ { id: "Zubenelgenubi", name: "Zane", style: "Casual", gender: "m" },+ { id: "Sadaltager", name: "Simon", style: "Knowledgeable", gender: "m" },+];++export const DEFAULT_VOICE = "Puck";++// The line every persona speaks for its hover preview and that the build script+// renders to a hosted clip. Full declarative sentences only — "Hey!"-style+// leads make the TTS model intermittently return an empty clip. Change with+// care, then re-render the samples (scripts/generate-voices.ts).+export const VOICE_SAMPLE_TEXT =+ "This is how I sound. Let's make something worth remembering.";++/** Resolve a requested voice to its model id: an exact id match, else a+ * case-insensitive match on the id or the friendly display name, else the+ * default. Shared by the picker, the AI copilot (which sees display names), and+ * the asset-URL helpers so a loose ask still lands on a real voice. */+export function resolveVoice(wanted?: string): string {+ const w = wanted?.trim();+ if (w) {+ const exact = SPEECH_VOICES.find((v) => v.id === w);+ if (exact) return exact.id;+ const ci = SPEECH_VOICES.find(+ (v) => v.id.toLowerCase() === w.toLowerCase() || v.name.toLowerCase() === w.toLowerCase()+ );+ if (ci) return ci.id;+ }+ return DEFAULT_VOICE;+}++/** Where the persona's assets live, served statically from `public/`. Both are+ * rendered once by scripts/generate-voices.ts and committed. */+const VOICE_ASSET_DIR = "/cut/voices";++/** Hosted persona portrait (square WebP). */+export function voicePortraitUrl(id: string): string {+ return `${VOICE_ASSET_DIR}/${resolveVoice(id).toLowerCase()}.webp`;+}++/** Hosted sample clip (MP3) of the persona speaking VOICE_SAMPLE_TEXT. */+export function voiceSampleUrl(id: string): string {+ return `${VOICE_ASSET_DIR}/${resolveVoice(id).toLowerCase()}.mp3`;+}