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

# Text To Speech

> Synthesize speech from text with voice and gender customization, plus optional webhook callback.  
Give priority to the sample audio first, then to the voice ID, and lastly to gender.



## OpenAPI

````yaml POST /v1/TextToSpeech
openapi: 3.1.0
info:
  title: Musicgpt API
  version: 1.0.0
  description: API for retrieving conversion details by ID.
servers:
  - url: https://api.musicgpt.com/api/public
    description: Production server
security: []
paths:
  /v1/TextToSpeech:
    post:
      summary: Convert text to speech using a specified voice
      description: >-
        Synthesize speech from text with voice and gender customization, plus
        optional webhook callback.  

        Give priority to the sample audio first, then to the voice ID, and
        lastly to gender.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                text:
                  type: string
                  description: Text to convert to speech
                voice_id:
                  type: string
                  description: Voice model ID
                gender:
                  type: string
                  description: Gender preference for the voice (e.g., "male", "female")
                sample_audio_url:
                  type: string
                  description: >-
                    An audio URL containing a voice sample of the target speaker
                    without music or overlapping voices. Recommended over
                    voice_id for better output quality.
                webhook_url:
                  type: string
                  description: Callback URL for async processing
              required:
                - text
              anyOf:
                - required:
                    - sample_audio_url
                - required:
                    - voice_id
      responses:
        '200':
          description: Successfully initiated TTS conversion
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  task_id:
                    type: string
                  conversion_id:
                    type: string
                  eta:
                    type: integer
                example:
                  success: true
                  task_id: 72eed5b0-8652-4bb4-9a95-eb0ad4850f12
                  conversion_id: 648a6823-b2a4-47b3-801e-f452c567ae6f
                  eta: 19
        '402':
          description: Payment Required
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                    example: Insufficient credit balance
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                    example: 'Missing required field: text'
        '500':
          description: Server Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                    example: Internal Server Error
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization

````