---
title: "Stream Text To Speech"
method: POST
path: "/text_to_speech/streaming"
tags: ["Streaming"]
---

# Stream Text To Speech

`POST /text_to_speech/streaming`

Stream synthesised speech as Server-Sent Events (SSE).

Authenticates the caller, checks quota, and delegates synthesis to the versioned
handler registered in ``voice_registry["streaming_text_to_speech"]``.  Concurrency
is enforced per-token via Redis before the handler is invoked.

Args:
    tts_request: TTS parameters (text, voice, model, format, etc.).
    background_tasks: FastAPI background-task queue (passed through to the handler).
    token_service: Injected token validation service.
    _request: Raw FastAPI ``Request`` object used for rate-limiting and ``app.state`` access.
    version: API version extracted from the ``version`` request header.
    x_api_key: Bearer API key from the ``x-api-key`` header.

Returns:
    StreamingResponse: SSE stream of audio chunks.

Raises:
    UsageLimitExceeded: When the token has exhausted its quota.
    TooManyConcurrentRequests: When the per-token concurrency cap is reached.

## Headers

- `X-Api-Key` string

## Request body

- TTSRequest
  - `__dev_toggles` DevToggles — Hidden dev-only flags for disabling external services during concurrency profiling. Accepted under the ``__dev_toggles`` JSON key. Silently ignored outside ENVIRONMENT=dev.
    - `disable_token_validation` boolean
    - `disable_postgresql` boolean
    - `disable_mongodb` boolean
    - `disable_rate_limiter` boolean
    - `disable_concurrency_limiter` boolean
    - `disable_pubsub` boolean
    - `disable_language_detector` boolean
    - `disable_sentence_splitter` boolean
    - `disable_normalizer` boolean
    - `disable_phonemizer` boolean
    - `disable_stp` boolean
    - `disable_xcodec` boolean
    - `disable_transcript_validation` boolean
    - `disable_stp_short_target_standalone` boolean, nullable
  - `model_id` 'async_flash_v1.0' | 'async_flash_v1.5' | 'async_pro_v1.0'
  - `normalize` boolean — Whether to normalize the input text. If False, the input text will be used as is.
  - `experimental_streaming_mode` boolean — Whether to stream audio in experimental mode.
  - `experimental_stp_v2` boolean — Use v2 STP prompt format (pr_speech_start/end). Only has effect when experimental_streaming_mode=True.
  - `transcript` string, required
  - `previous_request_id` string, uuid, nullable — ID returned in the X-Request-Id header of a previous TTS response. When provided, the last sentence of that request is appended AFTER the voice reference, enabling voice continuity across requests. Effective only for STP-based models (async_flash_v1.5, async_pro_v1.0). Silently falls back to the voice reference alone when the entry has expired, is missing, or belongs to a different token / voice / model / experimental_stp_v2 setting.
  - `language` 'en' | 'fr' | 'it' | 'de' | 'es' | 'pt' | 'ar' | 'ru' | 'ro' | 'ja' | 'he' | 'hy' | 'tr' | 'hi' | 'zh' | 'cmn' | 'ur'
  - `lang_detection_mode` 'llm' | 'fasttext'
  - `voice` VoiceIdSpecifier, required
    - `mode` 'id', required
    - `id` string, uuid, required
    - `__experimental_controls` object, nullable
  - `output_format` union — Default is raw / pcm_s16le / 44100 Hz
    - RawOutputFormat
      - `container` 'raw', required
      - `encoding` 'pcm_f32le' | 'pcm_s16le' | 'pcm_mulaw'
      - `sample_rate` integer, required — Sample rate in Hz (e.g., 44100)
      - `bit_rate` integer, nullable
    - WavOutputFormat
      - `container` 'wav', required
      - `encoding` 'pcm_f32le' | 'pcm_s16le'
      - `sample_rate` integer, required
      - `bit_rate` integer, nullable
    - Mp3OutputFormat
      - `container` 'mp3', required
      - `encoding` 'pcm_f32le' | 'pcm_s16le'
      - `bit_rate` integer
      - `sample_rate` integer, required
  - `sentence_splitter_chunk_size` integer, nullable — Number of characters to split the transcript into chunks. None if based on sentences.
  - `duration` number, nullable
  - `stability` integer — TTS's stability.
  - `speed_control` number — TTS's speed control.

## Response `200`

Successful Response

- unknown

## Other responses

- `422` — Validation Error
- `429` — Too Many Requests / Concurrency / QUOTA EXCEEDED

---

[API](https://skmtc.net/async/apis/text-to-speech-api-service.md) · [All operations](https://skmtc.net/async/apis/text-to-speech-api-service/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/async/text-to-speech-api-service/versions/9bfc541b6e9a/schema)
