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

# Text to Speech

> 
Converts the provided text to speech audio using the specified voice. 

For best results, we expect you to use Urdu script. To get better pronounciation of English words, use ASCII characters for them. Example "<span dir="rtl" class="urdu">یہ ایک exerted force ہے</span>"


Returns the audio data directly in the response.




## OpenAPI

````yaml post /synthesis/text-to-speech
openapi: 3.1.0
info:
  title: UpliftAI API
  version: 1.0.0
  description: >
    API for UpliftAI messaging, media handling, and text-to-speech capabilities.
    This API enables real-time communication

    with AI assistants, supporting various content types including text, images,
    audio,

    and documents. It provides both synchronous and asynchronous messaging
    capabilities

    with webhook support for real-time updates. The API also supports
    text-to-speech synthesis

    and phrase replacement configuration.
servers:
  - url: https://api.upliftai.org/v1
    description: Version 1 API
security: []
paths:
  /synthesis/text-to-speech:
    post:
      summary: Text to Speech
      description: >

        Converts the provided text to speech audio using the specified voice. 


        For best results, we expect you to use Urdu script. To get better
        pronounciation of English words, use ASCII characters for them. Example
        "<span dir="rtl" class="urdu">یہ ایک exerted force ہے</span>"



        Returns the audio data directly in the response.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TextToSpeechRequest'
      responses:
        '200':
          description: Successful audio synthesis
          content:
            audio/*:
              schema:
                type: string
                format: binary
          headers:
            Content-Type:
              schema:
                type: string
              description: Audio MIME type (e.g., audio/wav)
            x-uplift-ai-audio-duration:
              schema:
                type: integer
              description: Duration of the audio in milliseconds
            x-uplift-ai-encoding:
              schema:
                type: string
              description: Audio encoding format
            x-uplift-ai-sample-rate:
              schema:
                type: integer
              description: Audio sample rate in Hz
            x-uplift-ai-bit-rate:
              schema:
                type: integer
              description: Audio bit rate in kbps
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Rate limit exceeded, please try again later
      security:
        - apiKeyAuth: []
      x-codeSamples:
        - lang: JavaScript
          label: Convert text to speech
          source: "{\n  \"voiceId\": \"v_8eelc901\",\n  \"text\": \"سلام، آپ اِس وقت اوریٹر کی آواز سن رہے\_ہیں۔\",\n  \"outputFormat\": \"MP3_22050_128\",\n}\n"
components:
  schemas:
    TextToSpeechRequest:
      type: object
      required:
        - voiceId
        - text
        - outputFormat
      description: Request for text-to-speech synthesis
      properties:
        voiceId:
          type: string
          description: >-
            Identifier for the voice to use. Options include v_8eelc901
            (Info/Edu), v_kwmp7zxt (Gen Z), v_yypgzenx (Dada Jee), v_30s70t3a
            (Nostalgic News)
          enum:
            - v_8eelc901
            - v_kwmp7zxt
            - v_yypgzenx
            - v_30s70t3a
        text:
          type: string
          maxLength: 2500
          description: The text to synthesize
        outputFormat:
          type: string
          enum:
            - PCM_22050_16
            - WAV_22050_16
            - WAV_22050_32
            - MP3_22050_32
            - MP3_22050_64
            - MP3_22050_128
            - OGG_22050_16
            - ULAW_8000_8
          description: >-
            Format of the output audio. Wav files are usually 10x larger, we
            recommend using MP3 or OGG for best compression results while
            maintaining quality.
        phraseReplacementConfigId:
          type: string
          description: Optional ID of a phrase replacement configuration to apply
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: API key with format "Bearer sk_api_..."

````