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)
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
POST
https://api.segmind.com/v1/sadtalker
Parameters
input_audio
requiredstring (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_image
requiredstring (uri)
Input image of a talking-head.
Default:
"https://segmind-sd-models.s3.amazonaws.com/display_images/sad_talker/sad-talker-input.png"
base64
optionalboolean
Base64 encoding of the output image.
Default:
false
enhancer
optionalboolean
Enhance the output video
Default:
true
expression_scale
optionalnumber
A larger value will make the expression motion stronger
Default:
1.4
Range: 1 - 3image_size
optionalinteger
The image size of the facerender
Default:
256
Allowed values :
256
512
pose_style
optionalinteger
Pose Style
Default:
4
Range: 0 - 45preprocess
optionalstring
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