Complete audio
Returns one whole WAV. For email, files, recorded announcements.# POST /api/speak/ -> audio/wav
curl -X POST http://127.0.0.1:8010/api/speak/ \
-H 'Content-Type: application/json' \
-H 'X-Api-Key: YOUR_KEY' \
-d '{"text":"Dobrý deň.","lang":"sk","voice":"F1"}' \
--output speech.wavStreaming
Same body, chunked response. The first audio leaves without waiting for the rest: this is the path for a phone call.# POST /api/stream/ -> chunked audio/wav
curl -N -X POST http://127.0.0.1:8010/api/stream/ \
-H 'Content-Type: application/json' \
-d '{"text":"...","lang":"sk","first":45,"steps":4}'Socket, for a live call
One connection per call. Text in, audio frames out, and cancel for barge-in.// ws://127.0.0.1:8010/api/socket/
ws.send(JSON.stringify({ type: 'speak', id: 'call-42', text: '...', lang: 'sk' }));
// <- { type:'chunk', index, duration } then the binary frame
// <- { type:'end', first, total, segments }
ws.send(JSON.stringify({ type: 'cancel' })); // the caller interruptedInside the process
If the application that needs speech is already Total.js, there is no HTTP in the way: copy the plugin and call it.const audio = await PLUGINS.voice.speak({ text: 'Dobrý deň.', lang: 'sk' });
// audio.buffer a complete WAV
// audio.duration seconds
// audio.compute milliseconds of CPU