Batch generation
Generate up to 100 text-to-speech clips in one call, then download each one.
Looking for batch transcription?
This page is about generating speech in bulk. To transcribe many recordings at once, see Batch transcription.
The batch API turns many texts into speech in one request. Submit up to 100 items, poll until the batch finishes, then download each clip. Items are processed together server-side (up to 4 at a time), which spreads model warm-up across the whole batch.
from wistfareai import WistfareAI
client = WistfareAI() # reads WISTFARE_API_KEY
voice = "vc_9f2ae1"
batch = client.text_to_speech.batches.create(
items=[
{"ref": "welcome", "text": "Ikaze kuri serivisi yacu.", "voice_id": voice},
{"ref": "menu-1", "text": "Kanda rimwe kugira ngo uvugane n'umukozi.", "voice_id": voice},
{"ref": "menu-2", "text": "Kanda kabiri kugira ngo umenye amakuru ya konti yawe.", "voice_id": voice},
],
metadata={"project": "ivr-refresh"},
)
batch = client.text_to_speech.batches.wait(batch.id)
for item in batch.items:
if item.status == "succeeded":
with open(f"{item.ref}.mp3", "wb") as f:
f.write(client.text_to_speech.batches.audio(batch.id, item.ref))
else:
print(item.ref, item.error)When to use batch
- Many clips at once: IVR prompt libraries, course narration, notification catalogs, localisation runs.
- Cost efficiency over latency: items share warm model sessions instead of each paying its own warm-up.
- Nobody is waiting on one clip: you want the whole set, reliably.
For interactive, one-at-a-time generation where time to first audio matters, use POST /v1/tts.
Items
Each item takes the same fields as POST /v1/tts (text, voice_id, model, format, speed; in the SDKs output_format / outputFormat and voiceId) plus an optional ref: your own id, unique within the batch, used to download its audio. See Create a batch.
| Batch status | Meaning |
|---|---|
processing | Items are still being generated. |
completed | Every item succeeded. |
partial | Some items succeeded and some failed. Failed items carry an error and cost nothing. |
failed | Every item failed. Nothing was charged. |
Item statuses are pending, processing, succeeded and failed.
Billing
- Items are charged individually as they complete, at the
/v1/ttsrate: $0.15 per minute of generated audio (×speedwhen above 1.0), minimum 1¢ per item. Failed items are never charged. - Before processing starts, the estimated total of all items is held from your balance. If it can't be covered, the whole batch is rejected with
402 insufficient_creditsand nothing is charged. Unused held credits are released when the batch finishes. - Send an
Idempotency-Keyheader so a retried request can't create the batch twice.
Retention
Batches and their audio are kept for 30 days after creation. Download anything you want to keep within that window.