Streaming synthesis

WSwss://api.lucidweights.ai/v1/tts/stream

Streams audio chunks in real time from incomplete text input. Connect to wss://api.lucidweights.ai/v1/tts/stream.

Authentication

Pass the API key as ?api_key=lw_YOUR_SECRET or send x-api-key as a header.

Request message

Send a JSON text frame over the WebSocket:

FieldTypeDefaultDescription
textstringrequiredText to convert
speakerstringrequiredSpeaker name
languagestringdefaultISO 639-1 language code
output_formatstringpcm_24000Audio format
speedfloat1.0Range 0.1–2.0
expressive_levelinteger30Range 0–100
custom_pronunciationsobject-{"words": {}, "phonemes": {}} per-request overrides
{
  "text": "Hello from Reverie streaming.",
  "speaker": "emily",
  "language": "en",
  "output_format": "pcm_24000",
  "speed": 1,
  "expressive_level": 30
}

Response

Raw audio bytes streamed as binary WebSocket messages. A JSON message {"status": "complete"} is sent at the end.

Example
const ws = new WebSocket(
  "wss://api.lucidweights.ai/v1/tts/stream?api_key=lw_YOUR_SECRET"
);

ws.onopen = () => {
  ws.send(JSON.stringify({
    text: "Streaming synthesis from Reverie.",
    speaker: "emily",
    language: "en",
    output_format: "pcm_24000",
  }));
};

ws.onmessage = (event) => {
  if (typeof event.data === "string") {
    const msg = JSON.parse(event.data);
    if (msg.status === "complete") console.log("done");
    return;
  }
  // event.data is binary audio chunk
};