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

# Generate speech from text

> API that generates audio from text and accent. Generating audio through this endpoint costs 1 credit for every 30 seconds.

### About Request Data Structure of Webhook

When using 'text\_to\_speech' API, if the 'webhook\_url' is passed in the parameters, we will initiate a POST request to the `webhook_url` when the task succeeds or fails, with the following content:

```python theme={null}
{
    'id': 'string',
    'status': 'string',
    'failed_reason': 'string',
    'video_output': 'string',
}
```

Arguments:

* `id` (string): The unique identifier of the job
* `status` (string): The status of the job. Possible values are `pending`, `in_queue`, `running`, `failed`, `done`
* `failed_reason` (string): The reason of the failure if the job failed
* `video_output` (string): The URL of the video if the job is done

*Note: We might send multiple requests for status changes.*


## OpenAPI

````yaml post /api/text_to_speech/
openapi: 3.0.3
info:
  title: creatify.ai API
  version: 1.0.0
  description: API for creatify.ai
servers: []
security: []
paths:
  /api/text_to_speech/:
    post:
      tags:
        - text_to_speech
      operationId: text_to_speech_create
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TextToSpeechFlow'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/TextToSpeechFlow'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/TextToSpeechFlow'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TextToSpeechFlow'
          description: ''
      security:
        - X-API-ID: []
          X-API-KEY: []
components:
  schemas:
    TextToSpeechFlow:
      type: object
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
        script:
          type: string
          description: Text to be converted to speech
          maxLength: 8000
        accent:
          type: string
          format: uuid
          nullable: true
          description: Accent to be used for the speech
        webhook_url:
          type: string
          format: uri
          nullable: true
          description: Webhook URL for status updates. Default is null.
          maxLength: 200
        output:
          type: string
          readOnly: true
          description: Output audio url
        media_job:
          type: string
          readOnly: true
          nullable: true
        credits_used:
          type: number
          description: Credits used in this API call
          readOnly: true
        duration:
          type: integer
          readOnly: true
          description: Duration of the video in seconds
        is_hidden:
          type: boolean
          readOnly: true
          description: Whether the job is hidden or not
        status:
          type: string
          readOnly: true
        failed_reason:
          type: string
          readOnly: true
          description: Failed reason
        created_at:
          type: string
          format: date-time
          readOnly: true
          title: Created date
        updated_at:
          type: string
          format: date-time
          readOnly: true
          title: Updated date
      required:
        - created_at
        - credits_used
        - duration
        - failed_reason
        - id
        - is_hidden
        - media_job
        - output
        - script
        - status
        - updated_at
  securitySchemes:
    X-API-ID:
      type: apiKey
      in: header
      name: X-API-ID
      description: API ID, from your settings page.
    X-API-KEY:
      type: apiKey
      in: header
      name: X-API-KEY
      description: API Key, from your settings page.

````