Skip to main content
TTSClient opens a WebSocket to /ws/tts, sends your text, and hands you audio chunks as they are generated. In JavaScript, synthesize() returns a promise that resolves when the server has sent all the audio and rejects with a LokutorError if the server returns an error or the stream stalls.

Basic usage

Node.js 22 or later.

Options

The Python client sends speed and steps on every request (defaults 1.05 and 24); they have no effect.

Completion and errors (JavaScript)

  • The promise resolves when the server signals the end of the stream (EOS).
  • It rejects with a LokutorError carrying the server’s code (for example validation.invalid_voice or tts.synthesis_failed) when the server sends an error frame.
  • It rejects with internal.timeout when no audio arrives within 30 seconds, or no further chunk within 15 seconds.
  • It rejects if the socket closes before the end of the stream, unless audio had arrived and the close was clean.
Each call opens its own WebSocket. To send many short requests over one connection, use the WebSocket API directly.

Audio format