---
title: "Generate speech from text"
method: POST
path: "/text-to-speech/speech"
tags: ["Text To Speech Commands"]
---

# Generate speech from text

`POST /text-to-speech/speech`

Generate synthesized speech audio from text input. Returns audio in the requested format (binary audio stream, base64-encoded JSON, or an audio URL for later retrieval).

Authentication is provided via the standard `Authorization: Bearer <API_KEY>` header.

The `voice` parameter provides a convenient shorthand to specify provider, model, and voice in a single string (e.g. `telnyx.NaturalHD.Alloy` or `Telnyx.Ultra.<voice_id>`). Alternatively, specify `provider` explicitly along with provider-specific parameters.

Supported providers: `aws`, `telnyx`, `azure`, `elevenlabs`, `minimax`, `rime`, `resemble`, `xai`, `humain`.

The Telnyx `Ultra` model supports 44 languages with emotion control, speed adjustment, and volume control. Use the `telnyx` provider-specific parameters to configure these features.

## Request body

- GenerateSpeechRequest — Request body for generating speech from text.
  - `voice` string — Voice identifier in the format `provider.model_id.voice_id` or `provider.voice_id`. Examples: `telnyx.NaturalHD.Alloy`, `Telnyx.Ultra.<voice_id>`, `Telnyx.Bayan.Ahmed`, `Telnyx.Sukhan.urdu-professor`, `azure.en-US-AvaMultilingualNeural`, `aws.Polly.Generative.Lucia`. When provided, `provider`, `model_id`, and `voice_id` are extracted automatically and take precedence over individual parameters.
  - `text` string — The text to convert to speech.
  - `provider` 'aws' | 'telnyx' | 'azure' | 'elevenlabs' | 'minimax' | 'rime' | 'resemble' | 'xai' | 'humain' — TTS provider. Required unless `voice` is provided.
  - `language` string — Language code (e.g. `en-US`). Usage varies by provider.
  - `text_type` 'text' | 'ssml' — Text type. Use `ssml` for SSML-formatted input (supported by AWS and Azure).
  - `output_type` 'binary_output' | 'base64_output' — Determines the response format. `binary_output` returns raw audio bytes, `base64_output` returns base64-encoded audio in JSON.
  - `disable_cache` boolean — When `true`, bypass the audio cache and generate fresh audio.
  - `voice_settings` object — Provider-specific voice settings. Contents vary by provider — see provider-specific parameter objects below.
  - `aws` AwsProviderParams — AWS Polly provider-specific parameters.
    - `language_code` string — Language code (e.g. `en-US`, `es-ES`).
    - `text_type` 'text' | 'ssml' — Input text type.
    - `lexicon_names` string[] — List of lexicon names to apply.
    - `output_format` string — Audio output format.
    - `sample_rate` string — Audio sample rate.
  - `telnyx` TelnyxProviderParams — Telnyx provider-specific parameters. Use `voice_speed` and `temperature` for `Natural` and `NaturalHD` models. For the `Ultra` model, use `voice_speed`, `volume`, and `emotion`. `Bayan` and `Sukhan` don't use `temperature`, `volume`, or `emotion`, and don't support `voice_speed`. `Sukhan`'s `response_format` is restricted to `mp3` or `pcm` (no `wav`).
    - `voice_speed` number, float — Voice speed multiplier. Applies to all models except `Bayan` and `Sukhan`, which don't support it. Range: 0.5 to 2.0.
    - `response_format` string — Audio response format.
    - `sampling_rate` integer — Audio sampling rate in Hz.
    - `temperature` number, float — Sampling temperature. Applies to `Natural` and `NaturalHD` models only.
    - `volume` number, float — Volume level for the Ultra model. Range: 0.0 to 2.0.
    - `emotion` 'neutral' | 'happy' | 'sad' | 'angry' | 'fearful' | 'disgusted' | 'surprised' — Emotion control for the Ultra model. Adjusts the emotional tone of the synthesized speech.
  - `azure` AzureProviderParams — Azure Cognitive Services provider-specific parameters.
    - `language_code` string — Language code (e.g. `en-US`).
    - `output_format` string — Azure audio output format.
    - `text_type` 'text' | 'ssml' — Input text type. Use `ssml` for SSML-formatted input.
    - `api_key` string — Custom Azure API key. If not provided, the default Telnyx key is used.
    - `region` string — Azure region (e.g. `eastus`, `westeurope`).
    - `deployment_id` string — Custom Azure deployment ID.
    - `effect` string — Azure audio effect to apply.
    - `gender` string — Voice gender preference.
  - `elevenlabs` ElevenLabsProviderParams — ElevenLabs provider-specific parameters.
    - `language_code` string — Language code.
    - `api_key` string — Custom ElevenLabs API key. If not provided, the default Telnyx key is used.
    - `voice_settings` object — ElevenLabs voice settings (stability, similarity_boost, etc.).
  - `minimax` MinimaxProviderParams — Minimax provider-specific parameters.
    - `speed` number, float — Speech speed multiplier.
    - `vol` number, float — Volume level.
    - `pitch` integer — Pitch adjustment.
    - `response_format` string — Audio output format.
    - `language_boost` string — Language code to boost pronunciation for.
  - `rime` RimeProviderParams — Rime provider-specific parameters.
    - `voice_speed` number, float — Voice speed multiplier.
    - `response_format` string — Audio output format.
    - `sampling_rate` integer — Audio sampling rate in Hz.
  - `resemble` ResembleProviderParams — Resemble AI provider-specific parameters.
    - `api_key` string — Custom Resemble API key.
    - `precision` string — Synthesis precision.
    - `sample_rate` string — Audio sample rate.
    - `format` string — Audio output format.
  - `xai` XAIProviderParams — xAI provider-specific parameters.
    - `voice_id` 'eve' | 'ara' | 'rex' | 'sal' | 'leo', required — xAI voice identifier.
    - `language` string — Language code, or `auto` to detect.
    - `output_format` 'mp3' | 'wav' | 'pcm' | 'mulaw' | 'alaw' — Audio output format.
    - `sample_rate` 8000 | 16000 | 22050 | 24000 | 44100 | 48000 — Audio sample rate in Hz.
  - `humain` HumainProviderParams — Humain provider-specific parameters. Unlike other providers, Humain has no format/sample-rate negotiation (output is always PCM16 24kHz mono) and no language parameter — language is fixed per voice.
    - `voice_id` 'sara-en' | 'abdulaziz-en' | 'sara-ar' | 'abdulaziz-ar' | 'nourah-ar' | 'abdullah-ar', required — Humain voice identifier.
    - `ttfb_eagerness` number, float — Time-to-first-byte eagerness, trading synthesis latency for quality.

## Response `200`

Speech generated successfully. The response format depends on the `output_type` parameter:
- `binary_output` (default): Returns raw audio bytes with the appropriate `Content-Type` header. Most providers return `audio/mpeg`; `humain` has no MP3 output and always returns raw headerless PCM16LE 24kHz mono as `audio/pcm`.
- `base64_output`: Returns a JSON object with `base64_audio` field.

- Base64AudioResponse — Response when `output_type` is `base64_output`.
  - `base64_audio` string — Base64-encoded audio data.

## Other responses

- `400` — Bad request — invalid parameters or provider error.
- `401` — Authentication failed — missing or invalid API key.
- `422` — Validation failed — invalid or missing required fields.

---

[API](https://skmtc.net/team-telnyx/apis/telnyx-api-2.md) · [All operations](https://skmtc.net/team-telnyx/apis/telnyx-api-2/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/team-telnyx/telnyx-api-2/versions/8f5f4e537994/schema)
