Celý zvuk
Vráti jeden celý WAV. Pre e-mail, súbory, nahrané oznamy.# 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.wavPriebežné vysielanie
Rovnaké telo, delená odpoveď. Prvý zvuk odchádza bez čakania na zvyšok: toto je cesta pre telefonický hovor.# 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, pre živý hovor
Jedno spojenie na hovor. Text dnu, zvukové rámce von, a cancel pre 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 interruptedV rámci procesu
Ak aplikácia, ktorá potrebuje hlas, už beží na Total.js, HTTP nie je v ceste: skopírujte plugin a zavolajte ho.const audio = await PLUGINS.voice.speak({ text: 'Dobrý deň.', lang: 'sk' });
// audio.buffer a complete WAV
// audio.duration seconds
// audio.compute milliseconds of CPU