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

# Generate Text to Speech Route



## OpenAPI

````yaml /api-reference/openapi.json post /v1/jobs/text-to-speech
openapi: 3.0.1
info:
  title: Hamsa API
  description: Trying out our transcription and media-to-text APIs
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.tryhamsa.com
security: []
paths:
  /v1/jobs/text-to-speech:
    post:
      summary: Initiate a text to speech job
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TTSRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TTSResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorSchema'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorSchema'
        '500':
          description: Server Side Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorSchema'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    TTSRequest:
      type: object
      properties:
        voiceId:
          type: string
          description: >-
            The voice id you wish to use. If you are using a cloned voice, you
            need to preload it first using [preload cloned TTS voice
            API](/api-reference/endpoint/preload-cloned-tts-voice)
        text:
          type: string
          example: أهلاً و سهلاً بكم في همسة!
          description: The text you want to convert to speech.
        webhookUrl:
          type: string
          format: uri
          description: The webhook url to which the TTS job result will be sent.
        webhookAuth:
          $ref: '#/components/schemas/ExternalWebhookAuthScheme'
    TTSResponse:
      type: object
      properties:
        success:
          type: boolean
          default: false
        message:
          type: string
          default: success
        data:
          type: object
          properties:
            id:
              type: string
            title:
              type: string
            type:
              type: string
              enum:
                - AI_CONTENT
                - TRANSCRIPTION
                - TTS
                - TRANSLATION
            mediaUrl:
              type: string
              format: uri
            webhookUrl:
              type: string
              format: uri
            model:
              type: string
            status:
              type: string
              enum:
                - PENDING
                - COMPLETED
                - FAILED
            jobResponse:
              type: object
              properties:
                text:
                  type: string
                ttsMediaFile:
                  type: string
                  format: uri
            totalCost:
              type: number
            apiKeyId:
              type: string
            userId:
              type: string
            ttsVoiceId:
              type: string
            createdAt:
              type: string
              format: date-time
            updatedAt:
              type: string
              format: date-time
    ErrorSchema:
      type: object
      properties:
        code:
          type: integer
        message:
          type: string
    ExternalWebhookAuthScheme:
      type: object
      description: >-
        Authorization header to be sent in this format: `Authorization:
        [authKey] [authSecret]`
      properties:
        authKey:
          type: string
          example: Token
          nullable: true
        authSecret:
          type: string
          example: Secret
          nullable: true
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Pass the API key in the Authorization header, You need to put Token
        keyword before the API key. e.g. 'Authorization: Token <api-key>'

````