Skip to main content
generateSegments voices the segments you choose into one downloadable clip per segment. It does not touch the video. Use it to check or download chosen lines. When you want them in the video, a dub assembles them. You need the scopes dubbing:write and credits:spend, and the plan feature audio_download. The project needs a transcript and voices. Listing segments needs transcripts:read, and on a project created through the API, its text must be open, which usually happens once a dub is charged: see Paid text.

1. Choose the segments

2. Estimate

A batch holds 1 to 100 segments. The price is max(1, round(s/60)) minutes (half to even), where s is the speech seconds of the chosen segments. A free dubbing variant (free_dubbing) costs 0.
details says what you pay for and what the engine does: Two notices matter. wider_voice_setup repeats the voice setup above. clips_not_reusable says the project has no dub yet, so the first dub will voice and charge these segments again.

3. Generate

The answer is a segment_generation job. While it runs, its segments are voicing. A dub of the project answers 409 segment_busy, and so does an edit that changes their speaker or translation, splits, merges or deletes them.

4. Read the clips

The finished job’s result.clips holds one SegmentClip per segment: Any voiced clip counts as success, also when it overruns. A take is stored under its job and never overwritten, so an old job keeps serving its old take. Segment.audio is different: it is the latest clip and each new take replaces it. If a segment fails, the job fails and is refunded whole. A failed job usually has no clips, because the engine stores audio only after all synthesis succeeded. Its segments go back to the state they had. Start again with a new Idempotency-Key. After a successful job, the voiced segments’ dub_state is outdated (not_dubbed when the project has no dub), and their ETags may have changed. Use clips[].segment_etag, or read the segment again, before you edit it.

5. Assemble with a dub

A dub puts the clips into the video without voicing or charging them again only when it applies the changed_segments mode, which needs a project that already has a dub. A first or full dub voices and charges every segment. The estimate’s details.mode_applied says which mode the dub applies: it is full when the project needs a full dub, even for mode: changed_segments.
A clip counts while it is still the segment’s latest clip, the segment’s speaker, interval and translation are as they were when it was voiced, and its voice has not changed since (a new voice or new clone settings). A change to any of these means the segment is voiced again. Only clips of a succeeded job count, from the project’s 200 most recent succeeded segment generations. The estimate is the answer for your project: read details.reused_clip_segment_ids before you pay.
The anchor segment. A track can be rebuilt only when at least one segment is voiced. So when every changed segment already has a current clip, the shortest one is voiced again, at its own speech price with a minimum of 1 minute, and its clip in the track is a new take. The estimate discloses it in assembly_anchor_segment_id and the notice assembly_anchor_voiced.
The job’s result reports voiced_segment_count and reused_clip_count. Then download the outputs.

The whole program

generate_segments.py