Skip to content

createCaptions

createCaptions<M>(languagesMap): Captions<AllCaptions<M>>

Defined in: caption.ts:167

Creates a set of typed caption controllers, one per key in the map.

Each controller has start(), waitUntil(percent), and end(). At render time screenci sends the caption text to ElevenLabs, generates a voiceover, and syncs the audio to the recording. You write text; the voice is handled for you.

TypeScript enforces that every language has the same caption keys. Forget a translation key → compile error.

M extends Partial<Record<"fi" | "en", { captions: Record<string, CaptionMapValue>; voice: VoiceKey; }>>

M & { [L in string | number | symbol]: { captions: AllCaptions<M>; voice: VoiceForLang<L & string> } }

Captions<AllCaptions<M>>

const captions = createCaptions({
en: { voice: voices.en.Jude, captions: { intro: 'Welcome.' } },
fi: { voice: voices.fi.Martti, captions: { intro: 'Tervetuloa.' } },
})