Refine and regenerate a dub

Edit the source transcript and translations, then regenerate a language's audio.

How-to guide · Assumes you have created a dubbing project and generated at least one language, as shown in the Dubbing quickstart.

The transcript editing and regeneration endpoints used in this guide are only available to enterprise workspaces. Contact sales for access.

A dub is only as accurate as the transcript it is built from. This guide covers the two places you can make corrections — the source transcript and a language’s translation — and how to regenerate the audio once you are satisfied.

How revisions work

Every project and every language track their own revision counter, both starting at 0.

  • Editing the source transcript increases the project’s revision. Transcription itself does not.
  • Editing a translation increases that language’s revision. It does not affect the source or any other language.
  • A language also reports output_revision: the revision its current audio was generated from. When output_revision is behind revision, the downloaded audio is out of date and the language’s status becomes stale.

Correct the source transcript before adding languages where possible. Translations are produced from the source, so fixing the source first means every language starts from the right text. Editing the source after a language exists marks that language stale and requires a regeneration.

Edit the source transcript

Read the source transcript to get each segment’s stable id, then edit, add, or delete segments.

1import os
2from dotenv import load_dotenv
3from elevenlabs.client import ElevenLabs
4
5load_dotenv()
6
7elevenlabs = ElevenLabs(api_key=os.getenv("ELEVENLABS_API_KEY"))
8
9# Replace with your project's ID
10project_id = "proj_1601kwkyxp0hfzvtmyxwqxx6mcy3"
11
12# Read the source transcript
13transcript = elevenlabs.dubbing.project.transcript.get(project_id)
14first_segment = transcript.segments[0]
15
16# Correct a segment's text
17elevenlabs.dubbing.project.transcript.update_segment(
18 project_id,
19 segment_id=first_segment.id,
20 text="Welcome to our latest product demo.",
21)
22
23# Add a segment (reuse an existing speaker_id so it is dubbed with that voice)
24added = elevenlabs.dubbing.project.transcript.create_segment(
25 project_id,
26 text="Thanks for watching.",
27 speaker_id=first_segment.speaker_id,
28 start_s=40.0,
29 end_s=42.0,
30)
31
32# Delete the segment we just added
33elevenlabs.dubbing.project.transcript.delete_segment(
34 project_id,
35 segment_id=added.segment.id,
36)

When editing timing, end_s must be greater than start_s. New segments require all four fields (text, speaker_id, start_s, end_s); the server assigns the segment id.

Refine a translation

A language transcript pairs each source segment with its translation. Segment id values match the source transcript, so you can line translations up against the original text. Edit a single segment’s translation to override the machine translation. Pass null to clear a translation and mark that segment for re-translation.

1project_id = "proj_1601kwkyxp0hfzvtmyxwqxx6mcy3"
2language_id = "lang_1001kwkyxp0je6ktn4knsfrasx5s"
3
4# Read the language's translations
5target = elevenlabs.dubbing.project.language.transcript.get(project_id, language_id)
6first_segment = target.segments[0]
7
8# Refine a single translation
9elevenlabs.dubbing.project.language.transcript.update_segment(
10 project_id,
11 language_id,
12 segment_id=first_segment.id,
13 translation="Bienvenido a nuestra última demostración de producto.",
14)

Editing a translation bumps the language’s revision. If the language had already completed, it becomes stale and keeps its previous audio until you regenerate.

Regenerate the audio

After editing the source transcript or a translation, regenerate the language to produce a fresh dub from the current transcript. Regeneration is charged like a generation.

1import time
2
3# Regenerate from the current transcript
4elevenlabs.dubbing.project.language.transcript.regenerate(project_id, language_id)
5
6# Poll until the new output is ready
7while True:
8 language = elevenlabs.dubbing.project.language.get(project_id, language_id)
9 if language.status == "completed":
10 break
11 if language.status == "failed":
12 raise RuntimeError("Regeneration failed")
13 time.sleep(5)
14
15print("Fresh output at", language.outputs.lossless_audio)

Regenerate returns a 409 Conflict if the project is not ready or the language is not in a settled state, for example when it is already generating. Once the language reaches completed again, output_revision equals revision and the downloaded audio reflects your edits.

You can control how strongly the dubbed speakers clone the source voices with the cloning_strength voice setting (0 to 10, default 7) when adding a language. See the create language target API reference.