> ## Documentation Index
> Fetch the complete documentation index at: https://smallestai-ff1e543d.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Text to Speech

> Stream speech for given text using the Lightning-Large SSE API

## Overview

The Lightning-Large SSE API provides real-time text-to-speech streaming capabilities with high-quality voice synthesis. This API uses Server-Sent Events (SSE) to deliver audio chunks as they're generated, enabling low-latency audio playback without waiting for the entire audio file to process.
For an end-to-end example of how to use the Lightning-Large SSE API, check out [Text to Speech (SSE) Example](https://github.com/smallest-inc/waves-examples/blob/main/lightning_large/http_streaming/http_streaming_api.py)

## When to Use

* **Interactive Applications**: Perfect for chatbots, virtual assistants, and other applications requiring immediate voice responses
* **Long-Form Content**: Efficiently stream audio for articles, stories, or other long-form content without buffering delays
* **Voice User Interfaces**: Create natural-sounding voice interfaces with minimal perceived latency
* **Accessibility Solutions**: Provide real-time audio versions of written content for users with visual impairments

## How It Works

1. **Make a POST Request**: Send your text and voice settings to the API endpoint
2. **Receive Audio Chunks**: The API processes your text and streams audio back as base64-encoded chunks with 1024 byte size
3. **Process the Stream**: Handle the SSE events to decode and play audio chunks sequentially
4. **End of Stream**: The API sends a completion event when all audio has been delivered


## OpenAPI

````yaml POST /waves/v1/lightning-large/stream
openapi: 3.0.1
info:
  title: Text-to-Speech API (Deprecated)
  description: >
    Deprecated API endpoints for Waves text-to-speech models.

    These lightning large and lightning models are no longer recommended for new
    integrations.


    Please use Lightning v2 or Lightning v3.1 instead.
  version: 1.0.0
servers:
  - url: https://api.smallest.ai
    description: Waves API server
security: []
paths:
  /waves/v1/lightning-large/stream:
    post:
      tags:
        - Lightning Large (Deprecated)
      summary: Stream speech from text (Lightning Large)
      description: >-
        Converts provided text to speech using the Lightning Large model with
        streaming response.
      operationId: streamLightningLargeSpeech
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LightningLargeRequest'
      responses:
        '200':
          description: Synthesized speech retrieved successfully.
          content:
            text/event-stream:
              example:
                data: |
                  event: chunk
                  data: <WAV_DATA>
                  done: false
        '400':
          description: Bad request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: InvalidRequest
                message: The 'text' field is required.
        '401':
          description: Unauthorized.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: Unauthorized
                message: Bearer token is missing or invalid.
        '500':
          description: Server error occurred.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: InternalServerError
                message: An unexpected error occurred.
      deprecated: true
      security:
        - bearerAuth: []
components:
  schemas:
    LightningLargeRequest:
      type: object
      required:
        - text
        - voice_id
      properties:
        text:
          type: string
          description: The text to convert to speech.
        voice_id:
          type: string
          description: The voice identifier to use for speech generation.
        sample_rate:
          type: integer
          description: The sample rate for the generated audio.
          minimum: 8000
          maximum: 24000
          default: 24000
        speed:
          type: number
          description: The speed of the generated speech.
          minimum: 0.5
          maximum: 2
          default: 1
        consistency:
          type: number
          description: >-
            This parameter controls word repetition and skipping. Decrease it to
            prevent skipped words, and increase it to prevent repetition.
          minimum: 0
          maximum: 1
          default: 0.5
        similarity:
          type: number
          description: >-
            This parameter controls the similarity between the generated speech
            and the reference audio. Increase it to make the speech more similar
            to the reference audio.
          minimum: 0
          maximum: 1
          default: 0
        enhancement:
          type: number
          description: Enhances speech quality at the cost of increased latency.
          minimum: 0
          maximum: 2
          default: 1
        language:
          type: string
          description: >-
            Language code for text normalization (e.g., how numbers, dates, and
            abbreviations are spelled out). Specify a language code like 'en' or
            'hi' to normalize text according to that language's rules.
          default: en
          enum:
            - en
            - hi
        output_format:
          type: string
          description: The format of the output audio.
          default: pcm
          enum:
            - pcm
            - mp3
            - wav
            - mulaw
        pronunciation_dicts:
          type: array
          items:
            type: string
            description: >-
              The ID of the pronunciation dictionary to use for speech
              generation.
          description: >-
            The IDs of the pronunciation dictionaries to use for speech
            generation.
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Error type.
        message:
          type: string
          description: Error message.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer authentication header of the form `Bearer <api_key>`, where
        <api_key> is your api key.

````