Speech

Stream speech in a named voice as raw PCM

Changed on

Render the given text as speech in one of the named voices from GET /v1/voices, streaming the audio while it is generated, so playback can start after the first ~80 ms instead of after the whole clip. The response body is the audio itself: raw 16-bit little-endian PCM, mono, at sample_rate (24 kHz by default), with no header. Each request renders one utterance. The response starts with the first audio, so a request that fails before then gets an ordinary error response with its status code; if generation fails after audio has started, the connection is terminated before the response completes. Closing the connection stops generation.

post/v1/tts/{voice_id}/stream

Request

  • Base URL
    https://api.kalpalabs.ai
  • Auth
    HTTP bearer

Path parameters

voice_idstring required

A named voice id, as listed by GET /v1/voices.

Request body

textstring required

Text to speak; must contain at least one non-whitespace character.

modelstring nullable

Public model id (see GET /v1/models). Omit/null for the default model.

output_format'pcm_s16le'

Encoding of the response body: raw 16-bit little-endian PCM, mono, no header.

sample_rate8000 | 16000 | 22050 | 24000 | 32000 | 44100 | 48000

Output sample rate in Hz.

Example request

{
  "text": "Hey there! How are you doing today?",
  "model": "kalpa-tts-1"
}

Response

The audio as it is generated: raw 16-bit little-endian PCM, mono, at sample_rate.

Changes