文档

EMO 视频生成 API详情

更新时间:

EMO模型,可基于通过EMO-detect模型检测的人物肖像图片和人声音频文件生成视频。本文档介绍了该模型提供的视频生成能力的API调用方法。

模型概览

模型名

模型简介

emo

emo是一个人物视频生成模型,可基于人物肖像图片和人声音频文件生成人物肖像动态视频。

HTTP调用接口

功能描述

用于生成人物头像、半身像动态视频。不推荐用于生成人物全身像动态视频。

因该算法调用耗时较长,故采用异步调用的方式提交任务。任务提交之后,系统会返回对应的作业 ID,后续可通过对应的异步作业查询接口获取任务状态以及在作业结束后取回对应结果。

前提条件

  • 已开通服务并获得API-KEY:获取API-KEY

  • 输入图像已通过EMO 图像检测 API检测,并获得对应人脸区域动态区域的范围值作为入参。

  • 输入音频包含清晰、响亮的人声语音,并去除了环境噪音、背景音乐等声音干扰信息。

作业提交接口调用

POST https://dashscope.aliyuncs.com/api/v1/services/aigc/image2video/video-synthesis/

入参描述

字段

类型

传参方式

必选

描述

示例值

Content-Type

String

Header

请求类型:application/json

application/json

Authorization

String

Header

API-Key,例如:Bearer d1**2a

Bearer d1**2a

X-DashScope-Async

String

Header

使用 enable,表明使用异步方式提交作业。

enable

model

String

Body

指明需要调用的模型,填入在百炼平台部署成功的模型名称

emo-xxx

input.image_url

String

Body

用户上传的图片 URL,该图应先通过EMO图像检测API。最终用于视频生成的图片会按input.ext_bbox所指定的区域进行裁剪。

1:1图像对应生成512*512的头像视频;3:4图像对应生成512*704的半身像视频。

图像最小边长≥400,最大边长≤7000,格式支持:jpg、png、jpeg、bmp、webp

http://aaa/bbb.jpg

input.audio_url

String

Body

用户上传的音频文件 URL, 用于EMO模型推理的输入。

音频文件<15M , 时长<20s,格式支持:wav、mp3

http://aaa/bbb.wav

input.face_bbox

Array

Body

图片中人脸区域 bbox,应输入“EMO 图像检测 API”出参中同名字段的值。

[10,20,30,40]

input.ext_bbox

Array

Body

图片中动态区域 bbox,应输入“EMO 图像检测 API”出参中同名字段的值。

该区域的宽高比应为1:1或3:4。

[10,20,30,40]

parameters.style_level

String

Body

可选择动作风格强度控制人物的运动姿态和幅度,当前支持3种:normal、calm、active,分别对应人物动作风格适中、平静、活泼。默认为normal。

normal

出参描述

字段

类型

描述

示例值

output.task_id

String

提交异步任务的作业id,实际作业结果需要通过异步任务查询接口获取。

a8532587-fa8c-4ef8-82be-0c46b17950d1

output.task_status

String

提交异步任务后的作业状态。

“PENDING”

request_id

String

本次请求的系统唯一码。

7574ee8f-38a3-4b1e-9280-11c33ab46e51

请求示例

curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/image2video/video-synthesis/' \
--header 'X-DashScope-Async: enable' \
--header 'Authorization: Bearer <YOUR_API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
    "model": "<YOUR_MODEL>",
    "input": {
        "image_url": "http://xxx/1.jpg",
        "audio_url": "http://xxx/1.wav",
        "face_bbox": [10, 20, 30, 40],
        "ext_bbox": [10, 20, 30, 40]
        },
        "parameters": {
            "style_level": "normal"
        }
    }'

响应示例

{
    "output": {
        "task_id": "a8532587-fa8c-4ef8-82be-0c46b17950d1", 
        "task_status": "PENDING"
    }
    "request_id": "7574ee8f-38a3-4b1e-9280-11c33ab46e51"
}

作业任务状态查询和结果获取接口

GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}

入参描述

字段

类型

传参方式

必选

描述

示例值

Authorization

String

Header

API-Key,例如:Bearer d1**2a

Bearer d1**2a

task_id

String

Url Path

需要查询作业的task_id

a8532587-fa8c-4ef8-82be-0c46b17950d1

出参描述

字段

类型

描述

示例值

output.task_id

String

查询作业的 task_id

a8532587-fa8c-4ef8-82be-0c46b17950d1

output.task_status

String

被查询作业的作业状态

任务状态:

PENDING 排队中

RUNNING 处理中

SUCCEEDED 成功

FAILED 失败

UNKNOWN 作业不存在或状态未知

output.results

Array

如果作业成功,包含模型生成的结果 object,然后每个object中包含按照要求生成的结果地址

"video_url":"https://xxx/1.mp4"

output.results.video_url

Array

生成的视频文件

usage.video_duration

float

本次请求生成视频时长计量

"video_duration": 2

request_id

String

本次请求的系统唯一码

7574ee8f-38a3-4b1e-9280-11c33ab46e51

请求示例

curl -X GET \
--header 'Authorization: Bearer <YOUR_API_KEY>' \
https://dashscope.aliyuncs.com/api/v1/tasks/<YOUR_TASK_ID>

响应示例(作业成功执行完毕)

{
    "output": {
        "task_id": "ae453190-cc37-4250-9e57-a71d5927090e",
        "task_status": "SUCCEEDED",
        "results": {
              "video_url": "https://xxx/1.mp4"
        }
    },
    "usage": {
        "video_duration": 20
    },
    "request_id": "efaa9f4b-fb15-90c8-8df5-cd8fcb1c46bc"
}

响应示例(作业失败)

{
    "output": {
        "task_id": "a8532587-fa8c-4ef8-82be-0c46b17950d1", 
        "task_status": "FAILED",
        "code": "xxx", 
        "message": "xxxxxx", 
    },
    "request_id": "7574ee8f-38a3-4b1e-9280-11c33ab46e51" 
}

状态码说明

大模型服务平台通用状态码请查阅:状态码说明

同时,本模型还有如下特定错误码:

http 返回码*

错误码(code)

错误信息(message)

含义说明

400

InvalidParameter

The request is missing required parameters or in a wrong format, please check the parameters that you send.

入参格式不对

400

InvalidParameter

The style_level is invalid.

style_level不在枚举范围内

400

InvalidURL

The request URL is invalid, please check the request URL is available and the request image format is one of the following types: JPEG, JPG, PNG, BMP, and WEBP.

输入图片下载失败,请检查网络或者输入格式

400

InvalidURL

Required URL is missing or invalid, please check the request URL

输入的URL不正确或缺失

400

InvalidURL

The input audio is longer than **!

输入的音频文件超过最大时长**秒

400

InvalidURL

File size is larger than 15MB

输入的音频文件超过最大限制15M

400

InvalidURL

File type is not supported. Allowed types are: .wav, .mp3

输入的音频格式不合规,当前支持wav、mp3

400

InvalidFile.Content

The input image has no human body. Please upload other image with single person.

输入图片中没有人

400

InvalidFile.Content

The input image has multi human bodies. Please upload other image with single person.

输入图片中有多人

400

InvalidFile.BodyProportion

The proportion of the detected person in the picture is too large or too small, please upload other image.

上传图片中人物占比不符合要求

400

InvalidFile.Resolution

The image resolution is invalid, please make sure that the largest length of image is smaller than 7000, and the smallest length of image is larger than 400.

上传图片大小不符合要求

400

InvalidFile.Value

The value of the image is invalid, please upload other clearer image.

上传图片过暗不符合要求

400

InvalidFile.FrontBody

The pose of the detected person is invalid, please upload other image with the front view.

上传图片中人物背身不符合要求

400

InvalidFile.FullFace

The pose of the detected face is invalid, please upload other image with whole face.

上传图片中人物面部姿态不符合要求(要求面部可见)

400

InvalidFile.FacePose

The pose of the detected face is invalid, please upload other image with the expected oriention.

上传图片中人物面部姿态不符合要求(要求面部朝向无严重偏移)