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

# Text To Speech

> Generate a text-to-speech audio file based on the provided text input and speaker description.

<Info>
  The default Gateway used in this guide is the public
  [Livepeer.cloud](https://www.livepeer.cloud/) Gateway. It is free to use but
  not intended for production-ready applications. For production-ready
  applications, consider using the [Livepeer Studio](https://livepeer.studio/)
  Gateway, which requires an API token. Alternatively, you can set up your own
  Gateway node or partner with one via the `ai-video` channel on
  [Discord](https://discord.gg/livepeer).
</Info>

<Note>
  Please note that the exact parameters, default values, and responses may vary
  between models. For more information on model-specific parameters, please
  refer to the respective model documentation available in the [text-to-speech
  pipeline](/ai/pipelines/text-to-speech). Not all parameters might be available
  for a given model.
</Note>


## OpenAPI

````yaml post /text-to-speech
openapi: 3.1.0
info:
  title: Livepeer AI Runner
  description: An application to run AI pipelines
  version: 0.0.0
servers:
  - url: https://dream-gateway.livepeer.cloud
    description: Livepeer Cloud Community Gateway
  - url: https://livepeer.studio/api/beta/generate
    description: Livepeer Studio Gateway
security: []
paths:
  /text-to-speech:
    post:
      tags:
        - generate
      summary: Text To Speech
      description: >-
        Generate a text-to-speech audio file based on the provided text input
        and speaker description.
      operationId: genTextToSpeech
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TextToSpeechParams'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AudioResponse'
                x-speakeasy-name-override: data
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
      security:
        - HTTPBearer: []
components:
  schemas:
    TextToSpeechParams:
      properties:
        model_id:
          type: string
          title: Model Id
          description: Hugging Face model ID used for text to speech generation.
          default: ''
        text:
          type: string
          title: Text
          description: Text input for speech generation.
          default: ''
        description:
          type: string
          title: Description
          description: Description of speaker to steer text to speech generation.
          default: >-
            A male speaker delivers a slightly expressive and animated speech
            with a moderate speed and pitch.
      type: object
      title: TextToSpeechParams
    AudioResponse:
      properties:
        audio:
          allOf:
            - $ref: '#/components/schemas/MediaURL'
          description: The generated audio.
      type: object
      required:
        - audio
      title: AudioResponse
      description: Response model for audio generation.
    HTTPError:
      properties:
        detail:
          allOf:
            - $ref: '#/components/schemas/APIError'
          description: Detailed error information.
      type: object
      required:
        - detail
      title: HTTPError
      description: HTTP error response model.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    MediaURL:
      properties:
        url:
          type: string
          title: Url
          description: The URL where the media can be accessed.
      type: object
      required:
        - url
      title: MediaURL
      description: A URL from which media can be accessed.
    APIError:
      properties:
        msg:
          type: string
          title: Msg
          description: The error message.
      type: object
      required:
        - msg
      title: APIError
      description: API error response model.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````