Prepare prompts ahead of time so they play instantly
Send up to 200 sentences per call to /v1/prepare, then speak them later without waiting for generation.
POST /v1/prepare gets sentences ready in the background. Preparing is not billed; speaking them later is billed per character as usual. Use it at deploy time for every fixed prompt you will play.
prepare_prompts.py
import os, sys, requests
API = "https://speakvora.com/api/v1"
H = {"x-api-key": os.environ["SPEAKVORA_KEY"]}
def chunks(items, n=200):
for i in range(0, len(items), n):
yield items[i:i + n]
prompts = [line.strip() for line in open(sys.argv[1], encoding="utf-8") if line.strip()]
for batch in chunks(prompts):
r = requests.post(f"{API}/prepare", headers=H, json={"voice": "af_heart", "lang": "en", "texts": batch}, timeout=60)
r.raise_for_status()
j = r.json()
print("ready", j["ready"], "queued", j["queued"], "rejected", j["rejected"])Use it
python prepare_prompts.py prompts.txt # one sentence per line, 1 to 500 charactersWhat the reply means
- ready: already in the library or stored; speaking it is quick.
- queued: being generated in the background; ready in a few seconds.
- rejected: up to 20 examples with the reason (for example digits outside English).
There is a daily cap on prepared texts per account, and a 429 live_rate_limited reply means you reached it. Then run your script again tomorrow or split the work.