BobaBanana API

Talking videos: lip-synced speech in a cloned or saved voice

POST /v1/videos with voice and script, or with audio, makes a character speak with lip sync. The voice is a saved library voice ("@handle") or a voice cloned from a 5 to 30 second sample you send with voice_consent: true. Talking videos are made at 720p, from 2 to 10 seconds.

View as Markdown

At a glance

Endpoint
POST /v1/videos with voice + script, or audio
Auth
Authorization: Bearer bb_...
Returns
202 with a job; output.video.url (MP4) and output.speech.url (WAV)
Price keys
video_voice, video_voice_ref or video_voice_frames, plus speech (and transcribe without a transcript)
Key limits
script up to 600 characters; 720p only; not with motion_video
Consent
voice_consent: true with every uploaded voice sample
Idempotent
yes, with an Idempotency-Key header

Three ways to make a character speak#

Three ways to make a character speak
Way Send Use it when
Clone a voice voice: a sample object + script + voice_consent: true You have a recording of the voice
Use a saved voice voice: "@handle" + script The voice is saved in your library
Drive the clip with your own audio audio: a media input You already have the speech or soundtrack

Each works with any start: image, a generated frame from prompt (with references or not), last_frame or extend_video. Not with motion_video, and not at 1080p or 2160p.

Clone a voice#

Send the sample in voice, the words in script and voice_consent: true.

curl
curl https://bobabanana.com/api/v1/videos \
  -H "Authorization: Bearer $BOBABANANA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "image": {
      "url": "https://example.com/presenter.png"
    },
    "motion": "she talks to the camera, small natural gestures",
    "voice": {
      "url": "https://example.com/my-voice.wav",
      "transcript": "Hi, this is a short sample of my voice for cloning."
    },
    "voice_consent": true,
    "script": "Welcome back! Today I will show you three quick tips.",
    "duration_seconds": 6
  }'
Python
import os
import uuid

import requests

r = requests.post(
    "https://bobabanana.com/api/v1/videos",
    headers={"Authorization": f"Bearer {os.environ['BOBABANANA_API_KEY']}", "Idempotency-Key": str(uuid.uuid4())},
    json={
        "image": {
            "url": "https://example.com/presenter.png",
        },
        "motion": "she talks to the camera, small natural gestures",
        "voice": {
            "url": "https://example.com/my-voice.wav",
            "transcript": "Hi, this is a short sample of my voice for cloning.",
        },
        "voice_consent": True,
        "script": "Welcome back! Today I will show you three quick tips.",
        "duration_seconds": 6,
    },
    timeout=60,
)
r.raise_for_status()
print(r.json())
JavaScript
const res = await fetch("https://bobabanana.com/api/v1/videos", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BOBABANANA_API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": crypto.randomUUID(),
  },
  body: JSON.stringify({
    "image": {
      "url": "https://example.com/presenter.png"
    },
    "motion": "she talks to the camera, small natural gestures",
    "voice": {
      "url": "https://example.com/my-voice.wav",
      "transcript": "Hi, this is a short sample of my voice for cloning."
    },
    "voice_consent": true,
    "script": "Welcome back! Today I will show you three quick tips.",
    "duration_seconds": 6
  }),
});
if (!res.ok) throw new Error(JSON.stringify(await res.json()));
console.log(await res.json());

A voice sample is one of file_id, url or data, plus an optional transcript (up to 1000 characters) of the exact words in the recording. Without a transcript, the sample is transcribed first: a short extra step, priced as transcribe. A sample is accepted from 2 to 60 seconds; 5 to 30 seconds of one person speaking clearly works best. Upload it once with POST /v1/files and reuse its file_id.

Clone only your own voice or a voice whose speaker gave you explicit permission. voice_consent: true records that confirmation with the job; without it, a sample is refused with 400 voice_consent_required. A saved @handle voice needs no consent field.

Use a saved voice#

{
  "prompt": "@captain_fox on the deck of a ship in a storm",
  "assets": [
    "@captain_fox"
  ],
  "motion": "he grips the wheel and shouts",
  "voice": "@storyteller",
  "script": "Hold on, everyone!",
  "sound_effect": {
    "prompt": "storm wind and crashing waves",
    "duration_seconds": 6
  },
  "duration_seconds": 6
}

This example also mixes in a generated sound effect. List saved voices with GET /v1/voices.

Drive the clip with your own audio#

Send recorded speech or a soundtrack as audio and the clip follows it. Leave out voice and script.

{
  "image": {
    "url": "https://example.com/singer.png"
  },
  "audio": {
    "url": "https://example.com/line.mp3"
  },
  "motion": "she sings to the camera",
  "duration_seconds": 8
}

Audio formats: AAC, FLAC, M4A, MP3, MP4, OGG, OPUS, WAV, WEBM, up to 60 MB.

Script length#

Aim for about 2.5 words per second of video: a 6 second clip fits about 15 words. script takes up to 600 characters, and a longer script does not make the clip longer; set duration_seconds to fit the words.

Limits#

  1. 720p only: voice, script and audio at 1080p or 2160p are 400 invalid_request.
  2. A voice needs a script and a script needs a voice: one without the other is 400 invalid_request.
  3. Audio or voice, not both: send audio or voice + script.
  4. Not with motion transfer: a motion_video job keeps the clip's own sound instead.

Errors for this page#

Errors for this page
Status Code Meaning What to do
400 invalid_audio The audio could not be read. Send a valid WAV, MP3, M4A, OGG or FLAC file.
400 invalid_request A field is missing, has the wrong type or breaks a rule. param names the field. Type and range problems found while reading the body are 422 with the same code. Read error.param and error.message, fix that field and send again. Do not retry unchanged.
400 invalid_voice_sample The voice sample is too short or too long. Use 5 to 30 seconds of one person speaking clearly.
400 voice_consent_required A voice sample was sent without voice_consent: true. Set voice_consent: true only if the voice is yours or you have the speaker's explicit permission.
400 wrong_asset_kind The asset is the wrong kind for this field (for example a voice used as a picture). Use GET /v1/assets?kind=... to find an asset of the right kind.
400 wrong_file_type An image was given where audio is needed, or the other way round. Send the kind of file the field asks for; param names the field.
404 asset_not_found No approved library asset with this @handle or id. List assets with GET /v1/assets and use a handle from there.
503 engine_unavailable This kind of generation is not available right now. Retry after Retry-After seconds; GET /v1/status shows what is available. Retry-After: 300 s.

Frequently asked questions#

How much audio do I need to clone a voice?#

5 to 30 seconds of clean speech from one person, with no music. Samples from 2 to 60 seconds are accepted; outside that the request is 400 invalid_voice_sample.

Do I need a transcript of the sample?#

No, but it helps. With transcript the speech step starts at once; without it the sample is transcribed first, priced as transcribe.

Can I reuse a cloned voice without sending the sample every time?#

Send the same file_id each time: an upload a job uses is kept. To get an @handle, save the voice in the studio's library and use voice: "@handle".

Is the speech returned on its own?#

Yes. When the job succeeds, output.speech.url is the generated speech as a WAV file, next to output.video.url.

Last updated · View as Markdown · llms.txt