Generate Talking Avatar

Create a talking avatar video by combining a reference image and an audio clip.

Request

Use POST /v1/video/async_generate_talking_avatar with base64-encoded image and audio.

import requests
import base64

api_key = "YOUR_API_KEY"
base_url = "https://api.mirako.ai/v1"
headers = {"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}

# Encode reference image
with open("avatar_face.png", "rb") as img_f:
    image_b64 = base64.b64encode(img_f.read()).decode("utf-8")

# Encode audio file
with open("speech.wav", "rb") as audio_f:
    audio_b64 = base64.b64encode(audio_f.read()).decode("utf-8")

payload = {
    "image": image_b64,
    "audio": audio_b64
}

response = requests.post(
    f"{base_url}/video/async_generate_talking_avatar",
    headers=headers,
    json=payload
)
response.raise_for_status()
task_id = response.json()["data"].get("task_id")
print(f"Talking avatar video task started: {task_id}")

Checking Task Status

status_resp = requests.get(
    f"{base_url}/video/async_generate_talking_avatar/{task_id}/status",
    headers=headers
)
status_resp.raise_for_status()
status = status_resp.json()["data"]
print(f"Status: {status.get('status')}")

if status.get("status") == "succeeded":
    video_url = status.get("result", {}).get("url")
    print(f"Video URL: {video_url}")

Note: Ensure your audio is clear and your image is well-cropped for best results.

Dive deeper