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

# Voice Cloning

> Generate audio from text by cloning a provided audio URL or a selected voice ID.

## Request

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

> [!NOTE]
>
> `init_audio` is required for voice cloning. You can also pass `voice_id` to select a voice from the available voice list.

```curl curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
--request POST 'https://modelslab.com/api/v6/voice/text_to_audio' \
```

## Body

```json json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "key": "your_api_key", 
  "prompt":"Narrative voices capable of pronouncing terminologies & acronyms in training and ai learning materials.", 
  "init_audio":"https://assets.modelslab.ai/generations/5c3eef10-0eb4-4db8-8b12-fc4eedbf30b9.mp3", 
  "voice_id": "your_voice_id",
  "language":"english", 
  "webhook": null, 
  "track_id": null
}
```

## Drama 3

Pass `"model_id": "drama-3"` to generate with Drama 3. It detects the spoken language itself, so `language`, `emotion` and `speed` are ignored. The reference clip must be at least 3 seconds long, and you can pass its transcript as `reference_text` for a closer match.

```json json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "key": "your_api_key",
  "model_id": "drama-3",
  "prompt": "Hello! This is a test of the Drama three audio model.",
  "init_audio": "https://assets.modelslab.ai/generations/5c3eef10-0eb4-4db8-8b12-fc4eedbf30b9.mp3",
  "language": "english",
  "temperature": 1.0,
  "top_p": 0.9,
  "top_k": 30,
  "max_new_tokens": 1024,
  "seed": 123,
  "webhook": null,
  "track_id": null
}
```


## OpenAPI

````yaml POST /voice/text_to_audio
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_audio:
    post:
      summary: Generate audio from text with voice cloning
      description: Generates audio from text using voice cloning with audio URL or voice ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TextToAudioRequest'
      responses:
        '200':
          description: Text to audio response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VoiceResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    TextToAudioRequest:
      type: object
      required:
        - key
        - prompt
        - init_audio
      properties:
        key:
          type: string
          description: API key for authentication
        prompt:
          type: string
          description: Text prompt describing audio to be generated
        init_audio:
          type: string
          format: uri
          description: Valid URL pointing to audio file for voice cloning (4-30 seconds)
        voice_id:
          type: string
          description: >-
            ID of voice from available list [Find Voice IDs
            Here](https://modelslab.com/voice-lists)
        language:
          type: string
          enum:
            - arabic
            - assamese
            - bengali
            - brazilian portuguese
            - chinese
            - czech
            - danish
            - dutch
            - english
            - finnish
            - french
            - german
            - greek
            - gujarati
            - hebrew
            - hindi
            - hungarian
            - indonesian
            - italian
            - japanese
            - kannada
            - korean
            - maithili
            - malay
            - malayalam
            - marathi
            - min nan chinese
            - nepali
            - odia
            - persian
            - polish
            - punjabi
            - russian
            - sindhi
            - sinhala
            - slovak
            - spanish
            - swahili
            - swedish
            - tamil
            - telugu
            - thai
            - turkish
            - ukrainian
            - urdu
            - vietnamese
            - welsh
            - yue chinese
          default: english
          description: Language for the voice
        speed:
          type: number
          default: 1
          description: Playback speed of generated audio
        base64:
          type: boolean
          default: false
          description: Whether input audio is in base64 format
        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
        model_id:
          type: string
          enum:
            - drama-3
          description: >-
            Voice cloning model to use. Leave it out to use the default model.
            `drama-3` detects the spoken language itself, so `language`,
            `emotion` and `speed` are ignored, and the reference clip must be at
            least 3 seconds long.
        reference_text:
          type: string
          description: >-
            Drama 3 only. Transcript of the reference clip (`init_audio` or the
            voice's clip). Optional, but improves how closely the output matches
            the voice.
        temperature:
          type: number
          minimum: 0
          maximum: 2
          default: 1
          description: >-
            Drama 3 only. Sampling temperature; higher values give more varied
            delivery.
        top_p:
          type: number
          minimum: 0
          maximum: 1
          default: 0.9
          description: Drama 3 only. Nucleus sampling threshold.
        top_k:
          type: integer
          minimum: 1
          maximum: 100
          default: 30
          description: >-
            Drama 3 only. Number of most likely tokens sampled from at each
            step.
        max_new_tokens:
          type: integer
          minimum: 1
          maximum: 2048
          default: 1024
          description: >-
            Drama 3 only. Maximum number of audio tokens to generate; caps the
            output length.
        seed:
          type: integer
          minimum: 0
          description: >-
            Drama 3 only. Seed for reproducible output. A random seed is used
            when omitted.
    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

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.