> ## 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.

# Stream Text to Speech

> Convert text to speech with streaming response for real-time playback.

## 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`).

```
POST /v1/text-to-speech/{voice_id}/stream
```

## Request Parameters

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

## Query Parameters

| Parameter | Required | Description |
|-----------|----------|-------------|
| `output_format` | Yes | Audio format for streaming. Default: `wav_24000` (see formats below) |

## How It Works

Audio chunks are streamed as they are generated, enabling:
- Lower latency for first audio
- Real-time playback during generation
- Reduced memory usage for long text

## Example

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

```bash
curl -X POST "https://platform.perso.ai/api/speech/v1/text-to-speech/{voice_id}/stream?output_format=mp3_44100_192"   -H "PersoPlatform-APIKey: <your-api-key>"   -H "Content-Type: application/json"   -H "Accept: */*"   -d '{"text": "Hello, this is a streaming test."}'   --output audio.mp3
```




## OpenAPI

````yaml /specs/openapi-speech.json post /api/speech/v1/text-to-speech/{voice_id}/stream
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}/stream:
    post:
      tags:
        - Speech
      summary: Stream Text to Speech
      description: >
        Convert text to speech with streaming response for real-time playback.


        ## 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`).


        ```

        POST /v1/text-to-speech/{voice_id}/stream

        ```


        ## Request Parameters


        | Parameter | Required | Description |

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

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

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


        ## Query Parameters


        | Parameter | Required | Description |

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

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


        ## How It Works


        Audio chunks are streamed as they are generated, enabling:

        - Lower latency for first audio

        - Real-time playback during generation

        - Reduced memory usage for long text


        ## Example


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


        ```bash

        curl -X POST
        "https://platform.perso.ai/api/speech/v1/text-to-speech/{voice_id}/stream?output_format=mp3_44100_192"  
        -H "PersoPlatform-APIKey: <your-api-key>"   -H "Content-Type:
        application/json"   -H "Accept: */*"   -d '{"text": "Hello, this is a
        streaming test."}'   --output audio.mp3

        ```
      operationId: speech_v1_text_to_speech_stream_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/TextToSpeechStreamRequestBodyRequest'
            examples:
              TextToSpeechStreamRequest:
                value:
                  text: Hello, this is a streaming text to speech test.
                  model_id: perso_multilingual_v1
        required: true
      responses:
        '200':
          content:
            '*/*':
              schema:
                type: string
                format: binary
          description: >-
            Streaming 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:
    TextToSpeechStreamRequestBodyRequest:
      type: object
      properties:
        text:
          type: string
          minLength: 1
          description: Text to synthesize and stream as 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.

````