v5

latestOpenAPI 3.1.02026-08-043621,4011.8 MB
text-to-speech

Text To Speech Streaming With Timestamps

Converts text into speech using a voice of your choice and returns a stream of JSONs containing audio as a base64 encoded string together with information on when which character was spoken.

post/v1/text-to-speech/{voice_id}/stream/with-timestamps

Path parameters

voice_idstring required

Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.

Example:21m00Tcm4TlvDq8ikWAM

Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.

Query parameters

enable_loggingboolean

When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers.

When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers.

optimize_streaming_latencyinteger nullable

You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Possible values: 0 - default mode (no latency optimizations) 1 - normal latency optimizations (about 50% of possible latency improvement of option 3) 2 - strong latency optimizations (about 75% of possible latency improvement of option 3) 3 - max latency optimizations 4 - max latency optimizations, but also with text normalizer turned off for even more latency savings (best latency, but can mispronounce eg numbers and dates).

Defaults to None.

You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Possible values: 0 - default mode (no latency optimizations) 1 - normal latency optimizations (about 50% of possible latency improvement of option 3) 2 - strong latency optimizations (about 75% of possible latency improvement of option 3) 3 - max latency optimizations 4 - max latency optimizations, but also with text normalizer turned off for even more latency savings (best latency, but can mispronounce eg numbers and dates).

Defaults to None.

output_format'mp3_22050_32' | 'mp3_24000_48' | 'mp3_44100_32' | 'mp3_44100_64' | 'mp3_44100_96' | 'mp3_44100_128' | 'mp3_44100_192' | 'pcm_8000' | 'pcm_16000' | 'pcm_22050' | 'pcm_24000' | 'pcm_32000' | 'pcm_44100' | 'pcm_48000' | 'ulaw_8000' | 'alaw_8000' | 'opus_48000_32' | 'opus_48000_64' | 'opus_48000_96' | 'opus_48000_128' | 'opus_48000_192'

Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs.

Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs.

Headers

xi-api-keystring nullable

Your API key. This is required by most endpoints to access our API programmatically. You can view your xi-api-key using the 'Profile' tab on the website.

Your API key. This is required by most endpoints to access our API programmatically. You can view your xi-api-key using the 'Profile' tab on the website.

Request body

textstring required

The text that will get converted into speech.

model_idstring

Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for text to speech, you can check this using the can_do_text_to_speech property.

language_codestring nullable

Language code (ISO 639-1) used to enforce a language for the model and text normalization. If the model does not support the provided language code, it will be ignored. This parameter is not supported for multilingual_v2 models.

seedinteger nullable

If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295.

previous_textstring nullable

The text that came before the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation.

next_textstring nullable

The text that comes after the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation.

previous_request_idsstring[] nullable

A list of request_id of the samples that were generated before this generation. Can be used to improve the speech's continuity when splitting up a large task into multiple requests. The results will be best when the same model is used across the generations. In case both previous_text and previous_request_ids is send, previous_text will be ignored. A maximum of 3 request_ids can be send.

next_request_idsstring[] nullable

A list of request_id of the samples that come after this generation. next_request_ids is especially useful for maintaining the speech's continuity when regenerating a sample that has had some audio quality issues. For example, if you have generated 3 speech clips, and you want to improve clip 2, passing the request id of clip 3 as a next_request_id (and that of clip 1 as a previous_request_id) will help maintain natural flow in the combined speech. The results will be best when the same model is used across the generations. In case both next_text and next_request_ids is send, next_text will be ignored. A maximum of 3 request_ids can be send.

use_pvc_as_ivcboolean

If true, we won't use PVC version of the voice for the generation but the IVC version. This is a temporary workaround for higher latency in PVC versions.

apply_text_normalization'auto' | 'on' | 'off'

This parameter controls text normalization with three modes: 'auto', 'on', and 'off'. When set to 'auto', the system will automatically decide whether to apply text normalization (e.g., spelling out numbers). With 'on', text normalization will always be applied, while with 'off', it will be skipped.

apply_language_text_normalizationboolean

This parameter controls language text normalization. This helps with proper pronunciation of text in some supported languages. WARNING: This parameter can heavily increase the latency of the request. Currently only supported for Japanese.

Example request

{
  "text": "This is a test for the API of ElevenLabs.",
  "voice_settings": {
    "similarity_boost": 1,
    "speed": 1,
    "stability": 1,
    "style": 0,
    "use_speaker_boost": true
  },
  "pronunciation_dictionary_locators": [
    {
      "pronunciation_dictionary_id": "test",
      "version_id": "id2"
    }
  ],
  "seed": 12345,
  "previous_text": "In the heart of a lush valley surrounded by towering mountains lies the quaint village of Willowbrook.",
  "next_text": "The Willowbrook Festival, held every spring, celebrates the blossoming of the wild bluebells that carpet the nearby forest floors, creating a breathtaking sea of blue under the canopy of fresh green leaves.",
  "previous_request_ids": [
    "09bOJkdYVjKy2oOiiVtR",
    "0p2uKqOnZyce22SPZ9d5",
    "1KYvY8WZAKmcjCJ1mvVB"
  ],
  "next_request_ids": [
    "3tPgBrD1UdW3snUkGw1K",
    "4D1jAxiRFkolBNUGzXkU",
    "4c8Z4aWliVR2oipYRXhj"
  ],
  "use_pvc_as_ivc": true,
  "apply_language_text_normalization": true
}

Response

Stream of transcription chunks

audio_base64string required

Base64 encoded audio data

Example response

{
  "alignment": {
    "character_end_times_seconds": [
      0.1,
      0.2
    ],
    "character_start_times_seconds": [
      0,
      0.1
    ],
    "characters": [
      "H",
      "e"
    ]
  },
  "audio_base64": "base64_encoded_audio_chunk",
  "normalized_alignment": {
    "character_end_times_seconds": [
      0.1,
      0.2
    ],
    "character_start_times_seconds": [
      0,
      0.1
    ],
    "characters": [
      "H",
      "e"
    ]
  }
}