PlayHT TTS API

Text-to-speech generation jobs.

OpenAPI Specification

play-ht-tts-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: PlayHT TTS API
  description: 'REST API for PlayHT TTS, voice listing, and voice cloning. The v2

    endpoints sit under https://api.play.ht/api/v2. Authentication uses two

    credentials supplied as headers: `AUTHORIZATION` (the secret API key)

    and `X-USER-ID` (the user identifier).

    '
  version: 1.0.0
  contact:
    name: API Evangelist
    email: kin@apievangelist.com
  license:
    name: Proprietary
servers:
- url: https://api.play.ht/api/v2
  description: PlayHT v2 API
security:
- apiKey: []
  userId: []
tags:
- name: TTS
  description: Text-to-speech generation jobs.
paths:
  /tts:
    post:
      tags:
      - TTS
      summary: Stream audio from text
      description: 'Streams the audio bytes for the supplied text in real time using

        PlayHT''s text-in, audio-out API.

        '
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TTSStreamRequest'
      responses:
        '200':
          description: Streamed audio bytes.
          content:
            audio/mpeg:
              schema:
                type: string
                format: binary
            audio/wav:
              schema:
                type: string
                format: binary
  /tts/job:
    post:
      tags:
      - TTS
      summary: Create a batch TTS job
      description: 'Converts one or more input texts into audio asynchronously. Poll the

        job endpoints to retrieve completion status.

        '
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TTSJobRequest'
      responses:
        '201':
          description: Job created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TTSJob'
    get:
      tags:
      - TTS
      summary: Get batch TTS job details
      description: Retrieves batch job information including all child jobs and status.
      responses:
        '200':
          description: Batch job.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TTSJob'
  /tts/job/{jobId}:
    parameters:
    - $ref: '#/components/parameters/JobId'
    get:
      tags:
      - TTS
      summary: Get batch TTS child job by ID
      responses:
        '200':
          description: Child job.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TTSJob'
components:
  schemas:
    TTSJob:
      type: object
      properties:
        id:
          type: string
        status:
          type: string
          enum:
          - queued
          - processing
          - complete
          - failed
        url:
          type: string
          format: uri
        duration:
          type: number
        created:
          type: string
          format: date-time
    TTSStreamRequest:
      type: object
      required:
      - text
      - voice
      properties:
        text:
          type: string
          description: Text to synthesize.
        voice:
          type: string
          description: Voice identifier.
        voice_engine:
          type: string
          description: Voice engine, for example `PlayDialog`, `Play3.0-mini`.
        output_format:
          type: string
          enum:
          - mp3
          - wav
          - ogg
          - flac
          - mulaw
        speed:
          type: number
        quality:
          type: string
          enum:
          - draft
          - low
          - medium
          - high
          - premium
    TTSJobRequest:
      type: object
      required:
      - text
      - voice
      properties:
        text:
          oneOf:
          - type: string
          - type: array
            items:
              type: string
        voice:
          type: string
        voice_engine:
          type: string
        output_format:
          type: string
        speed:
          type: number
        quality:
          type: string
  parameters:
    JobId:
      name: jobId
      in: path
      required: true
      schema:
        type: string
      description: TTS batch job identifier.
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: AUTHORIZATION
      description: Secret API key generated in the PlayHT studio.
    userId:
      type: apiKey
      in: header
      name: X-USER-ID
      description: PlayHT user identifier paired with the API key.