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 Close
  • Close Confirmation
  • Conclusion
Text-to-Speech StreamingControl Messages

Close

Close will close the websocket connection immediately.
Was this page helpful?
Previous

Voices and Languages

An overview of Deepgram’s Aura text-to-speech voice models

Next
Built with
Text to Speech Stream

To close the websocket connection, you can either send an websocket Close frame, or send the optional close message.

Sending Close

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

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

Close Confirmation

Upon receiving the Close message, the server will close the websocket connect and return:

Disconnected from wss://api.deepgram.com/v1/speak
14:57:21
1000 Normal Closure:
Connection was closed successfully.

Conclusion

In real-time text-to-speech processing, situations may arise where you need to immediately stop the server’s operations. To manage this, Deepgram provides a Close message, which ensures the server halts processing and closes the connection promptly, maintaining control and responsiveness in critical scenarios.