audio

Synthesize many inputs in one request

Answers application/x-ndjson by default: one JSON object per line, written the moment that item finishes, each carrying its audio as base64. A final {"object":"batch.done"} line closes the stream. Send stream: false for one buffered application/json envelope instead.

Each item’s audio is a COMPLETE file — real sizes in its header, never the streaming placeholder — so you can write the decoded bytes straight to disk. Set response_format on the batch, or per item to mix formats in one request; each item carries format, mimeType, sampleRate, channels and bitsPerSample next to its audio.

Audio defaults to MPEG-2 Layer III (MP3), 24 kHz, mono, 128 kbps, with no Xing/LAME header and no ID3 tag — the body starts at the first audio frame. Set response_format for anything else: mp3, mp3_64, mp3_160, wav, wav24, wav32f, flac, flac24, pcm, pcm_f32, aiff, caf, au, mulaw, alaw. The exact numbers for a given response are echoed in the X-Ditto-Audio-* headers; decode and resample from those rather than assuming a rate. GET /v1/audio/format describes every encoding in full, without authentication.

Hi-fidelity formats bill at 1.2× the normal rate, multiplied by the model’s own weighting — the audio is identical, but the bytes are several times larger. mp3 (the default), mp3_64, mulaw and alaw are unchanged at 1×. Each format’s exact multiplier is in GET /v1/audio/format and in the X-Ditto-Audio-Cost-Multiplier response header.

Results are not in request order. Items are reordered server-side so that work sharing a (model, voice, language) runs contiguously — the serving node holds ONE voice slot, so an interleaved order forces a speaker reload on every item, which is the cost this endpoint exists to remove. Streamed lines therefore arrive as they complete; every line carries index (its position in your items array), and the buffered envelope is sorted back into request order for you.

Failure is PER ITEM: a bad voice on one item produces a failed result for that item with the same status/code the single-shot route would have returned, and does not affect the others. The HTTP status is 200 whenever the batch itself was accepted.

Aborting the request stops dispatching further items — in-flight synthesis is cancelled at the node, so cancelling saves GPU.

Up to 64 items and 200000 characters per request. For more, or for work too long to hold a connection open, use POST /v1/audio/batches.

post/v1/audio/speech/batch

Request

  • Base URL: https://api.ditto.audio (the document declares no server; this is the origin it was published from)
  • URL: https://api.ditto.audio/v1/audio/speech/batch
  • Auth: HTTP bearer

Request body

model'kokoro' | 'xtts' | 'pocket'

Default model for every item that doesn’t set its own.

voicestring

Default voice for every item that doesn’t set its own.

languagestring

Default language. Omit to infer per item from its own text.

speednumber
response_format'mp3' | 'mp3_64' | 'mp3_160' | 'wav' | 'wav24' | 'wav32f' | 'flac' | 'flac24' | 'pcm' | 'pcm_f32' | 'aiff' | 'caf' | 'au' | 'mulaw' | 'alaw'

Default audio encoding for every item that doesn’t set its own. Every item is a COMPLETE file — real sizes in its header, not the streaming placeholder — so the result is directly playable and directly saveable. Hi-fidelity formats bill at 1.2× the normal rate, multiplied by the model’s own weighting — the audio is identical, but the bytes are several times larger. mp3 (the default), mp3_64, mulaw and alaw are unchanged at 1×. Each format’s exact multiplier is in GET /v1/audio/format and in the X-Ditto-Audio-Cost-Multiplier response header.

streamboolean

true (default): application/x-ndjson — one JSON object per line, written the moment that item finishes, so you can start using results before the batch is done. false: one buffered application/json envelope { results, summary } with results in REQUEST order.

Example request

{
  "model": "kokoro",
  "voice": "kokoro-af-heart",
  "language": "en",
  "items": [
    {
      "id": "para-17"
    }
  ]
}

Response

NDJSON stream of batch.item lines followed by one batch.done, or the buffered { results, summary } envelope when stream:false.

object required

Changes

No recorded changes to this operation across all 1 revision of this API.