> ## Documentation Index
> Fetch the complete documentation index at: https://docs.inworld.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Latency

> Best practices for minimizing latency in realtime TTS applications

For realtime use cases, minimizing latency is critical. Here are some tips and techniques you can use:

1. **Stream TTS output** - Instead of waiting for the entire generation (which may take some time if it is long), you can start playback as soon as the first chunk arrives so that the user doesn't have to wait. Inworld's [websocket streaming](/api-reference/ttsAPI/texttospeech/synthesize-speech-websocket) should be the lowest-latency option, but [streaming over HTTP](/api-reference/ttsAPI/texttospeech/synthesize-speech-stream) will also be superior to a [non-streaming setup](/api-reference/ttsAPI/texttospeech/synthesize-speech).

2. **Chunk streaming LLM output into TTS** - For the fastest time to first audio, consider breaking streaming LLM output into sentence chunks and sending them one by one to TTS. The Inworld Agent Runtime provides [built-in tools](/node/runtime-reference/classes/graph_dsl_nodes_text_chunking_node.TextChunkingNode) to handle this in a performant manner.

3. **Use JWT authentication to stream directly to the client** - For applications like mobile apps or browser-based experiences, use [JWT authentication](/api-reference/introduction#jwt-authentication) to stream TTS directly to the client rather than proxying through your server and adding extra latency.

4. **Reuse connections with keep-alive** - The first request to the API incurs a TCP and TLS handshake. Use `Connection: keep-alive` (and persistent sessions in Python) to reuse the established connection on subsequent requests. See our [low-latency Python](https://github.com/inworld-ai/inworld-api-examples/blob/main/tts/python/example_tts_low_latency_http.py) and [JavaScript](https://github.com/inworld-ai/inworld-api-examples/blob/main/tts/js/example_tts_low_latency_http.js) examples for this technique in practice.

## Next Steps

Looking for more tips and tricks? Check out the resources below to get started!

<CardGroup cols={3}>
  <Card title="Voice Cloning Best Practices" icon="circle-check" href="/tts/best-practices/voice-cloning">
    Learn best practices for producing high-quality voice clones.
  </Card>

  <Card title="Speech Generation Best Practices" icon="circle-check" href="/tts/best-practices/generating-speech">
    Learn best practices for synthesizing high-quality speech.
  </Card>

  <Card title="API Examples" icon="github" href="https://github.com/inworld-ai/inworld-api-examples/tree/main/tts">
    Explore Python and JavaScript code examples for TTS integration.
  </Card>
</CardGroup>
