AI Voiceover API for Generated Video
Add narration to AI video with an AI voiceover API: write the script with a chat model, voice it with a speech model, and merge it onto a silent Seedance clip.
By OceanToken Team

Editor's note: Native audio from video models has become good enough that many teams stop thinking about voiceover at all. That works until a client asks for a second language, a changed product name or a script line moved two seconds later. Then a baked-in soundtrack means regenerating the whole clip. We think narration belongs on its own track, made by a speech model you can rerun in seconds without touching the render, and merged at the end.
Short answer: An AI voiceover API turns a script into narration you can lay over a generated clip. Ask a chat model for the script, send it to POST /v1/audio/speech with a speech model and one of that model's own voice names, generate the video silent with generate_audio: false, then merge the two tracks with ffmpeg.
Key takeaways:
- On OceanToken, the chat model that writes the script, the speech model that reads it and the video model that renders the clip are all called with one key and one base URL, so the whole pipeline is three requests in one script (docs.oceantoken.ai, checked November 28, 2026).
voiceis required, and its names belong to the model. Our docs list a voice tested on the live service formicrosoft/mai-voice-2; for MiniMax speech models, use the names MiniMax documents and test one first.microsoft/mai-voice-2is scheduled to retire on December 31, 2026, per our docs model list, so keep a second voice ready.response_format: "url"returns a JSON link instead of audio bytes, valid for 24 hours. Usemp3when your code saves the file directly.- Choose a separate voiceover when words change or come in several languages. Choose native audio when you need lip sync or ambient sound tied to the picture.
01 · How an AI voiceover API fits a video pipeline
A voiceover endpoint is a text-to-speech call used for one job: producing narration that runs alongside a video. The video and the voice are made separately and joined at the end, which is the opposite of a video model's native audio, where the soundtrack is generated with the picture.
The pipeline has four steps, and each one is a plain request or command:

- A chat model writes the narration for a clip of known length.
- A speech model reads the narration and returns an audio file.
- A video model renders the clip with sound turned off.
- ffmpeg puts the audio track onto the video.
Splitting it this way buys you independence between the parts. You can regenerate the voice without paying for a new clip, swap the speech model without touching the video code, and make five language versions from one render. If you have read our guide to one API for chat, image and video apps, this is the same idea extended to audio: one client, several model types, each doing the part it is good at. Our text-to-image-to-video pipeline guide covers the visual half of a similar chain.
The cost of the split is alignment. A video model does not know how long your narration is, and a speech model does not know how long your clip is. Most of the practical work in this article, especially section 07, is about making those two lengths agree.
02 · The speech request and its fields
The speech endpoint follows OpenAI's Audio API, so client.audio.speech in the OpenAI SDKs works once you change the base URL and key. The request is JSON and the default answer is the audio itself.
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.oceantoken.ai/v1",
api_key=os.environ["OCEANTOKEN_API_KEY"],
)
audio = client.audio.speech.create(
model="microsoft/mai-voice-2",
input="Every morning, the market wakes before the city does.",
voice="en-US-Jasper:MAI-Voice-1",
response_format="mp3",
)
audio.write_to_file("line-01.mp3")
Each field has a narrow job. These are the descriptions in our speech guide and the model references on November 28, 2026:
| Field | Required | What it does | Voiceover advice |
|---|---|---|---|
model |
Yes | A speech model's id | Keep it in config; you will try more than one |
input |
Yes | The text to read | Write it for the ear, not the eye (section 07) |
voice |
Yes | One of the model's own voice names | Never assume a name carries over between models |
response_format |
No | mp3, wav, opus, aac, flac, pcm or url |
mp3 is the safe default the guide recommends |
speed |
No | Pace from 0.25 to 4, default 1, on models that support it | Small nudges only; big changes sound unnatural |
instructions |
No | Tone notes such as "calm, slow", on models that support them | Test whether your model honors them |
Two of those fields come with "on models that support them," and that qualifier matters. OpenAI's own text-to-speech guide describes instructions as a way to steer accent, emotion, intonation and pace, and names gpt-4o-mini-tts as the model that supports it. Our docs do not say which speech models on our endpoint honor instructions. So send the same line with and without a tone note and listen; if the two files sound the same, the field is being ignored on that model.
The format list is wider than most voiceover jobs need. For a video merge, mp3 and wav cover nearly everything: mp3 is small and fine for narration, while wav is uncompressed and easier for some editing tools. OpenAI's guide describes pcm as raw 24 kHz samples with no header, which is useful for streaming playback but awkward in a file-based pipeline.
03 · Text to speech API: the voice is required, and names belong to the model
A text to speech API request without voice is refused with 400 on our endpoint, and a voice name the model does not know fails. That is the most common first error when people move speech code between models, because every publisher names its voices differently.
Our speech guide keeps a table of voices that were tested on the live service on September 26, 2026. That date is the docs team's test, not ours, and it is worth rechecking if you read this much later. For the models relevant to narration, here is what the docs and publishers say:
| Model | Publisher | response_format options |
Voice name to start with | Where the name comes from |
|---|---|---|---|---|
microsoft/mai-voice-2 |
Microsoft | mp3, wav, opus, aac, flac, pcm, url | en-US-Jasper:MAI-Voice-1 |
Our speech guide's tested voice table |
minimax/speech-2.8-hd |
MiniMax | mp3, wav, opus, aac, flac, pcm, url | A MiniMax system voice id | MiniMax's system voice list; our sample shows VOICE_NAME |
minimax/speech-2.8-turbo |
MiniMax | mp3, wav, opus, aac, flac, pcm, url | A MiniMax system voice id | Same as HD |
deepgram/aura-2 |
Deepgram | mp3, wav, opus, aac, flac, pcm, url | aura-2-thalia-en |
Our speech guide's tested voice table (2026-09-26) |
The docs model list shows no retirement date for deepgram/aura-2, which makes it the natural second voice to keep ready; you can find it and the other speech models in the model catalog.
The Mai Voice 2 model page describes it as an expressive text-to-speech model from Microsoft AI, suited to media narration among other uses, and its sample uses the same tested voice, which is why it leads the examples in this article.
The MiniMax rows need a careful reading. The API references for both MiniMax speech models on our docs use the placeholder VOICE_NAME in their samples, and the speech guide says that for any model outside its table you should use the voice names the publisher documents. MiniMax's own system voice list includes English ids such as English_expressive_narrator and English_Trustworth_Man, and it asks you to keep their case and internal spaces exactly. Whether those ids pass through unchanged on our endpoint is something we have not confirmed, so send one short line with a MiniMax id before you script a batch. If it fails, the error message is the fastest way to learn what the model expects.
There is also a date to plan around. The model list in our docs shows a scheduled retirement date of December 31, 2026 for microsoft/mai-voice-2 and for microsoft/mai-voice-2-flash. A pipeline built only on that voice needs a second speech model ready before then. That is one more argument for keeping the model and voice in configuration rather than in code: when the date arrives, you change two strings and re-listen.
Pick voices by listening, not by name. A narrator voice that sounds right for a product demo can sound wrong over a slow travel montage. Generate the same two sentences with three or four candidate voices, play each over the actual clip, and choose with the picture in front of you.
04 · TTS API: get an MP3 link instead of the audio bytes
To get an MP3 link instead of the audio bytes from the TTS API, set "response_format": "url". The answer becomes JSON with a link to an MP3, its content type, its size and the number of input characters used.
{"url": "https://...", "content_type": "audio/mpeg", "bytes": 48213, "usage": {"input_characters": 41}}
That example is the one in our speech guide. The link is valid for 24 hours, and the clip also shows up in the console's Media page, which keeps generated files for 30 days.
The link form is the better choice in three situations. When a browser plays the narration, handing it a URL is simpler than streaming bytes through your server. When the next step is another API call that accepts a file link, you skip a download and re-upload. And when you want the character count for your own accounting, usage.input_characters arrives with the link.
The bytes form is better when your own code does the merge. The ffmpeg step needs a local file, and downloading from a link is just an extra hop. It also removes the 24-hour clock: with bytes, the file is yours the moment the call returns.
Whichever you use, do not treat the link as storage. Download what you intend to keep. A render queue that depends on a day-old link will fail quietly, the same way it would with a video content_url, which also expires after 24 hours.
05 · Native audio vs voiceover for AI video
Native audio is the better choice when sound has to match the picture, and a voiceover is the better choice when the words have to stay editable. The decision is less about quality than about what you will need to change later.
Several video models on our endpoint make sound with the clip when you set generate_audio: true. Seedance 2.5's API reference, for example, describes generate_audio as true for a clip with sound and false for a silent one. Native audio can include speech, effects and ambience timed to what happens on screen. Our Seedance lip-sync and dialogue prompting guide covers getting characters to speak on camera.

| What you need | Use | Why |
|---|---|---|
| A character speaking on camera with lip sync | Native audio | The mouth and the words are generated together |
| Footsteps, rain, crowd noise tied to the action | Native audio | Timing comes from the picture |
| A narrator who never appears on screen | Voiceover | Nothing on screen needs to match the voice |
| The same clip in several languages | Voiceover | One render, one voice file per language |
| Script likely to change after review | Voiceover | Regenerate seconds of audio, not the clip |
| Exact wording that legal or a client must approve | Voiceover | The text you send is the text you hear |
| Music bed under narration | Voiceover plus your own music | You control levels in the mix |
The two approaches also combine. You can render with native audio for ambience, then duck it and lay narration on top in the merge step. That keeps the sense of place while the words stay under your control. The only thing to avoid is native dialogue plus a narrator saying different things at the same time.
06 · End to end in Python: script, voice, silent clip, merge
This script runs the whole chain with one client and one key. It asks a chat model for narration sized to the clip, voices it, renders a silent Seedance clip, and merges the two. It is a general pattern built from our docs, not a pipeline we have benchmarked.
The one unusual part is calibration. Every voice reads at its own pace, so instead of guessing how many words fit in a clip, the script voices a known sentence first, measures it with ffprobe, and uses that pace to set the word budget.
import os, time, uuid, subprocess
import requests
from openai import OpenAI
KEY = os.environ["OCEANTOKEN_API_KEY"]
BASE = "https://api.oceantoken.ai/v1"
client = OpenAI(base_url=BASE, api_key=KEY)
CLIP_SECONDS = 10
SPEECH_MODEL = "microsoft/mai-voice-2"
VOICE = "en-US-Jasper:MAI-Voice-1"
# After 2026-12-31: SPEECH_MODEL = "deepgram/aura-2"; VOICE = "aura-2-thalia-en"
CHAT_MODEL = "minimax/minimax-m3"
VIDEO_MODEL = "bytedance/seedance-2.5"
def duration(path):
out = subprocess.run(
["ffprobe", "-v", "error", "-show_entries", "format=duration",
"-of", "default=nw=1:nk=1", path],
capture_output=True, text=True, check=True)
return float(out.stdout.strip())
def speak(text, path):
audio = client.audio.speech.create(
model=SPEECH_MODEL, voice=VOICE, input=text, response_format="mp3",
extra_headers={"Idempotency-Key": str(uuid.uuid4())})
audio.write_to_file(path)
return duration(path)
# 1. Calibrate this voice's pace
sample = "The quick brown fox jumps over the lazy dog near the quiet river bank."
pace = len(sample.split()) / speak(sample, "calibrate.mp3") # words per second
budget = int(pace * (CLIP_SECONDS - 1)) # leave a breath at the end
# 2. Script
chat = client.chat.completions.create(
model=CHAT_MODEL,
messages=[{"role": "user", "content":
f"Write voiceover narration for a {CLIP_SECONDS}-second shot of a night "
f"market opening. At most {budget} words. Plain sentences, no stage "
f"directions, spell out numbers."}])
script = chat.choices[0].message.content.strip()
# 3. Voice
voice_len = speak(script, "voice.mp3")
print(f"narration {voice_len:.1f}s for a {CLIP_SECONDS}s clip")
# 4. Silent clip
H = {"Authorization": f"Bearer {KEY}"}
job = requests.post(f"{BASE}/videos",
headers={**H, "Idempotency-Key": str(uuid.uuid4())},
json={"model": VIDEO_MODEL, "prompt": "A night market opening, lanterns "
"switching on one by one, slow dolly forward",
"duration": CLIP_SECONDS, "resolution": "720p",
"generate_audio": False}).json()
while job["status"] in ("queued", "in_progress"):
time.sleep(15)
job = requests.get(f"{BASE}/videos/{job['id']}", headers=H).json()
if job["status"] != "completed":
raise SystemExit(job.get("error"))
with open("clip.mp4", "wb") as f:
f.write(requests.get(job["content_url"]).content)
# 5. Merge: keep the video stream, add the narration
subprocess.run(["ffmpeg", "-y", "-i", "clip.mp4", "-i", "voice.mp3",
"-map", "0:v", "-map", "1:a", "-c:v", "copy", "-c:a", "aac",
"-af", "apad", "-shortest", "final.mp4"], check=True)
A few lines deserve comment. extra_headers lets the speech call carry an Idempotency-Key; our docs recommend that key on speech requests so a retry after a timeout does not make, and charge, the clip twice. The video request uses its own key for the same reason. The merge copies the video stream without re-encoding, which is fast and keeps the picture untouched, and encodes the narration to AAC, which MP4 players expect.
apad pads the narration with silence and -shortest then ends the file at the clip's length, so a short narration keeps the whole clip and a long one is cut at the last frame, which is the failure the print in step 3 warns you about. For finishing work in an editor instead of ffmpeg, our guide to editing clips in CapCut and Premiere covers the timeline side.
07 · Fitting the voice to the clip
Narration that runs past the end of the clip is the most common problem in this pipeline, and the fix is almost always the script, not the audio. There are four levers, in the order we would use them.
Shorten the script. The calibration step gives you a word budget for the voice you chose. If the narration still runs long, ask the chat model to cut it to a smaller budget. Fewer words read naturally always beat the same words read faster.
Nudge speed. The speech endpoint takes speed from 0.25 to 4 on models that support it. A small change can close a small gap. Large changes tend to sound rushed or dragged, so treat it as fine-tuning, and confirm your model honors it by comparing two files.
Lengthen the clip. Video models take a range of durations. Seedance 2.5's reference lists 4 to 30 seconds, so a narration that needs twelve seconds can simply get a twelve-second clip. This costs a new render, so it is the lever for when the script is final.
Pad the audio. When the narration is shorter than the clip, that is usually fine: silence at the end reads as a pause. If you want the voice to start a beat later, delay it in the merge with ffmpeg's adelay filter instead of regenerating anything.
Pronunciation is the second thing to check, and it is mostly a writing problem. Speech models read what you send. Write numbers, dates and units as words when the reading matters, spell out abbreviations the way you want them heard, and check brand names and personal names by ear on every voice you try. The prompt in step 2 already asks the chat model to spell out numbers, which removes the most common surprise.
There is also a disclosure question. OpenAI's text-to-speech guide says its usage policies require telling end users that a voice they hear is AI-generated. That rule is OpenAI's, but the practice is a sensible default for any synthetic narration you publish, and some platforms have their own labeling rules for AI audio.
08 · Cost units, retries and the files you keep
Speech is charged per character of input, or by token on Gemini voices, according to our speech guide. Video, by contrast, is charged per clip according to its length, resolution and sound. The practical consequence is the stance of this article: a changed line means re-voicing only that text, so regenerate the voice when the words change and render the video as few times as possible.
Retries need one rule. Send an Idempotency-Key on every speech and video request, and keep the same key when you retry the same body. Our errors page says a retry with the same key and body replays the first answer instead of running again. Change the key when you change the text, because a reused key with a different body is refused with 409.
Because links expire, as section 04 explains, your master narration, the silent render and the merged output should live in your own storage, alongside the script text that produced them, so any line can be regenerated later.
How to test this on your workload
We have not run these checks for you. Each one is a single request or a short script, and together they tell you which speech model and voice to build on.
- Voice names. Send one short line to
microsoft/mai-voice-2withen-US-Jasper:MAI-Voice-1, and one to each MiniMax speech model with a MiniMax system voice id such asEnglish_expressive_narrator. Record which names are accepted. - Missing voice. Send a request without
voiceand confirm the400, so your error handling expects it. - Pace. Run the calibration step for every candidate voice and write down the measured words per second. Use your own numbers, not anyone else's.
- Speed and instructions. Generate the same line at default speed, with a small
speedchange, and with aninstructionsnote. Listen for whether each change is honored. - Link vs bytes. Request the same line with
mp3and withurl. Check that the link's file matches, and noteusage.input_characters. - Pronunciation. Voice a paragraph with your product names, a date, a price written as words and an abbreviation. Fix the script until every voice reads it right.
- Merge. Run the full script on one ten-second clip. Watch the output for sync, levels and any cut-off at the end.
- Retirement plan. Repeat step 1 with
deepgram/aura-2andaura-2-thalia-en, the backup for after December 31, 2026, and keep both strings in config.
Our take: Generate video silent and add narration as its own track whenever the words might change or exist in more than one language. A voice line is quick to redo and a video render is not, so put the parts that change on the quick side. Keep native audio for lip-synced dialogue and for sound that has to follow the action on screen.
Running it on OceanToken
The base URL is https://api.oceantoken.ai/v1. Speech goes to POST /v1/audio/speech, chat to POST /v1/chat/completions and video to POST /v1/videos. The model ids in this article are microsoft/mai-voice-2, minimax/speech-2.8-hd, minimax/speech-2.8-turbo, minimax/minimax-m3 and bytedance/seedance-2.5. What helps for voiceover work, from our docs as of November 28, 2026:
- One key for script, voice and video. The chat model, the speech model and the video model all answer the same key and balance, which is why the end-to-end script above needs one client and no second account.
- OpenAI SDK, unchanged. Speech follows OpenAI's Audio API, so
client.audio.speechcode moves by changing the base URL and key, and switching speech models is themodelandvoicestrings. - Retries that do not bill twice. Speech and video both accept an
Idempotency-Key, and afailedvideo job is not charged. - Prepaid, billed per character for speech. No subscription; each model page shows its unit.
Price: see the current rate on the Mai Voice 2, Speech 2.8 HD and Speech 2.8 Turbo model pages and on /minimax-api. For the video side, see /video, /seedance-api and the Seedance 2.5 model page.
FAQ
Is the voice field required in a text to speech API request? On our endpoint, yes. A request without voice is refused with 400, and the name must be one the model knows.
Can I use the same voice name on every speech model? No. Voice names belong to each model. Use the tested names in our speech guide, or the names the model's publisher documents, and test one line first.
How do I get a link to the MP3 instead of the audio bytes? Set response_format to url. You get JSON with the link, its size and the input character count; download it within 24 hours.
Should I use native audio or a voiceover for AI video? Native audio for lip sync and on-screen sound, voiceover for narration that may change or needs several languages. You can also combine them in the merge.
How do I make the narration fit the clip length? Measure the voice's pace on a sample sentence, size the script to the clip, then fine-tune with speed or a longer clip.
Is microsoft/mai-voice-2 going away? Our docs model list shows a scheduled retirement date of December 31, 2026. Keep a second speech model and voice ready in config.
Sources
- docs.oceantoken.ai: Speech and transcription (checked 2026-11-28)
- docs.oceantoken.ai: Video guide (checked 2026-11-28)
- docs.oceantoken.ai: Mai Voice 2 API reference (checked 2026-11-28)
- docs.oceantoken.ai: Speech 2.8 HD API reference (checked 2026-11-28)
- docs.oceantoken.ai: Console, Media (checked 2026-11-28)
- Mai Voice 2 model page (checked 2026-11-28)
- OpenAI: Text to speech guide (checked 2026-11-28)
- MiniMax: System voice ID list (checked 2026-11-28)
Get your OceanToken API key
- Create an OceanToken account and an API key.
- Copy the snippet below, paste your key, and run it.
- Check the current rate on /minimax-api and the Mai Voice 2 model page.
curl https://api.oceantoken.ai/v1/audio/speech \
-H "Authorization: Bearer $OCEANTOKEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "microsoft/mai-voice-2", "input": "Every morning, the market wakes before the city does.", "voice": "en-US-Jasper:MAI-Voice-1", "response_format": "mp3"}' \
--output voice.mp3
The voice name in this snippet is the one our speech guide lists as tested for this model.
More from the blog
Veo 3.1 Reference Images API Guide
How to send reference images to Veo 3.1 through the API: input_references vs first frame, which tiers take them, two-shot Python script and a consistency test.
LLM Function Calling API Across Models
Write one LLM function calling API loop that works across GPT, Claude, Gemini, Qwen, GLM and DeepSeek: tool_choice, streaming and the silent no-call trap.
LLM Image Input API: Screenshots and Scans
Send screenshots, photos and scans to a chat model with one LLM image input API: URL vs base64 data URL, per-model image limits, the 400 error and token costs.