# Text to Speech with Word Timestamps

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /text_to_speech/with_timestamps:
    post:
      summary: Text to Speech with Word Timestamps
      deprecated: false
      description: >-
        Generates speech using provided text and voice of your choice and
        returns audio and word timestamps.
      tags:
        - API Reference/Text-to-Speech
      parameters:
        - name: x-api-key
          in: header
          description: ''
          required: true
          example: <api-key>
          schema:
            type: string
        - name: version
          in: header
          description: ''
          required: true
          example: v1
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                model_id:
                  type: string
                  description: Model id
                  enum:
                    - async_flash_v1.0
                  x-apidog-enum:
                    - value: async_flash_v1.0
                      name: Async Flash v1.0
                      description: >-
                        Fastest model, designed for real-time and low-latency
                        applications
                transcript:
                  type: string
                  description: Text to convert to the speech
                voice:
                  type: object
                  properties:
                    mode:
                      type: string
                      enum:
                        - id
                      x-apidog-enum:
                        - value: id
                          name: ''
                          description: ''
                    id:
                      type: string
                      description: Voice id
                  required:
                    - mode
                    - id
                  x-apidog-orders:
                    - mode
                    - id
                  description: Voice to use while make speech
                output_format:
                  type: object
                  properties:
                    container:
                      type: string
                      description: Output audio format
                      enum:
                        - raw
                        - mp3
                        - wav
                      x-apidog-enum:
                        - value: raw
                          name: ''
                          description: ''
                        - value: mp3
                          name: ''
                          description: ''
                        - value: wav
                          name: ''
                          description: ''
                    encoding:
                      type: string
                      description: Output audio encoding. Ignore if mp3
                      enum:
                        - pcm_f32le
                        - pcm_s16le
                      x-apidog-enum:
                        - value: pcm_f32le
                          name: ''
                          description: ''
                        - value: pcm_s16le
                          name: ''
                          description: ''
                      default: pcm_s16le
                    sample_rate:
                      type: integer
                      minimum: 8000
                      maximum: 48000
                      description: Output audio sample rate
                    bit_rate:
                      type: integer
                      default: 192000
                      minimum: 32000
                      maximum: 320000
                      description: Output audio bit rate. Use only with mp3
                  required:
                    - container
                    - sample_rate
                  x-apidog-orders:
                    - container
                    - encoding
                    - sample_rate
                    - bit_rate
                  description: Output configurations
                language:
                  type: string
                  description: >-
                    Force to synthesize speech in the specified language (ISO
                    639-1), regardless of the detected language of the input
                    text.
                  enum:
                    - en
                    - fr
                    - es
                    - de
                    - it
                    - pt
                    - ar
                    - ru
                    - ro
                    - ja
                    - he
                    - hy
                    - tr
                    - hi
                    - zh
                  x-apidog-enum:
                    - value: en
                      name: English
                      description: ''
                    - value: fr
                      name: French
                      description: ''
                    - value: es
                      name: Spanish
                      description: ''
                    - value: de
                      name: German
                      description: ''
                    - value: it
                      name: Italian
                      description: ''
                    - value: pt
                      name: Portuguese
                      description: ''
                    - value: ar
                      name: Arabic
                      description: ''
                    - value: ru
                      name: Russian
                      description: ''
                    - value: ro
                      name: Romanian
                      description: ''
                    - value: ja
                      name: Japanese
                      description: ''
                    - value: he
                      name: Hebrew
                      description: ''
                    - value: hy
                      name: Armenian
                      description: ''
                    - value: tr
                      name: Turkish
                      description: ''
                    - value: hi
                      name: Hindi
                      description: ''
                    - value: zh
                      name: Chinese
                      description: ''
                speed_control:
                  type: number
                  minimum: 0.7
                  maximum: 2
                  title: (experimental)
                  description: Adjusts the speaking speed of the synthesized voice.
                stability:
                  type: integer
                  minimum: 0
                  maximum: 100
                  title: (experimental)
                  description: >-
                    Adjusts how stable or expressive the synthesized voice
                    sounds.
              required:
                - model_id
                - transcript
                - voice
                - output_format
              x-apidog-orders:
                - model_id
                - transcript
                - voice
                - output_format
                - language
                - speed_control
                - stability
              x-apidog-refs: {}
            example:
              model_id: async_flash_v1.0
              transcript: Welcome to Async
              voice:
                mode: id
                id: e0f39dc4-f691-4e78-bba5-5c636692cc04
              output_format:
                container: raw
                encoding: pcm_f32le
                sample_rate: 44100
      responses:
        '200':
          openapi: 3.0.3
          info:
            title: TTS Streaming API – Error Model
            version: 1.0.0
          paths:
            /v1/tts/stream:
              post:
                summary: Stream speech audio
                responses:
                  '400':
                    $ref: '#/components/responses/VOICE_FIELD_UPDATE_NOT_ALLOWED'
                  '401':
                    $ref: '#/components/responses/INVALID_API_KEY'
                  '404':
                    $ref: '#/components/responses/VOICE_NOT_FOUND'
                  '429':
                    $ref: '#/components/responses/TOO_MANY_CONCURRENT_REQUESTS'
                  '500':
                    $ref: '#/components/responses/INTERNAL_SERVER_ERROR'
          components:
            schemas:
              ErrorResponse:
                type: object
                required:
                  - message
                properties:
                  error_code:
                    type: string
                  message:
                    type: string
                  extra:
                    type: object
                    additionalProperties: true
              InternalServerError:
                allOf:
                  - $ref: '#/components/schemas/ErrorResponse'
                  - type: object
                    properties:
                      method:
                        type: string
                      url:
                        type: string
                        format: uri
                      detail:
                        type: string
            responses:
              TOO_MANY_CONCURRENT_REQUESTS:
                description: Parallel request limit exceeded
                content:
                  application/json:
                    schema:
                      $ref: '#/components/schemas/ErrorResponse'
                    example:
                      error_code: TOO_MANY_CONCURRENT_REQUESTS
                      message: Too many concurrent requests
                      extra:
                        limit: 5
                        current: 7
              RATE_LIMIT_EXCEEDED:
                description: Per‑minute request cap reached
                content:
                  application/json:
                    schema:
                      $ref: '#/components/schemas/ErrorResponse'
                    example:
                      error_code: RATE_LIMIT_EXCEEDED
                      message: Rate limit exceeded. Please try again later.
                      extra:
                        limit: 120
                        retry_after_ms: 8500
              INVALID_API_KEY:
                description: Invalid or expired key
                content:
                  application/json:
                    schema:
                      $ref: '#/components/schemas/ErrorResponse'
                    example:
                      error_code: INVALID_API_KEY
                      message: Invalid or expired API key.
                      extra:
                        api_key: sk_test_...
              TOKEN_NOT_FOUND:
                description: Supplied token ID does not exist
                content:
                  application/json:
                    schema:
                      $ref: '#/components/schemas/ErrorResponse'
              USAGE_LIMIT_EXCEEDED:
                description: Monthly quota exhausted
                content:
                  application/json:
                    schema:
                      $ref: '#/components/schemas/ErrorResponse'
              VOICE_NOT_FOUND:
                description: Requested voice ID is unknown
                content:
                  application/json:
                    schema:
                      $ref: '#/components/schemas/ErrorResponse'
              VOICE_FIELD_UPDATE_NOT_ALLOWED:
                description: Immutable voice field
                content:
                  application/json:
                    schema:
                      $ref: '#/components/schemas/ErrorResponse'
              VERSION_NOT_FOUND:
                description: Unknown API version
                content:
                  application/json:
                    schema:
                      $ref: '#/components/schemas/ErrorResponse'
              INVALID_LANGUAGE:
                description: Language code not supported
                content:
                  application/json:
                    schema:
                      $ref: '#/components/schemas/ErrorResponse'
              FORMAT_NOT_RECOGNIZED:
                description: Unsupported audio format
                content:
                  application/json:
                    schema:
                      $ref: '#/components/schemas/ErrorResponse'
              INTERNAL_SERVER_ERROR:
                description: Unhandled server‑side exception
                content:
                  application/json:
                    schema:
                      $ref: '#/components/schemas/InternalServerError'
                    example:
                      message: Oops! Internal server error occurred.
                      method: POST
                      url: /v1/tts/stream
                      detail: 'Error: Traceback #42'
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  audio_base64:
                    type: string
                    description: Audio file content base64 encoded
                  alignment:
                    type: object
                    properties:
                      words:
                        type: array
                        items:
                          type: string
                      word_start_times_milliseconds:
                        type: array
                        items:
                          type: number
                      word_end_times_milliseconds:
                        type: array
                        items:
                          type: number
                    x-apidog-orders:
                      - words
                      - word_start_times_milliseconds
                      - word_end_times_milliseconds
                    required:
                      - words
                      - word_end_times_milliseconds
                      - word_start_times_milliseconds
                x-apidog-orders:
                  - audio_base64
                  - alignment
                required:
                  - audio_base64
                  - alignment
              example:
                audio_base64: ...
                alignment:
                  words:
                    - Welcome
                    - to
                    - Async
                  word_start_times_milliseconds:
                    - 0
                    - 871
                    - 923
                  word_end_times_milliseconds:
                    - 871
                    - 900
                    - 1637
          headers: {}
          x-apidog-name: Success
        '400':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: object
                    properties:
                      error_code:
                        type: string
                      message:
                        type: string
                    required:
                      - error_code
                      - message
                    x-apidog-orders:
                      - error_code
                      - message
                required:
                  - detail
                x-apidog-orders:
                  - detail
              example:
                detail:
                  error_code: INVALID_LANGUAGE
                  message: Language code 'xx' is not supported.
          headers: {}
          x-apidog-name: INVALID_LANGUAGE
        '401':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: object
                    properties:
                      error_code:
                        type: string
                      message:
                        type: string
                      extra:
                        type: object
                        properties:
                          api_key:
                            type: string
                        x-apidog-orders:
                          - api_key
                    required:
                      - error_code
                      - message
                    x-apidog-orders:
                      - error_code
                      - message
                      - extra
                required:
                  - detail
                x-apidog-orders:
                  - detail
              example:
                detail:
                  error_code: INVALID_API_KEY
                  message: Invalid or expired API key.
                  extra:
                    api_key: sk_33...
          headers: {}
          x-apidog-name: INVALID_API_KEY
        '404':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: object
                    properties:
                      error_code:
                        type: string
                      message:
                        type: string
                      extra:
                        type: object
                        properties:
                          voice_id:
                            type: string
                        x-apidog-orders:
                          - voice_id
                    required:
                      - error_code
                      - message
                    x-apidog-orders:
                      - error_code
                      - message
                      - extra
                required:
                  - detail
                x-apidog-orders:
                  - detail
              example:
                detail:
                  error_code: VOICE_NOT_FOUND
                  message: Requested voice with ID 17c7… not found.
                  extra:
                    voice_id: 17c7…
          headers: {}
          x-apidog-name: VOICE_NOT_FOUND
        '429':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: object
                    properties:
                      error_code:
                        type: string
                      message:
                        type: string
                      extra:
                        type: object
                        properties:
                          limit:
                            type: integer
                          current:
                            type: integer
                        x-apidog-orders:
                          - limit
                          - current
                    required:
                      - error_code
                      - message
                    x-apidog-orders:
                      - error_code
                      - message
                      - extra
                required:
                  - detail
                x-apidog-orders:
                  - detail
              example:
                detail:
                  error_code: TOO_MANY_CONCURRENT_REQUESTS
                  message: Too many concurrent requests
                  extra:
                    limit: 5
                    current: 7
          headers: {}
          x-apidog-name: TOO_MANY_CONCURRENT_REQUESTS
        '500':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  method:
                    type: string
                  url:
                    type: string
                  detail:
                    type: string
                required:
                  - message
                  - method
                  - url
                  - detail
                x-apidog-orders:
                  - message
                  - method
                  - url
                  - detail
              example:
                message: Oops! Internal server error occurred.
                method: POST
                url: /v1/tts/stream
                detail: 'Error: Traceback #42'
          headers: {}
          x-apidog-name: Server Error
        x-429:RATE_LIMIT_EXCEEDED:
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: object
                    properties:
                      error_code:
                        type: string
                      message:
                        type: string
                      extra:
                        type: object
                        properties:
                          limit:
                            type: integer
                          retry_after_ms:
                            type: integer
                        x-apidog-orders:
                          - limit
                          - retry_after_ms
                    required:
                      - error_code
                      - message
                    x-apidog-orders:
                      - error_code
                      - message
                      - extra
                required:
                  - detail
                x-apidog-orders:
                  - detail
              example:
                detail:
                  error_code: RATE_LIMIT_EXCEEDED
                  message: Rate limit exceeded. Please try again later.
                  extra:
                    limit: 120
                    retry_after_ms: 8500
          headers: {}
          x-apidog-name: RATE_LIMIT_EXCEEDED
        x-429:USAGE_LIMIT_EXCEEDED:
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: object
                    properties:
                      error_code:
                        type: string
                      message:
                        type: string
                      extra:
                        type: object
                        properties:
                          limit:
                            type: integer
                          current:
                            type: integer
                        x-apidog-orders:
                          - limit
                          - current
                    required:
                      - error_code
                      - message
                    x-apidog-orders:
                      - error_code
                      - message
                      - extra
                required:
                  - detail
                x-apidog-orders:
                  - detail
              example:
                detail:
                  error_code: USAGE_LIMIT_EXCEEDED
                  message: Quota exceeded. Please upgrade your plan or try later.
                  extra:
                    limit: 1000000
                    current: 1250000
          headers: {}
          x-apidog-name: USAGE_LIMIT_EXCEEDED
        x-404:VERSION_NOT_FOUND:
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: object
                    properties:
                      error_code:
                        type: string
                      message:
                        type: string
                    required:
                      - error_code
                      - message
                    x-apidog-orders:
                      - error_code
                      - message
                required:
                  - detail
                x-apidog-orders:
                  - detail
              example:
                detail:
                  error_code: VERSION_NOT_FOUND
                  message: API version v0.9 not found.
          headers: {}
          x-apidog-name: VERSION_NOT_FOUND
        x-400:FORMAT_NOT_RECOGNIZED:
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: object
                    properties:
                      error_code:
                        type: string
                      message:
                        type: string
                    required:
                      - error_code
                      - message
                    x-apidog-orders:
                      - error_code
                      - message
                required:
                  - detail
                x-apidog-orders:
                  - detail
              example:
                detail:
                  error_code: FORMAT_NOT_RECOGNIZED
                  message: Audio format not recognized or unsupported.
          headers: {}
          x-apidog-name: FORMAT_NOT_RECOGNIZED
      security: []
      x-apidog-folder: API Reference/Text-to-Speech
      x-apidog-status: released
      x-run-in-apidog: https://app.apidog.com/web/project/909580/apis/api-18761064-run
components:
  schemas: {}
  securitySchemes: {}
servers: []
security: []

```
