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.
Ask AIPlaygroundLoginFree API Key
HomeAPI ReferenceVoice AgentSpeech-to-TextText-to-SpeechIntelligenceSelf-Hosted Deployments
HomeAPI ReferenceVoice AgentSpeech-to-TextText-to-SpeechIntelligenceSelf-Hosted Deployments
  • Text-to-Speech REST
    • Getting Started
    • Feature Overview
    • Template Apps
  • Text-to-Speech Streaming
    • Getting Started
    • Feature Overview
    • Template Apps
      • Flush
      • Clear
      • Close
  • Models and Languages
    • Voices and Languages
    • TTS Voice Controls
  • Media Output Settings
    • Encoding
    • Bit Rate
    • Container
    • Sample Rate
  • Results Processing
    • TTS Tagging
    • TTS Callback
    • Audio Output Streaming
  • Tips and Tricks
    • Real-Time TTS with WebSockets
    • Text Chunking for TTS
    • Formatting text for Aura-2
    • Handling Audio Issues in Text To Speech
    • Sending LLM Outputs to a WebSocket
    • Text Chunking for TTS REST Optimization
    • Text to Speech Latency
    • Text to Speech Prompting
    • TTS Troubleshooting WebSocket, NET, and DATA Errors
LogoLogo
Ask AIPlaygroundLoginFree API Key
On this page
  • Sending Clear
  • Clear Confirmation
  • Conclusion
Text-to-Speech StreamingControl Messages

Clear

Clear will clear out Deepgram's internal text buffer.
Was this page helpful?
Previous

Close

Close will close the websocket connection immediately.
Next
Built with
Text to Speech Stream

If you’re working on a conversational AI use case between a human and a TTS agent, the human may interrupt the Agent at any time, and you may want to clear (or reset) the internal text buffer. This is useful because the TTS websocket will stop sending audio, allowing your LLM to generate a new response. The TTS websocket will then produce audio only based on the new text provided.

After sending the optional Clear message, the TTS websocket will clear the internal text and audio buffer for generating audio and will stop sending new audio chunks as soon as possible.

Sending Clear

To send the Clear message, you need to send the following JSON message to the server:

JSON
1{
2 "type": "Clear"
3}

Clear Confirmation

Upon receiving the Clear message, the server will process all remaining audio data and return the following:

JSON
1{
2
3"type": "Cleared",
4"sequence_id": 0
5}

Conclusion

To ensure seamless interactions between a human and a TTS agent, it’s crucial to handle interruptions effectively. Clearing the internal text buffer via a Clear message allows for fresh input to be sent from the LLM, ensuring the system adapts to the ongoing conversation. This approach stops the generation of unnecessary audio, enhancing the responsiveness and accuracy of the TTS agent.