SadTalker

Audio-based Lip Synchronization for Talking Head Video

~119.20s
~$0.184
 1import requests
 2import json
 3
 4url = "https://api.segmind.com/v1/sadtalker"
 5headers = {
 6    "x-api-key": "YOUR_API_KEY",
 7    "Content-Type": "application/json"
 8}
 9
10data = {
11    "input_image": "https://segmind-sd-models.s3.amazonaws.com/display_images/sad_talker/sad-talker-input.png",
12    "input_audio": "https://segmind-sd-models.s3.amazonaws.com/display_images/sad_talker/sad_talker_audio_input.mp3",
13    "pose_style": 4,
14    "expression_scale": 1.4,
15    "preprocess": "full",
16    "image_size": "256",
17    "enhancer": true,
18    "base64": false
19}
20
21response = requests.post(url, headers=headers, json=data)
22
23if response.status_code == 200:
24    result = response.json()
25    print(json.dumps(result, indent=2))
26else:
27    print(f"Error: {response.status_code}")
28    print(response.text)

API Endpoint

POSThttps://api.segmind.com/v1/sadtalker

Parameters

input_audiorequired
string (uri)

Input audio file. Avoid special symbol in the filename as it may cause ffmpeg erros.

Default: "https://segmind-sd-models.s3.amazonaws.com/display_images/sad_talker/sad_talker_audio_input.mp3"
input_imagerequired
string (uri)

Input image of a talking-head.

Default: "https://segmind-sd-models.s3.amazonaws.com/display_images/sad_talker/sad-talker-input.png"
base64optional
boolean

Base64 encoding of the output image.

Default: false
enhanceroptional
boolean

Enhance the output video

Default: true
expression_scaleoptional
number

A larger value will make the expression motion stronger

Default: 1.4Range: 1 - 3
image_sizeoptional
integer

The image size of the facerender

Default: 256
Allowed values :
256512
pose_styleoptional
integer

Pose Style

Default: 4Range: 0 - 45
preprocessoptional
string

Method to preprocess the image

Default: "full"
Allowed values :
"crop""extcrop""resize""full""extfull"

Response Type

Returns: Video

Common Error Codes

The API returns standard HTTP status codes. Detailed error messages are provided in the response body.

400

Bad Request

Invalid parameters or request format

401

Unauthorized

Missing or invalid API key

403

Forbidden

Insufficient permissions

404

Not Found

Model or endpoint not found

406

Insufficient Credits

Not enough credits to process request

429

Rate Limited

Too many requests

500

Server Error

Internal server error

502

Bad Gateway

Service temporarily unavailable

504

Timeout

Request timed out