Dub an SRT or a dialogue sheet through the API
You have a subtitle file or a script with timecodes, and you want one audio track where every line starts at its own time. Pick the row that matches what you have:
| You have | Use | Section |
|---|---|---|
An .srt and one voice from the VieNeu library | POST /v1/srt — one request, one WAV back | One library voice |
A cloned voice (clone_…), or a different voice per line | One Python script that sends each line to POST /v1/tts and assembles the track | Cloned or several voices |
| No wish to write code | The desktop app or the web Dubbing page | Without code |
Only dub text you have the right to use, in voices you have the right to use. A cloned voice must be your own, or one whose owner agreed to it.
One library voice: POST /v1/srt
Send the whole file. The server reads every cue, places it at its start time, speeds up a cue that does not fit its window, and returns one WAV plus a report of where each cue actually landed.
curl https://api.vieneu.io/api/v1/srt \
-H "Authorization: Bearer $VIENEU_API_KEY" \
-F file=@episode.srt \
-F voiceId="Ngọc Lan" \
-o result.json
The answer comes back when the whole track is ready (there is no job to poll):
{
"success": true,
"cuesCount": 42,
"audioUrl": "https://…/srt/….wav?X-Amz-Expires=86400&…",
"audioUrlExpiresIn": 86400,
"duration": 128.4,
"sampleRate": 48000,
"tokenCost": 1875,
"placements": [
{ "index": 7, "scheduledStartMs": 12000, "actualStartMs": 12180,
"windowMs": 2000, "durationMs": 2400, "speed": 1.2, "overflowed": true }
]
}
Download audioUrl straight away: it expires after 24 hours.
Read placements as a drift report
placements has one entry per cue:
| Field | Meaning |
|---|---|
scheduledStartMs | the start time written in the subtitle |
actualStartMs | where the cue really starts in the track |
windowMs | the subtitle's own length, end − start |
durationMs | the spoken length after speed-fitting |
speed | the tempo applied to fit the window (1.0 = untouched) |
overflowed | true when the cue was pushed later than its start, because the cue before it ran over |
A cue that does not fit is first sped up; if it still runs over, the cues after it move later. So the lines worth a human look are the ones that were sped up or pushed:
jq '.placements[] | select(.overflowed or .speed > 1.0)
| {index, late_ms: (.actualStartMs - .scheduledStartMs), speed}' result.json
Shorten those lines in the subtitle and send the file again. One long cue usually pushes several after it, so fix the first late one before the rest.
Limits on /v1/srt
Checked against the server code on 2026-11-30.
.srtonly, sent as the multipart fieldfile, at most 10 MB.- 50,000 characters of cue text in total. Past that the request is refused before anything is charged: split the file.
- 10 requests per minute per API key.
- Library voices only. A
clone_…id is refused with 400 (Cloned voice … can only be used on POST /v1/tts, POST /v1/tts/stream or POST /v1/audio/speech). Use the script below for cloned voices. - One voice for the whole file. For several voices, use the script.
- Billing: by the characters of cue text (about one token per character, minimum 50) times the engine's multiplier, deducted when the request starts and refunded if synthesis fails. Output length does not change the price.
aiRefineis off unless you send-F aiRefine=true(it moderates the text and adds a surcharge). Your pronunciation dictionary applies to every cue unless you send-F applyPronunciation=false.- A test key (
vn_test_…) accepts at most 100 words per file. - The request stays open while the whole track renders. Give your HTTP client a generous timeout, and split a long episode into parts rather than sending 50,000 characters at once.
Field-level detail is in the API reference under
createSrtDub.
Cloned or several voices: one script
dub_with_api.py does by hand what
/v1/srt does on the server, so the voice can be anything POST /v1/tts
accepts — a library voice, your own clone_… voice, or a different voice on every
line. It uses only the Python standard library (3.10 or newer) and calls ffmpeg
for decoding and speed-fitting.
export VIENEU_API_KEY=vn_sk_...
# An .srt, every line in one cloned voice
python dub_with_api.py episode.srt --voice "clone_0f3c…" -o episode.wav
# A dialogue sheet: a voice per line
python dub_with_api.py sheet.csv -o episode.wav
A dialogue sheet is a UTF-8 CSV with the header start,end,voice,text. Times
are 00:01:02.500 or seconds (62.5); an SRT-style time with a comma must be
quoted.
start,end,voice,text
0.5,2.8,Ngọc Lan,Chào anh. Hôm nay anh muốn đặt bàn mấy giờ?
3.2,5.0,clone_0f3c…,"Bảy giờ tối nhé, cho bốn người."
5.4,7.6,Ngọc Lan,Dạ vâng. Em giữ bàn cho anh rồi ạ.
It writes episode.wav (48 kHz mono) and episode.report.json, whose entries
have the same fields as placements, plus an error for a
line that produced no audio. It exits with status 1 if any line failed.
What the script does, and the limits it stays inside
- One job per line,
POST /v1/ttswith{"text", "voiceId"}. - An
Idempotency-Keyon every submit, derived from the file's contents, the line number, voice and text. A retry after a timeout, or a second run of the same file, gets the job that key already created instead of a new charge (the response carriesIdempotent-Replayed: true). The key must be 8–128 printable ASCII characters. Reusing a key with a different body is refused with 422IDEMPOTENCY_KEY_REUSED; a 409IDEMPOTENCY_IN_FLIGHTmeans the first request is still being handled, so the script waits a second and resends the same key. - At most 20 jobs in flight. An account may have 30 jobs queued or
processing at once, counting jobs from the web and the app too. Past that a
submit is refused with 429
USER_QUEUE_FULLand aRetry-After, before anything is charged. The script honoursRetry-Afteron every 429. - Polls in batches with
GET /v1/tts?ids=…, up to 50 ids per call, every 3 seconds — one request for the whole batch rather than one per job. Job states arequeued,processing,completedandfailed. - A failed job is sent once more under a new key. Failed jobs are refunded, and replaying the old key would only return the same failed job.
- Downloads each clip from its presigned
audioUrl(valid 24 hours) without sending your API key there, decodes it with ffmpeg, and speeds a clip up to 1.25× (--max-speed) to fit its window. - Places every clip at its start time. A clip that still runs over pushes
the next one later — the same rule
/v1/srtapplies — and the report marks that lineoverflowed.
Per-request ceilings on POST /v1/tts: 50,000 characters of text per job, and
the per-key synthesis rate limit (read the live value from X-RateLimit-Limit;
it is a deployment setting). A clone_… voice works when it is yours or was
published by VieNeu; anyone else's is a 400.
The script was run end to end against a local stand-in for the API (45 lines with a cloned voice, 429 and 409 responses, a failed job, a second run of the same file). Test it on a short file with your own key before a full episode.
Without code
- A track timed to the video: the web app's Dubbing page reads an
.srtat its timecodes and lets you download the audio, the subtitles or the dubbed video. See Read SRT files and dub. - Many files at once in the desktop app: Tạo hàng loạt (Batch) takes a
list of lines (
.txtor.json, a voice per row) or.srtfiles read as plain text. Each.srtbecomes one continuous reading, or one file per line if you choose that; timecodes are not kept, so use it for narration rather than lip-synced dubbing. The page offers ready-made templates to start from. To get the app, see Download and install the app.
See also
- Errors — every status the routes above can return.
- Webhooks — get told when a job finishes instead of polling.
- API reference —
createSrtDub,createTtsJob,getTtsJobs.