Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/phpaisdk/elevenlabs/llms.txt

Use this file to discover all available pages before exploring further.

The Dubbing resource translates and re-voices video or audio content into a target language using ElevenLabs’ dubbing pipeline. Because dubbing involves speech detection, translation, and synthesis, the process is asynchronous: you create a job, poll until it finishes, and then retrieve the dubbed media or subtitle transcript. The three phases are described below.
Dubbing is an asynchronous operation. Depending on media length and server load, a job may complete in a few seconds or several minutes. Poll status() on a schedule — such as every five seconds — rather than assuming immediate completion.
1
Create a dub job
2
Call create() to submit the media for dubbing. It returns a DubbingJob with the job ID and an estimated duration.
3
$job = ElevenLabs::dubbing()->create(
    Content::video(__DIR__.'/interview.mp4'),
    targetLanguage: 'es',
    options: ['source_lang' => 'en'],
);

echo $job->id;               // e.g. "dub-abc123"
echo $job->expectedDuration; // estimated duration in seconds
4
For URL-backed content, pass a URL string to Content::video() instead of a local path:
5
$job = ElevenLabs::dubbing()->create(
    Content::video('https://example.com/interview.mp4'),
    targetLanguage: 'fr',
);
6
Poll for completion
7
Call status() with the job ID to check progress. The status field reflects the current state of the job.
8
$status = ElevenLabs::dubbing()->status($job->id);

echo $status->status; // 'pending', 'dubbing', 'dubbed', or 'failed'
9
If dubbing fails, $status->status will be 'failed' and $status->error will contain a message from ElevenLabs describing the reason. Always check for 'failed' before attempting to retrieve output.
10
Retrieve the output
11
Once $status->status === 'dubbed', retrieve the dubbed media file or the subtitle transcript.
12
Dubbed mediaoutput() returns a BinaryData object that can be saved directly:
13
if ($status->status === 'dubbed') {
    ElevenLabs::dubbing()
        ->output($job->id, 'es')
        ->save(__DIR__.'/interview-es.mp4');
}
14
Subtitle transcripttranscript() returns a DubbingTranscript. Use 'srt' or 'vtt' for caption files, or 'json' for structured data:
15
$subtitles = ElevenLabs::dubbing()->transcript($job->id, 'es', 'srt');
file_put_contents('interview-es.srt', $subtitles->content ?? '');

// Or retrieve structured JSON:
$json = ElevenLabs::dubbing()->transcript($job->id, 'es', 'json');
$data = $json->structured; // array|null

Method Reference

create()

Submits a new dubbing job and returns a DubbingJob.
$media
Content
required
The source media to dub. Use Content::video() for video files or URLs, or Content::audio() for audio-only content.
  • If $media has a URL (created from a URL string), the URL is sent as a source_url string form field.
  • Otherwise the raw binary is uploaded as a file multipart part with filename source.bin and content type application/octet-stream.
$targetLanguage
string
required
The BCP-47 language code for the target dubbed language. For example 'es' for Spanish or 'fr' for French. Sent as the target_lang multipart form field.
$options
array
Additional ElevenLabs dubbing parameters passed as multipart form fields. Common options include:
  • source_lang (string) — BCP-47 code of the source language. Omit to let ElevenLabs auto-detect.
  • num_speakers (int) — Hint for the number of distinct speakers in the source.
  • watermark (bool) — Whether to apply an ElevenLabs watermark to the output.
Any option value that is a Content instance is added as a file upload part; all other values are sent as string parts.

status()

Fetches the current state of a dubbing job.
$dubbingId
string
required
The job ID returned by create() as $job->id.

output()

Downloads the dubbed media for a completed job. Returns a BinaryData instance.
$dubbingId
string
required
The job ID of the completed dubbing job.
$languageCode
string
required
The BCP-47 language code of the dubbed track to retrieve. Must match one of the targetLanguages on the job.

transcript()

Downloads a subtitle or structured transcript for a completed job. Returns a DubbingTranscript.
$dubbingId
string
required
The job ID of the completed dubbing job.
$languageCode
string
required
The BCP-47 language code of the transcript to retrieve.
$format
string
default:"srt"
Transcript format. One of 'srt', 'vtt', or 'json'.

Return Types

DubbingJob

Returned by create().
id
string
The unique ID of the dubbing job, populated from the dubbing_id field in the API response. Store this to poll status and retrieve output.
expectedDuration
float
ElevenLabs’ estimate of the time required to complete the job, in seconds. Populated from the expected_duration_sec field in the API response.
rawResponse
array
The full decoded JSON response from the ElevenLabs API for inspection or debugging.

DubbingStatus

Returned by status().
id
string
The dubbing job ID.
name
string
A human-readable name for the dubbing job.
status
string
Current job state. One of 'pending', 'dubbing', 'dubbed', or 'failed'.
sourceLanguage
string|null
The detected or declared source language of the media.
targetLanguages
list<string>
The list of BCP-47 language codes the media is being or has been dubbed into.
createdAt
string
ISO 8601 timestamp of when the job was created.
editable
bool
Whether the dub is editable in ElevenLabs Dubbing Studio.
mediaType
string|null
MIME type of the source media, e.g. 'video/mp4' or 'audio/mpeg'.
mediaDuration
float|null
Duration of the source media in seconds, as reported by ElevenLabs.
error
string|null
An error message from ElevenLabs if status is 'failed'. null otherwise.
rawResponse
array
The full decoded JSON response from the ElevenLabs API for inspection or debugging.

DubbingTranscript

Returned by transcript().
format
string
The format of this transcript as confirmed by ElevenLabs: 'srt', 'vtt', or 'json'.
content
string|null
The raw transcript text for 'srt' or 'vtt' formats. null when the format is 'json'.
structured
array|null
Parsed transcript data when the json key is present in the API response. null when the format is 'srt' or 'vtt'.
rawResponse
array
The full decoded JSON response from the ElevenLabs API for inspection or debugging.

Complete Example

use AiSdk\Content;
use AiSdk\ElevenLabs;

// Step 1: Submit the job.
$job = ElevenLabs::dubbing()->create(
    Content::video(__DIR__.'/interview.mp4'),
    targetLanguage: 'es',
    options: ['source_lang' => 'en', 'num_speakers' => 2],
);

// Step 2: Poll until complete.
do {
    sleep(5);
    $status = ElevenLabs::dubbing()->status($job->id);
} while ($status->status === 'pending' || $status->status === 'dubbing');

// Step 3: Retrieve the output.
if ($status->status === 'dubbed') {
    ElevenLabs::dubbing()
        ->output($job->id, 'es')
        ->save(__DIR__.'/interview-es.mp4');

    $subtitles = ElevenLabs::dubbing()->transcript($job->id, 'es', 'srt');
    file_put_contents(__DIR__.'/interview-es.srt', $subtitles->content ?? '');

} elseif ($status->status === 'failed') {
    echo "Dubbing failed: {$status->error}\n";
}

Build docs developers (and LLMs) love