Or jump from this list on a smaller screen.

This is a page from the Audivra documentation. Developer exportsindex: http://127.0.0.1:3000/docs/llms.txt, full corpus: http://127.0.0.1:3000/docs/llms-full.txt, OpenAPI: http://127.0.0.1:3000/docs/openapi.json, Postman: http://127.0.0.1:3000/docs/postman.json. Press ⌘K to search docs.

Stream Opus TTS on low bandwidth

Deliver chunked Opus audio for mobile networks in the Global South — 48 kbps streams instead of multi-megabyte WAV files.

Developers
~10 min

Outcome: A streaming Opus pipeline your mobile app or IVR can play incrementally on 2G/3G links.

  1. 1

    Why Opus instead of WAV

    WAV responses from POST /api/v1/tts can be 500 KB+ for a short sentence — painful on M-Pesa-tier mobile data.

    POST /api/v1/tts/stream returns chunked Opus (or AAC) optimized for Global South bandwidth. Typical footprint: ~48 kbps.

    Use voice_id zuri-sw, umar-ha, or swara-hi for regional African languages on Kokoro-82M.

  2. 2

    Request a streaming response

    Set format to opus (default) or aac. The response uses Transfer-Encoding: chunked — read chunks as they arrive.

    cURL — save stream
    curl -X POST https://audivra.dev/api/v1/tts/stream \
      -H "Authorization: Bearer sk_live_…" \
      -H "Content-Type: application/json" \
      -d '{"text":"Habari. Karibu kwenye huduma yetu.","voice_id":"zuri-sw","format":"opus"}' \
      --output stream.opus
  3. 3

    Play in the browser or mobile app

    Opus chunks can be fed to MediaSource Extensions (web) or an Opus decoder on Android/iOS.

    For quick validation, pipe to ffplay: ffplay -autoexit stream.opus

    JavaScript — fetch stream
    const res = await fetch("https://audivra.dev/api/v1/tts/stream", {
      method: "POST",
      headers: {
        Authorization: "Bearer sk_live_…",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        text: "Sentence one. Sentence two.",
        voice_id: "zuri-sw",
        format: "opus",
      }),
    });
    
    const reader = res.body?.getReader();
    // Append chunks to MediaSource or buffer for native Opus decode
  4. 4

    Tune for your network

    Keep sentences under 500 characters for fast-path local routing (1 credit) when a local worker is configured.

    Set DEFAULT_STREAM_FORMAT=opus in your deployment env for server-side defaults.

    Monitor X-Characters and X-Stream-Format response headers for billing and debugging.

    1 audio character = 1 credit. Streaming and sync TTS meter the same way.

Related reference

/docs/api/tts

/docs/overview/voices

/docs/concepts/processing-nodes