Mowa ElevenLabs v4: 21 głosów i ponad 90 języków, do 10 000 znaków
ElevenLabs v4: generator głosu AI online- Głosy: 21
- Języki: 91
- Tekst na mowę
Wywołujesz go nazwą modelu elevenlabs/v4/text-to-speech w POST /jobs/createTask, od 0,096 USD.
elevenlabs/v4/text-to-speechPOST https://api.popnow.ai/api/v1/jobs/createTask# 1. Create the task. Keep the Idempotency-Key if you retry after a network error.
export IDEMPOTENCY_KEY="$(uuidgen)"
curl -X POST https://api.popnow.ai/api/v1/jobs/createTask \
-H "Authorization: Bearer $POPNOW_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $IDEMPOTENCY_KEY" \
-d '{
"model": "elevenlabs/v4/text-to-speech",
"input": {
"text": "Welcome back. Your files finished rendering a minute ago and are ready to download.",
"voice_id": "Roger",
"language": "auto"
}
}'
# 2. Copy data.taskId from the response, then poll until state is succeeded, failed, canceled or expired.
TASK_ID="TASK_ID_FROM_RESPONSE"
curl "https://api.popnow.ai/api/v1/jobs/recordInfo?taskId=$TASK_ID" \
-H "Authorization: Bearer $POPNOW_API_KEY"// Node 18+ (or any runtime with fetch). Keep the API key on your server.
const BASE = "https://api.popnow.ai/api/v1";
const headers = { Authorization: `Bearer ${process.env.POPNOW_API_KEY}` };
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
async function call(path, init = {}) {
const res = await fetch(BASE + path, { ...init, headers: { ...headers, ...init.headers } });
const body = await res.json();
if (body.code !== 200) throw new Error(`${body.code} ${body.msg}`);
return body.data;
}
const { taskId } = await call("/jobs/createTask", {
method: "POST",
headers: { "Content-Type": "application/json", "Idempotency-Key": crypto.randomUUID() },
body: JSON.stringify({
"model": "elevenlabs/v4/text-to-speech",
"input": {
"text": "Welcome back. Your files finished rendering a minute ago and are ready to download.",
"voice_id": "Roger",
"language": "auto"
}
}),
});
// Poll with backoff. A finished task may still be copying files: wait while an asset is pending.
let task;
for (let delay = 2000; ; delay = Math.min(delay * 1.5, 15000)) {
await sleep(delay);
task = await call(`/jobs/recordInfo?taskId=${taskId}`);
const copying = (task.output?.assets ?? []).some((a) => a.pending && !a.unavailable);
if (["succeeded", "failed", "canceled", "expired"].includes(task.state) && !copying) break;
}
if (task.state !== "succeeded") throw new Error(`${task.state}: ${task.errorMessage ?? "no detail"}`);
// Each asset has a signed url (no API key needed) that expires at expiresAt: save the file.
for (const asset of task.output.assets) console.log(asset.url);import os, time, uuid, requests
BASE = "https://api.popnow.ai/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['POPNOW_API_KEY']}"}
def call(method, path, **kwargs):
body = requests.request(method, BASE + path, headers={**HEADERS, **kwargs.pop("headers", {})}, timeout=30, **kwargs).json()
if body["code"] != 200:
raise RuntimeError(f'{body["code"]} {body["msg"]}')
return body["data"]
task_id = call(
"POST",
"/jobs/createTask",
headers={"Idempotency-Key": str(uuid.uuid4())}, # reuse it if you retry
json={
"model": "elevenlabs/v4/text-to-speech",
"input": {
"text": "Welcome back. Your files finished rendering a minute ago and are ready to download.",
"voice_id": "Roger",
"language": "auto"
}
},
)["taskId"]
# Poll with backoff. A finished task may still be copying files: wait while an asset is pending.
delay = 2.0
while True:
time.sleep(delay)
task = call("GET", "/jobs/recordInfo", params={"taskId": task_id})
assets = (task.get("output") or {}).get("assets") or []
copying = any(a.get("pending") and not a.get("unavailable") for a in assets)
if task["state"] in ("succeeded", "failed", "canceled", "expired") and not copying:
break
delay = min(delay * 1.5, 15.0)
if task["state"] != "succeeded":
raise RuntimeError(f'{task["state"]}: {task.get("errorMessage", "no detail")}')
# Each asset has a signed url (no API key needed) that expires at expiresAt: save the file.
for asset in assets:
print(asset["url"])input jest zbudowany ze schematu poniżej, więc przechodzi walidację bez zmian. Zamień prompt i linki na własne.
Cena
| Opcja | USD za 1000 znaków |
|---|---|
| Standard | 0,096 USD |
Rozliczenie w USD · Wszystkie opcje i ceny: GET /models/elevenlabs/v4/text-to-speech
Limity
- Długość tekstu (znaki)
- 10,000
- Głosy
- 21
- Języki
- 91
Parametry
Te pola pochodzą z tego samego schematu, którym sprawdzamy każde żądanie. Pola spoza listy są odrzucane.
textstringWymaganeSłowa do wypowiedzenia, dokładnie tak, jak są zapisane.
voice_idstringOpcjonalneWybierz jeden z dostępnych głosów.
languagestringOpcjonalneJęzyk wypowiedzi.
stabilitynumberOpcjonalneJak równa jest wypowiedź. Niżej oznacza więcej ekspresji i zmienności.
similarity_boostnumberOpcjonalneJak bardzo mowa trzyma się wybranego głosu.
output_formatstringOpcjonalneFormat pliku wyniku.
text_normalization_modestringOpcjonalneCzy liczby, daty i skróty są zapisywane słownie przed odczytaniem.
clone_strengthnumberOpcjonalneJak mocno stosowany jest profesjonalny klon głosu. Nie wpływa na głosy gotowe.
seedintegerOpcjonalneUżyj tej samej wartości seed i tych samych ustawień, aby lepiej kontrolować warunki porównania.
Surowy JSON Schema
{
"type": "object",
"required": [
"text"
],
"properties": {
"seed": {
"type": "integer",
"maximum": 4294967295,
"minimum": 0,
"description": "Random seed for controlled comparisons."
},
"text": {
"type": "string",
"maxLength": 10000,
"minLength": 1,
"description": "The words to speak. Audio tags such as [whispers] or [sighs] are performed, not read. Billed per 1,000 characters. Up to 10,000 characters; about 3,000 or fewer keeps a long read from being cut off."
},
"language": {
"enum": [
"auto",
"af",
"am",
"ar",
"hy",
"as",
"ast",
"az",
"be",
"bn",
"bs",
"bg",
"my",
"yue",
"ca",
"ceb",
"hr",
"cs",
"da",
"nl",
"en",
"et",
"fil",
"fi",
"fr",
"ff",
"gl",
"ka",
"de",
"el",
"gu",
"ha",
"he",
"hi",
"hu",
"is",
"id",
"it",
"ja",
"jv",
"kam",
"kn",
"kk",
"ko",
"ky",
"lo",
"lv",
"ln",
"lt",
"lg",
"lb",
"mk",
"ms",
"ml",
"mt",
"zh",
"mi",
"mr",
"mn",
"ne",
"no",
"oc",
"or",
"ps",
"fa",
"pl",
"pt",
"pa",
"ro",
"ru",
"sr",
"sn",
"sd",
"sk",
"sl",
"so",
"ckb",
"es",
"sw",
"sv",
"tg",
"ta",
"te",
"th",
"tr",
"uk",
"ur",
"uz",
"vi",
"cy",
"wo",
"zu"
],
"type": "string",
"default": "auto",
"description": "Language to enforce, as an ISO code, or auto to detect it from the text."
},
"voice_id": {
"enum": [
"Adam",
"Alice",
"Bella",
"Bill",
"Brian",
"Callum",
"Charlie",
"Chris",
"Daniel",
"Eric",
"George",
"Harry",
"Jessica",
"Laura",
"Liam",
"Lily",
"Matilda",
"River",
"Roger",
"Sarah",
"Will"
],
"type": "string",
"default": "Roger",
"description": "Preset voice."
},
"stability": {
"type": "number",
"default": 0.5,
"maximum": 1,
"minimum": 0,
"description": "How steady the delivery is, 0 to 1. Lower is more expressive and more variable."
},
"output_format": {
"enum": [
"mp3_44100_128",
"mp3_44100_64",
"mp3_22050_32",
"opus_48000_128",
"pcm_24000",
"pcm_16000",
"wav_44100",
"ulaw_8000",
"alaw_8000"
],
"type": "string",
"default": "mp3_44100_128",
"description": "Audio container, sample rate and bitrate. pcm is raw audio without a file header."
},
"clone_strength": {
"type": "number",
"maximum": 1,
"minimum": 0,
"description": "Strength of a professional voice clone, 0 to 1. Has no effect on preset voices."
},
"similarity_boost": {
"type": "number",
"default": 0.75,
"maximum": 1,
"minimum": 0,
"description": "How closely the speech follows the selected voice, 0 to 1."
},
"text_normalization_mode": {
"enum": [
"auto",
"on",
"off"
],
"type": "string",
"default": "auto",
"description": "Whether numbers, dates and abbreviations are spelled out before reading."
}
},
"additionalProperties": false
}Prawdziwy wynik z ElevenLabs v4
[laughs] Okay, confession time. The first sourdough starter I ever made, I named him Gerald. [sighs] Gerald lasted six days. But here's what nobody tells you about failing at something small: it's the fastest way to find out what you actually care about. I'm Maya, and this is Second Batch.
{
"model": "elevenlabs/v4/text-to-speech",
"input": {
"text": "[laughs] Okay, confession time. The first sourdough starter I ever made, I named him Gerald. [sighs] Gerald lasted six days. But here's what nobody tells you about failing at something small: it's the fastest way to find out what you actually care about. I'm Maya, and this is Second Batch.",
"voice_id": "Jessica",
"language": "auto",
"stability": 0.4
}
}Odpowiedzi, odpytywanie i callbacki
Wszystkie modele działają tak samo: utwórz zadanie, a potem odpytuj je albo poczekaj na callback.
Najpierw cena
curl -X POST https://api.popnow.ai/api/v1/jobs/quote \
-H "Authorization: Bearer $POPNOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "elevenlabs/v4/text-to-speech",
"input": {
"text": "Welcome back. Your files finished rendering a minute ago and are ready to download.",
"voice_id": "Roger",
"language": "auto"
}
}'Przed uruchomieniem wyślij tę samą treść żądania do POST /jobs/quote, aby zobaczyć szacowaną i maksymalną opłatę w USD. Wycena nie uruchamia zadania ani nie obciąża salda.
Przyjęte
HTTP/1.1 202 Accepted
{
"code": 200,
"msg": "success",
"data": {
"taskId": "task_01k3m8x9q2z4v7n5p6r8s0t1w3",
"state": "queued"
},
"request_id": "req_example_create"
}HTTP 202 oznacza przyjęcie zadania: maksymalna kwota w USD pozostaje zarezerwowana do rozliczenia. Po przyjęciu zadania rezerwujemy maksymalną kwotę wyceny na saldzie PopNow. Po zakończeniu naliczamy opłatę za rzeczywiste użycie, nie wyższą niż rezerwacja, i zwalniamy resztę. Jeśli zadanie się nie powiedzie, rezerwacja zostaje zwolniona.
Sprawdź status
curl "https://api.popnow.ai/api/v1/jobs/recordInfo?taskId=$TASK_ID" \
-H "Authorization: Bearer $POPNOW_API_KEY"Odpytuj co kilka sekund, stopniowo wydłużając odstęp, i przestań, gdy state ma wartość succeeded, failed, canceled lub expired.
Gotowe zadanie
{
"code": 200,
"msg": "success",
"data": {
"taskId": "task_01k3m8x9q2z4v7n5p6r8s0t1w3",
"model": "elevenlabs/v4/text-to-speech",
"state": "succeeded",
"output": {
"assets": [
{
"url": "https://cdn.popnow.ai/tasks/task_01k3m8x9q2z4v7n5p6r8s0t1w3/output.mp3?signature=FROM_RESPONSE",
"expiresAt": "2026-10-17T12:20:00Z",
"mime": "audio/mpeg",
"durationSeconds": 30
}
]
},
"settled": true
},
"request_id": "req_example_record"
}Pobierz plik z url przed expiresAt. Potrzebujesz później nowego linku? Poproś o niego przez POST /common/download-url.
Weryfikacja callbacku
import { createHash, createHmac, timingSafeEqual } from "node:crypto";
import express from "express";
const app = express();
// express.raw keeps the exact bytes that were signed; express.json would not match.
app.post("/hooks/popnow", express.raw({ type: "application/json" }), (req, res) => {
const timestamp = req.header("X-Webhook-Timestamp");
const signature = req.header("X-Webhook-Signature") ?? "";
const body = JSON.parse(req.body.toString("utf8"));
const taskId = body.data?.taskId ?? body.task_id;
const digest = createHash("sha256").update(req.body).digest("hex");
const expected = createHmac("sha256", process.env.POPNOW_WEBHOOK_SECRET)
.update(`${taskId}.${timestamp}.${digest}`)
.digest("base64");
const ok = expected.length === signature.length && timingSafeEqual(Buffer.from(expected), Buffer.from(signature));
// Check the signature first, then reject anything older than five minutes.
if (!ok || Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return res.status(401).end();
res.status(200).end(); // answer fast, then fetch the task and store its files
});Gdy ustawisz callBackUrl, wyślemy ci ukończone zadanie. Przed przetworzeniem zweryfikuj podpis na oryginalnej treści żądania.
Wysyłanie pliku lokalnego
curl -X POST https://api.popnow.ai/api/v1/common/upload-url \
-H "Authorization: Bearer $POPNOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{"contentType": "image/png", "bytes": 482113}'
# PUT the file bytes to data.uploadUrl with every header in data.headers, then commit it:
curl -X POST https://api.popnow.ai/api/v1/files/$FILE_ID/commit \
-H "Authorization: Bearer $POPNOW_API_KEY"
# The commit returns a popnow://f/... reference. Put it in any image, video or
# audio field of the task input instead of a public https URL.Publiczne linki https działają bez zmian. Pliki lokalne przechodzą najpierw przez upload-url i commit.