> ## Documentation Index
> Fetch the complete documentation index at: https://platform.perso.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Text to Speech

> Convert text to speech audio using a specified voice.

## Prerequisites

You must have at least one cloned voice. Use **Create Voice** (`POST /v1/voices/add`) to create a voice, then retrieve its `voice_id` from **List Voices** (`GET /v2/voices`).

Authenticate using the `PersoPlatform-APIKey` header.

```
--header 'PersoPlatform-APIKey: <your-api-key>'
```

## URL Path Parameters

Replace `{voice_id}` in the URL with your voice ID.
Retrieve available voice IDs from **List Voices** (`GET /v2/voices`).

| Parameter | Required | Description |
|-----------|----------|-------------|
| `voice_id` | Yes | The ID of the voice to use for speech generation. Retrieve available voice IDs from **List Voices** (`GET /v2/voices`). |
| `output_format` | Yes | Audio format. Default: `wav_24000` (see formats below) |


## Request Body Parameters

| Parameter | Required | Description |
|-----------|----------|-------------|
| `text` | Yes | Text to convert to speech |
| `model_id` | No | Default: `perso_multilingual_v1` |

## Output Formats

| Format | Content-Type | Description |
|--------|--------------|-------------|
| `pcm_24000` | `audio/L16` | Raw PCM 24kHz |
| `wav_24000` | `audio/wav` | WAV 24kHz |
| `mp3_44100_192` | `audio/mpeg` | MP3 44.1kHz 192kbps |

## Example

Select **"TextToSpeechRequest"** from the **Examples** dropdown to see a request example.

```bash
curl --request POST 
--url "https://platform.perso.ai/api/speech/v1/text-to-speech/{voice_id}?output_format=mp3_44100_192"
--header "PersoPlatform-APIKey: <your-api-key>"
--header "Content-Type: application/json"
--header "Accept: */*"
--data '{"text": "Hello, this is a text to speech test."}'
```




## OpenAPI

````yaml /specs/openapi-speech.json post /api/speech/v1/text-to-speech/{voice_id}
openapi: 3.0.3
info:
  title: Perso Speech API
  version: 0.0.0
servers:
  - url: https://platform.perso.ai
security: []
paths:
  /api/speech/v1/text-to-speech/{voice_id}:
    post:
      tags:
        - Speech
      summary: Text to Speech
      description: >
        Convert text to speech audio using a specified voice.


        ## Prerequisites


        You must have at least one cloned voice. Use **Create Voice** (`POST
        /v1/voices/add`) to create a voice, then retrieve its `voice_id` from
        **List Voices** (`GET /v2/voices`).


        Authenticate using the `PersoPlatform-APIKey` header.


        ```

        --header 'PersoPlatform-APIKey: <your-api-key>'

        ```


        ## URL Path Parameters


        Replace `{voice_id}` in the URL with your voice ID.

        Retrieve available voice IDs from **List Voices** (`GET /v2/voices`).


        | Parameter | Required | Description |

        |-----------|----------|-------------|

        | `voice_id` | Yes | The ID of the voice to use for speech generation.
        Retrieve available voice IDs from **List Voices** (`GET /v2/voices`). |

        | `output_format` | Yes | Audio format. Default: `wav_24000` (see
        formats below) |



        ## Request Body Parameters


        | Parameter | Required | Description |

        |-----------|----------|-------------|

        | `text` | Yes | Text to convert to speech |

        | `model_id` | No | Default: `perso_multilingual_v1` |


        ## Output Formats


        | Format | Content-Type | Description |

        |--------|--------------|-------------|

        | `pcm_24000` | `audio/L16` | Raw PCM 24kHz |

        | `wav_24000` | `audio/wav` | WAV 24kHz |

        | `mp3_44100_192` | `audio/mpeg` | MP3 44.1kHz 192kbps |


        ## Example


        Select **"TextToSpeechRequest"** from the **Examples** dropdown to see a
        request example.


        ```bash

        curl --request POST 

        --url
        "https://platform.perso.ai/api/speech/v1/text-to-speech/{voice_id}?output_format=mp3_44100_192"

        --header "PersoPlatform-APIKey: <your-api-key>"

        --header "Content-Type: application/json"

        --header "Accept: */*"

        --data '{"text": "Hello, this is a text to speech test."}'

        ```
      operationId: speech_v1_text_to_speech_create
      parameters:
        - in: query
          name: output_format
          schema:
            type: string
            enum:
              - mp3_44100
              - pcm_24000
              - pcm_44100
              - wav_24000
              - wav_44100
            default: wav_24000
          description: The desired audio output format.
          required: true
        - in: path
          name: voice_id
          schema:
            type: string
          description: >-
            The ID of the voice to use for speech generation. Retrieve available
            voice IDs from **List Voices** (`GET /v2/voices`).
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TextToSpeechRequestBodyRequest'
            examples:
              TextToSpeechRequest:
                value:
                  text: Hello, this is a text to speech test.
                  model_id: perso_multilingual_v1
        required: true
      responses:
        '200':
          content:
            '*/*':
              schema:
                type: string
                format: binary
          description: >-
            Audio binary. Content-Type depends on `output_format`: `audio/wav`,
            `audio/mpeg`, or `audio/L16`.
        '400':
          description: Bad Request - Invalid input data or parameters.
        '401':
          description: Unauthorized - Invalid or missing authentication credentials.
        '403':
          description: Forbidden - You do not have permission to perform this action.
        '404':
          description: Not Found - The requested resource could not be found.
        '500':
          description: Internal Server Error - An unexpected error occurred.
      security:
        - PersoPlatform-APIKey: []
          xi-api-key: []
        - {}
components:
  schemas:
    TextToSpeechRequestBodyRequest:
      type: object
      properties:
        text:
          type: string
          minLength: 1
          description: Text to synthesize into speech.
          maxLength: 5000
        model_id:
          type: string
          minLength: 1
          default: perso_multilingual_v1
        voice_settings:
          type: object
          additionalProperties: {}
          description: >-
            Optional dict of voice tuning parameters (e.g. `stability`,
            `similarity_boost`) compatible with ElevenLabs voice settings.
      required:
        - text
  securitySchemes:
    PersoPlatform-APIKey:
      type: apiKey
      in: header
      name: PersoPlatform-APIKey
    xi-api-key:
      type: apiKey
      in: header
      name: xi-api-key
      description: >-
        Use this header if you want to call the API with an
        ElevenLabs-compatible SDK. Pass your Perso API key as the `xi-api-key`
        header value.

````