TheDocumentation 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.
Dialogue resource renders multi-speaker conversations by assigning each line of text to a specific ElevenLabs voice ID. Each entry in the inputs array is spoken by its designated voice, and the segments are stitched into a single audio output. You can retrieve the plain audio or, when you need precise timing data, request character-level alignment and per-voice segment timestamps in a single call.
Basic Usage
create() accepts an array of text-and-voice pairs and returns an AudioResult. The rendered audio can be saved directly to disk.
Stage directions written in square brackets — such as
[giggling] or [curious] — are passed directly to ElevenLabs and influence how the voice delivers that line. ElevenLabs interprets these as expressive cues; they are not stripped or modified by the SDK.Inputs array structure
Each entry in the$inputs array must be an associative array containing exactly two keys:
| Key | Type | Description |
|---|---|---|
text | string | The spoken line, optionally prefixed with a stage direction in [brackets] |
voice_id | string | The ElevenLabs voice ID that will speak this line |
Options
The ElevenLabs dialogue model to use for generation. For example,
eleven_v3.The audio encoding format for the rendered output. Sent as a query parameter. Examples:
mp3_44100_128, wav_44100, pcm_16000.When set, controls whether ElevenLabs logs this request. Sent as a query parameter.
output_format and enable_logging are extracted from $options before the request body is built and sent as query parameters. All remaining keys in $options are merged into the JSON body alongside inputs.Output format and MIME type
Theoutput_format value determines both the audio encoding and the MIME type reported on AudioData::$mimeType. The SDK maps format prefixes as follows:
| Format prefix | MIME type |
|---|---|
wav_ | audio/wav |
pcm_ | audio/pcm |
opus_ | audio/opus |
ulaw_ | audio/basic |
alaw_ | audio/a-law |
(anything else, including mp3_) | audio/mpeg |
With Timestamps
withTimestamps() calls a different endpoint and returns a TimedDialogueResult that includes the rendered audio alongside character-level alignment and per-voice segment timing.
withTimestamps() accepts the same $inputs array format and the same optional $options array as create().
Return Types
TimedDialogueResult
Returned by withTimestamps(). Contains the rendered audio and all available timing data.
The rendered dialogue audio. Call
$timed->output->save($path) to write it to disk, or read $timed->output->data for the raw binary string.Character-level timing for the entire rendered output.
null if the model did not return alignment data.Normalized character-level timing. Follows the same structure as
alignment but with values normalized by ElevenLabs. null if not returned.An ordered list of per-voice segments describing when each voice is speaking within the final audio track.
The full decoded JSON response from the ElevenLabs API for inspection or debugging.
VoiceSegment
Each element of TimedDialogueResult::$voiceSegments is a VoiceSegment.
The ElevenLabs voice ID that produced this segment.
Start time of this segment in seconds, relative to the beginning of the combined audio output.
End time of this segment in seconds.
Index of the first character (within the full concatenated transcript) that belongs to this segment.
Index of the last character (exclusive) that belongs to this segment.
Zero-based index into the original
$inputs array identifying which input entry this segment corresponds to.CharacterAlignment
Used by both alignment and normalizedAlignment on TimedDialogueResult.
Ordered list of individual characters from the rendered transcript.
Start time in seconds for each character, aligned by index with
characters.End time in seconds for each character, aligned by index with
characters.