Guides
Text to speech
Product overview: Rendley video editing API
Text-to-speech turns a script into spoken audio in one call. Pick a voice, send the text, and get back an MP3. Place it on a timeline or use it on its own.
The flow
GET /v1/ai/text-to-speech/voices ← browse available voices
POST /v1/ai/text-to-speech ← send text, get a job
GET /v1/jobs/{id} ← poll until completed
List available voices
Each voice comes back as id, name, model_id and preview_audio_url. Listen to the preview to pick one.
const API_KEY = "YOUR_API_KEY";
const API = "https://api.rendley.com/v1";
const headers = { "Authorization": `Bearer ${API_KEY}` };
const response = await fetch(`${API}/ai/text-to-speech/voices`, { headers });
const payload = await response.json();
const voices = payload.data;
for (const voice of voices) {
console.log(voice.id.padEnd(24), voice.name.padEnd(20), voice.preview_audio_url || "");
}import requests
API_KEY = "YOUR_API_KEY"
API = "https://api.rendley.com/v1"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
response = requests.get(f"{API}/ai/text-to-speech/voices", headers=HEADERS)
response.raise_for_status()
voices = response.json()["data"]
for voice in voices:
print(f"{voice['id']:24} {voice['name']:20} {voice.get('preview_audio_url', '')}")The list is paginated. Pass page and limit to walk it, or query to search by name.
Generate a voiceover
The polling helpers used below
const API_KEY = "YOUR_API_KEY";
const API = "https://api.rendley.com/v1";
const headers = {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json",
};
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
// Generation and export jobs. The finished job carries output.url.
async function waitForJob(jobId) {
let job = { status: "queued" };
while (job.status === "queued" || job.status === "processing") {
await sleep(5000);
const response = await fetch(`${API}/jobs/${jobId}`, { headers });
if (!response.ok) {
throw new Error("Job lookup failed: " + response.status);
}
job = (await response.json()).data;
console.log("Job status:", job.status);
}
if (job.status !== "completed") {
throw new Error("Job " + job.status + ": " + (job.error || ""));
}
return job;
}
// Agent jobs. The finished job carries project_id, thread_id and
// last_message, but no output: export the project to get a file.
// onPause answers an interactive run that stops to ask something.
async function waitForAgentJob(jobId, onPause) {
let job = { status: "pending" };
while (job.status === "pending" || job.status === "running" || job.status === "waiting_input") {
if (job.status === "waiting_input") {
if (!onPause) throw new Error("The run is waiting for an answer");
await onPause(job);
}
await sleep(5000);
const response = await fetch(`${API}/agent/jobs/${jobId}`, { headers });
if (!response.ok) {
throw new Error("Job lookup failed: " + response.status);
}
job = (await response.json()).data;
console.log("Edit status:", job.status);
}
if (job.status !== "completed") {
throw new Error("The edit did not finish: " + (job.error || job.reason));
}
return job;
}import time
import requests
API_KEY = "YOUR_API_KEY"
API = "https://api.rendley.com/v1"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
def wait_for_job(job_id):
"""Generation and export jobs. The finished job carries output.url."""
job = {"status": "queued"}
while job["status"] in ("queued", "processing"):
time.sleep(5)
response = requests.get(f"{API}/jobs/{job_id}", headers=HEADERS)
response.raise_for_status()
job = response.json()["data"]
print("Job status:", job["status"])
if job["status"] != "completed":
raise RuntimeError(f"Job {job['status']}: {job.get('error', '')}")
return job
def wait_for_agent_job(job_id, on_pause=None):
"""Agent jobs. The finished job carries project_id, thread_id and
last_message, but no output: export the project to get a file.
on_pause answers an interactive run that stops to ask something.
"""
job = {"status": "pending"}
while job["status"] in ("pending", "running", "waiting_input"):
if job["status"] == "waiting_input":
if on_pause is None:
raise RuntimeError("The run is waiting for an answer")
on_pause(job)
time.sleep(5)
response = requests.get(f"{API}/agent/jobs/{job_id}", headers=HEADERS)
response.raise_for_status()
job = response.json()["data"]
print("Edit status:", job["status"])
if job["status"] != "completed":
raise RuntimeError("The edit did not finish: " + (job.get("error") or job.get("reason", "")))
return job// Pick a voice id from GET /ai/text-to-speech/voices.
const VOICE_ID = "EXAVITQu4vr4xnSDxMaL";
const SCRIPT = [
"Welcome to our product demo. In the next sixty seconds,",
"you'll see how easy it is to automate video creation with",
"the Rendley API.",
].join(" ");
// Queue the voiceover. This returns before any audio is rendered.
async function startSpeechJob() {
const response = await fetch(`${API}/ai/text-to-speech`, {
method: "POST",
headers,
body: JSON.stringify({
params: {
prompt: SCRIPT,
voice_id: VOICE_ID,
},
}),
});
if (!response.ok) {
throw new Error("Could not start the job: " + response.status);
}
const payload = await response.json();
return payload.data.job_id;
}
const jobId = await startSpeechJob();
const job = await waitForJob(jobId);
// The signed URL is the result. Fetch it, pipe it to your storage,
// or hand it to the browser.
console.log(job.output.url);import requests
# Pick a voice id from GET /ai/text-to-speech/voices.
VOICE_ID = "EXAVITQu4vr4xnSDxMaL"
SCRIPT = (
"Welcome to our product demo. In the next sixty seconds, "
"you'll see how easy it is to automate video creation with "
"the Rendley API."
)
def start_speech_job():
"""Queue the voiceover. Returns before any audio is rendered."""
response = requests.post(
f"{API}/ai/text-to-speech",
headers=HEADERS,
json={
"params": {
"prompt": SCRIPT,
"voice_id": VOICE_ID,
}
},
)
response.raise_for_status()
return response.json()["data"]["job_id"]
job_id = start_speech_job()
job = wait_for_job(job_id)
# The finished job points at a signed URL. Download it before it expires.
audio = requests.get(job["output"]["url"])
audio.raise_for_status()
with open("voiceover.mp3", "wb") as f:
f.write(audio.content)
print("Saved voiceover.mp3")Combining TTS with video
Generate the voiceover, then use the automated editing agent to lay it over footage.
{
"prompt": "Add voiceover.mp3 as narration over the product-demo.mp4 footage. Lower the original audio to 20% volume.",
"files": [
{ "url": "https://cdn.example.com/product-demo.mp4", "name": "product-demo.mp4" },
{ "url": "JOB_OUTPUT_URL", "name": "voiceover.mp3" }
]
}
Pass the voiceover job’s output.url as the second file. Set name on each entry so the prompt can refer to it reliably. Names derived from signed URLs are often opaque and hard to use in a prompt.