> ## 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.

# Synthesize Speech (WebSocket)

> Persistent connection for lowest-latency audio streaming

You open a persistent WebSocket connection and send text messages. The server streams audio chunks back over the same connection — no per-request overhead, no repeated handshakes. This gives you the lowest possible latency.

Best for voice agents and interactive applications that send multiple synthesis requests in a session, where avoiding connection setup on every call makes a measurable difference.

<Note>
  If you only need a single request-response with chunked audio, the [Streaming API](/tts/synthesize-speech-streaming) is simpler to integrate.
  For tips on optimizing latency, see the [latency best practices guide](/tts/best-practices/latency).
</Note>

## Timestamp Transport Strategy

When using [timestamp alignment](/tts/capabilities/timestamps), you can choose how timestamps are delivered alongside audio using `timestampTransportStrategy`:

* **`SYNC`** (default): Each chunk contains both audio and timestamps together.
* **`ASYNC`**: Audio chunks arrive first, with timestamps following in separate trailing messages. This reduces time-to-first-audio with TTS 1.5 models.

See [Timestamps](/tts/capabilities/timestamps#streaming-behavior) for details on how each mode works.

## Code Examples

<CardGroup cols={2}>
  <Card title="JavaScript" icon="js" href="https://github.com/inworld-ai/inworld-api-examples/blob/main/tts/js/example_websocket.js">
    View our JavaScript implementation example
  </Card>

  <Card title="Python" icon="python" href="https://github.com/inworld-ai/inworld-api-examples/blob/main/tts/python/example_websocket.py">
    View our Python WebSocket implementation example
  </Card>
</CardGroup>

## API Reference

<Card title="Synthesize Speech WebSocket" icon="code" href="/api-reference/ttsAPI/texttospeech/synthesize-speech-websocket">
  View the complete API specification
</Card>

## Next Steps

<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>
