For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
CommunitySign Up
HomeGuidesVerbsAPI ReferenceSelf-HostingClient SDKsTutorialsChangelog
HomeGuidesVerbsAPI ReferenceSelf-HostingClient SDKsTutorialsChangelog
    • Introduction
  • REST Call Control
  • REST Platform Management
  • Webhooks
    • GETNew Call
    • POSTNew Call
    • POSTClient Authentication
    • POSTNew Client Tool Request
  • Websocket API
      • Overview
      • session:new
      • session:redirect
      • session:reconnect
      • call:status
      • verb:hook
      • verb:status
      • llm:event
      • llm:tool-call
      • tts:tokens-result
      • tts:streaming-event
      • dial:confirm
      • ack
      • command
      • llm:tool-output
      • llm:update
      • tts:tokens
      • tts:flush
      • tts:clear
      • WSScallControl
LogoLogo
CommunitySign Up
Websocket APICall Control

tts:flush

Was this page helpful?
Edit this page
Previous

tts:clear

Next
Built with

websocket server => jambonz

An tts:flush message is sent by the application to jambonz to indicate that the speech synthesizer should be notified to generate audio for the tokens that have been sent. The application should periodically call tts:flush.

The snippet of example code below, written using @jambonz/node-client-ws shows how an application streaming tokens from Anthropic could call tts:flush at the end of each message streamed by Anthropic.

1 const stream = await client.messages.create({
2 model: ANTHROPIC_MODEL,
3 max_tokens: 1024,
4 messages: session.locals.messages,
5 stream: true
6 });
7
8 for await (const messageStreamEvent of stream) {
9 if (messageStreamEvent.delta?.text) {
10 const tokens = messageStreamEvent.delta.text;
11 session.sendTtsTokens(tokens)
12 .catch((err) => logger.error({err}, 'error sending TTS tokens'));
13 }
14 else if (messageStreamEvent.type === 'message_stop') {
15 session.flushTtsTokens();
16 }
17 }