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 Voice Changer performs speech-to-speech conversion: it takes any input audio recording and transforms it into a chosen ElevenLabs voice while preserving the original prosody, rhythm, and emotional delivery. This makes it ideal for dubbing performances, re-voicing podcast episodes, or applying a branded voice to recorded content without re-recording from scratch.

Usage

Call ElevenLabs::voiceChanger()->convert() with a target voice ID, a Content::audio() value wrapping the source file, and an optional options array.
use AiSdk\Content;
use AiSdk\ElevenLabs;

$result = ElevenLabs::voiceChanger()->convert(
    voiceId: 'JBFqnCBsd6RMkjVDRZzb',
    audio: Content::audio(__DIR__.'/performance.wav'),
    options: [
        'model_id' => 'eleven_multilingual_sts_v2',
        'remove_background_noise' => true,
        'output_format' => 'wav_44100',
    ],
);

$result->output->save(__DIR__.'/changed.wav');
You can also call the same method on a configured provider instance rather than the static facade:
use AiSdk\Content;
use AiSdk\ElevenLabs;

$elevenLabs = ElevenLabs::create(['apiKey' => 'xi-...']);

$result = $elevenLabs->voiceChanger()->convert(
    voiceId: 'JBFqnCBsd6RMkjVDRZzb',
    audio: Content::audio(__DIR__.'/performance.wav'),
    options: [
        'model_id' => 'eleven_multilingual_sts_v2',
        'remove_background_noise' => true,
        'output_format' => 'wav_44100',
    ],
);

$result->output->save(__DIR__.'/changed.wav');

Parameters

voiceId
string
required
The ElevenLabs voice ID to convert the source audio into. Any voice ID from your ElevenLabs workspace is accepted, for example JBFqnCBsd6RMkjVDRZzb.
audio
Content
required
The source audio to transform, wrapped in a Content::audio() value. Accepts a file path or inline bytes:
// From a file path
Content::audio(__DIR__.'/performance.wav')

// From raw bytes with explicit MIME type and filename
Content::audio($rawBytes, 'audio/wav', 'performance.wav')
options
array
An optional associative array of additional request fields. Most fields are sent as multipart form parts; a small set of fields are promoted to query parameters automatically — see Query parameters below.

Options

Request body fields

These options are sent in the multipart request body alongside the audio file.
model_id
string
The speech-to-speech model to use. ElevenLabs recommends eleven_multilingual_sts_v2 for high-quality multilingual conversion.
remove_background_noise
boolean
When true, background noise is stripped from the input audio before conversion begins. Useful when the source recording was captured in a noisy environment.
voice_settings
object
Fine-grained voice control passed as a JSON object. Accepts stability, similarity_boost, style, and use_speaker_boost keys as documented by ElevenLabs.

Query parameters

The following fields are automatically extracted from the $options array and appended to the request URL as query parameters instead of being sent in the body. This matches the ElevenLabs API contract for the speech-to-speech endpoint.
output_format
string
The desired audio encoding and sample rate of the returned file. Common values include mp3_44100_128, wav_44100, and pcm_16000. Defaults to mp3_44100_128 when omitted.
enable_logging
boolean
When false, the request and response are excluded from ElevenLabs usage logs and history.
optimize_streaming_latency
integer
A legacy latency-optimisation level (0–4). Deprecated by ElevenLabs but still accepted. Omit this field unless you have an existing integration that depends on it.
output_format, enable_logging, and optimize_streaming_latency are silently removed from the multipart body and sent as query parameters. All other keys in $options remain in the request body.

Return value

convert() returns an AudioResult. Access the converted audio through its output property:
output
AudioData
The converted audio file.
Save directly to a file path using the helper method:
$result->output->save(__DIR__.'/changed.wav');
Or work with the raw bytes directly:
$bytes = $result->output->data;
file_put_contents('/tmp/changed.wav', $bytes);

Full example

use AiSdk\Content;
use AiSdk\ElevenLabs;

ElevenLabs::create(['apiKey' => $_ENV['ELEVENLABS_API_KEY']]);

$result = ElevenLabs::voiceChanger()->convert(
    voiceId: 'JBFqnCBsd6RMkjVDRZzb',
    audio: Content::audio(__DIR__.'/performance.wav'),
    options: [
        'model_id'               => 'eleven_multilingual_sts_v2',
        'remove_background_noise' => true,
        'output_format'          => 'wav_44100',
        'enable_logging'         => false,
    ],
);

$result->output->save(__DIR__.'/changed.wav');

echo 'Saved converted audio — ' . strlen($result->output->data) . ' bytes';

Build docs developers (and LLMs) love