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

# Text to Speech

> Generate Speech by providing a text input along with a pre trained voice.

## Request

Make a `POST` request to below endpoint and pass the required parameters as a request body.

```curl curl theme={null}
--request POST 'https://modelslab.com/api/v6/voice/text_to_speech' \
```

## Emotion Support

<Note>
  Emotion support is currently only available in English (`en`) language. When emotion is enabled, you can use special tags in your text prompt to add expressive elements to the generated speech.
</Note>

### Available Emotion-Supported Voices

#### Female Voices

* Tara
* Leah
* Jess
* Mia
* Zoe

#### Male Voices

* Leo
* Dan
* Zac

#### Supported Emotion Tags

<Tip>
  The following emotion tags can be added to speech prompts to enhance expressiveness:
</Tip>

| Tag         | Description                                          |
| ----------- | ---------------------------------------------------- |
| `<laugh>`   | Adds a laughing effect                               |
| `<chuckle>` | A soft chuckle for a subtle humorous tone            |
| `<sigh>`    | Expresses disappointment, relief, or tiredness       |
| `<cough>`   | Simulates a short cough                              |
| `<sniffle>` | Mimics a sniffle, indicating sadness or a cold       |
| `<groan>`   | Adds a groaning effect for frustration or discomfort |
| `<yawn>`    | Simulates yawning to express boredom or tiredness    |
| `<gasp>`    | Expresses shock or surprise                          |

## Body

```json json theme={null}
{    
    "key": "your_api_key",
    "prompt":"Build next-generation AI products without worrying about GPUs",
    "language":"american english",
    "voice_id":"madison",
    "speed":1,
    "emotion":false
}
```


## OpenAPI

````yaml POST /voice/text_to_speech
openapi: 3.1.0
info:
  title: ModelsLab Voice API
  description: >-
    A comprehensive API for AI-driven voice and audio generation including
    text-to-speech, voice cloning, music generation, and audio processing
    capabilities
  license:
    name: MIT
  version: 6.0.0
servers:
  - url: https://modelslab.com/api/v6
security: []
paths:
  /voice/text_to_speech:
    post:
      summary: Convert text to speech
      description: Generates audio from text using pre-trained voices
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TextToSpeechRequest'
      responses:
        '200':
          description: Text to speech response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VoiceResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    TextToSpeechRequest:
      type: object
      required:
        - key
        - prompt
        - voice_id
        - language
      properties:
        key:
          type: string
          description: API key for authentication
        prompt:
          type: string
          description: Text prompt describing audio to be generate Max len `2500` chars.
        voice_id:
          type: string
          description: >-
            ID of trained voice [Find Pretrained Voices
            Here](https://modelslab.com/trained-voice-lists)
        language:
          type: string
          enum:
            - american english
            - british english
            - spanish
            - japanese
            - mandarin chinese
            - french
            - brazilian portuguese
            - hindi
            - italian
          default: english
          description: Language for the voice
        speed:
          type: number
          default: 1
          description: Playback speed of generated audio
        emotion:
          type: boolean
          default: false
          description: Enable emotion support (English only)
        temp:
          type: boolean
          default: false
          description: Use temporary links valid for 24 hours
        webhook:
          type: string
          format: uri
          description: URL to receive POST notification upon completion
        track_id:
          type: integer
          description: ID for webhook identification
    VoiceResponse:
      type: object
      properties:
        status:
          type: string
          enum:
            - success
            - processing
            - error
          description: Status of the voice generation
        generationTime:
          type: number
          description: Time taken to generate the audio in seconds
        id:
          type: integer
          description: Unique identifier for the voice generation
        output:
          type: array
          items:
            type: string
            format: uri
          description: Array of generated audio URLs
        proxy_links:
          type: array
          items:
            type: string
            format: uri
          description: Array of proxy audio URLs
        future_links:
          type: array
          items:
            type: string
            format: uri
          description: Array of future audio URLs for queued requests
        links:
          type: array
          items:
            type: string
            format: uri
          description: Array of audio URLs (voice cover response)
        meta:
          type: object
          description: Metadata about the audio generation including all parameters used
        eta:
          type: integer
          description: Estimated time for completion in seconds (processing status)
        message:
          type: string
          description: Status message or additional information
        tip:
          type: string
          description: Additional information or tips for the user
        fetch_result:
          type: string
          format: uri
          description: URL to fetch the result when processing
        audio_time:
          type: number
          description: Duration of the generated audio in seconds
    Error:
      type: object
      required:
        - status
        - message
      properties:
        status:
          type: string
          enum:
            - error
        message:
          type: string
          description: Error message description

````