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 (save to file)
- Browser
- Python
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
LokutorErrorcarrying the server’s code (for examplevalidation.invalid_voiceortts.synthesis_failed) when the server sends an error frame. - It rejects with
internal.timeoutwhen 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.