Prerequisites
- You have an API key. If not, you can get one by contacting us.
- You have python installed on your machine along with the
requests
library
Step 1 (Optional): Create a video resource
If you have an existing video you want to use as a reference, follow this step.
This is where your face, expressions and voice are taken from. If the file is
larger than 5MB, follow the
Upload Large Resources guide
and note the resource_id
. If not, you can
upload it directly.
Step 2: Create a script to personalize the video
files = {
"file": (
"text.txt",
bytes(
"Hey Pranav, how do you make videos at Verbalia today?",
"utf-8",
),
"text/plain",
)
}
data = {
"resource_name": "pranav-text",
"resource_type": "text",
}
script_response = requests.post(
base_url + "/resources/upload", files=files, params=data, headers=headers
)
if script_response.status_code != 200:
print(f"Failed to upload file. Status code: {script_response.status_code}")
print("Response:", script_response.text)
sys.exit(1)
print("Upload successful", script_response.json())
Step 3: Create a generation request body
This is just a regular generation, but the way you use your own face, expressions
and voice is by providing your reference video’s resource_id
for the face and
voice.
body = {
"avatar": {
"face": "resource-video-qV1ApL",
"voice": "resource-video-qV1ApL",
},
"script": {
"resource_id": "resource-text-5qyAQV",
"type": "text"
},
"output": {
"resolution": "512"
},
}
generation_response = requests.post(
base_url + "/generate-video", json=body, headers=headers
)
Step 4: Poll for the status and download the video
while True:
time.sleep(60)
response = requests.get(
base_url + "/status/" + generation_response.json()["request_id"],
headers=headers,
)
print(response.json())
if response.json()["status"] not in ["pending", "processing"]:
break
if response.json()["status"] == "completed":
video_response = requests.get(response.json()["video_url"])
with open("verbalia_personalize.mp4", "wb") as f:
f.write(video_response.content)
print("Downloaded video to verbalia_personalize.mp4")
To personalize to multiple audiences, repeat steps 2-4 with different
scripts.