← PixelAPI · Tutorials · All docs · Pricing
Generate narration in 23 languages and clone a voice from a 5-20 second clip. Engine: Chatterbox (MIT).
curl -X POST https://api.pixelapi.dev/v1/tts/generate \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "text=Welcome to our store. Today's deals end at midnight." \
-F "language=en" \
-F "voice_ref=@my_voice_10s.wav"
# then poll until status is "completed"
curl https://api.pixelapi.dev/v1/tts/status/TTS_JOB_ID -H "Authorization: Bearer YOUR_API_KEY"
Leave out voice_ref for the default voice. The response contains an id; poll /v1/tts/status/{id} until status is completed and download the WAV from output_url.
Each request takes up to 400 characters. This script splits text at sentence boundaries and generates each part:
import re, time, requests
API = "https://api.pixelapi.dev"
HEADERS = {"Authorization": "Bearer YOUR_API_KEY"}
def chunks(text, limit=400):
"""Split at sentence boundaries so each request stays within 400 characters."""
out, cur = [], ""
for s in re.split(r"(?<=[.!?])\s+", text.strip()):
if len(cur) + len(s) + 1 > limit and cur:
out.append(cur); cur = ""
cur = (cur + " " + s).strip()
if cur:
out.append(cur)
return out
def speak(text, language="en", voice_ref=None):
files = {"voice_ref": open(voice_ref, "rb")} if voice_ref else None
job = requests.post(f"{API}/v1/tts/generate", headers=HEADERS,
data={"text": text, "language": language}, files=files).json()
while True:
s = requests.get(f"{API}/v1/tts/status/{job['id']}", headers=HEADERS).json()
if s["status"] == "completed":
return s["output_url"]
if s["status"] == "failed":
raise RuntimeError(s.get("error"))
time.sleep(3)
script = open("script.txt").read()
for i, part in enumerate(chunks(script)):
print(i, speak(part, language="en", voice_ref="my_voice_10s.wav"))
ar, da, de, el, en, es, fi, fr, he, hi, it, ja, ko, ms, nl, no, pl, pt, ru, sv, sw, tr, zh. English uses chatterbox-turbo; the others use chatterbox-multilingual (model=auto picks for you).
40 credits per 1,000 characters, charged per character (minimum 1 credit). A 400-character request costs 16 credits. Voice cloning costs the same.