Digital Human Offline Synthesis OpenAPI

更新时间:
复制 MD 格式

Version history

Version

Description

Time

v0.8

  1. Modifying a digital human video synthesis task

    1. Added voice modification rules for TTS versions.

    2. Added pitch and emotion parameters to scripts.

    3. Added a language field to scripts.

  2. Updates to the query voice model API

    1. Response parameter: ttsVersion

  3. Added voice cloning APIs

    1. Submit a voice cloning task.

    2. Batch query voice cloning task information.

  4. The voice model list now supports queries by language. The default is Chinese.

  5. Upgraded the software development kit (SDK) version.

2025-03-13

v0.7

  1. Query the list of digital human avatars and add a digital human category

  2. Added APIs for photo-based digital humans.

  3. Added the anchorStyleLevel request parameter to the API for submitting digital human video synthesis tasks.

  4. Updated the SDK version.

2024-12-18

v0.6

Added the speed parameter to the API for submitting digital human video synthesis tasks.

Upgraded the SDK version.

2024-10-25

v0.5

Added the speechOpen parameter to the API for submitting digital human video synthesis tasks. Added voice modification rules and an academic phonetic chart.

2024-09-29

v0.4

Digital human video synthesis now supports Basic Edition digital humans. Added a material volume adjustment field. Added a voice model version response parameter to voice models.

Upgraded the SDK version.

2024-09-09

v0.3

Added an API to batch query digital human video synthesis information. Upgraded the SDK to 2.3.0.

2024-08-20

v0.2

Added the transparent background feature to the API for submitting digital human video synthesis tasks.

2024-07-31

v0.1

Feature release.

2024-07-01

Overview

Interaction example

image.jpeg

Prerequisites

  1. Prepare an Alibaba Cloud account. Use a RAM user to generate an AccessKey ID and an AccessKey secret.

  2. The main Alibaba Cloud account must grant RAM authorization to the RAM user that generated the AccessKey.

  3. Log on to the platform with the main Alibaba Cloud account and sign the relevant legal agreements.

API details

1. Submit a digital human video synthesis task

SubmitProjectTask

1.1. Request parameters

Parameter name

Type

Required

Description

scaleType

string

Yes

The aspect ratio. Valid values: 9:16, 16:9.

9:16: The frame width is 1080 and the height is 1920.

16:9: The frame width is 1920 and the height is 1080.

subtitleTag

int

Yes

Specifies whether to enable captions. 0: No.

Captions are not supported for digital humans.

transparentBackground

int

No

The transparent background switch. 1: On, 0: Off. The default is 0.

Do not add materials if the transparent background is enabled.

frames

List<OpenFrame>

Yes

The video frames. You can add up to 50 frames.

OpenFrame

Parameter

Type

Required

Description

index

int

Yes

The frame sequence number. The minimum value is 1. Each frame in a single submission must have a unique sequence number.

layers

List<OpenLayer>

Yes

The layers. A frame can have up to 10 layers.

videoScript

OpenVideoScript

Yes

The script information.

subtitle

OpenSubtitle

Required when captions are enabled.

The caption settings.

OpenVideoScript

Parameter name

Type

Required

Description

type

string

Yes

Text/Audio: TEXT/AUDIO

audioUrl

string

Required for audio type.

The URL of the audio file. The maximum duration is 10 minutes.

textContent

string

Required for text type.

The audio text. If ttsVersion is 3, LabTex syntax is supported.

voiceTemplateId

long

Required for text type.

The voice model ID. This must match the anchor.

volume

int

Required for text type.

The volume. The range is from 0 to 100. The recommended value is 50.

speedRate

string

Required for text type.

The speech rate. The range is from 0.8 to 2.0. A value of 1 indicates a normal speech rate. Only one decimal place is supported.

speechOpen

boolean

No

Specifies whether to enable voice modification. true: On. The default is false.

pitchRate

String

No

The pitch. The range is from -12 to 12. The default is 0. This is supported only by TTS versions 3 and 4.

emotion

String

No

The emotion. Valid values: "happy", "sad", "angry", "fearful", "disgusted", "surprised", "neutral". This is supported only by TTS versions 3 and 4.

voiceLanguage

String

Yes

The language. Pass the language field returned by the query voice model API.

OpenLayer

Parameter

Type

Required

Description

type

string

Yes

ANCHOR: Anchor

BACKGROUND: Background. Do not pass this value if the transparent background is enabled.

Material

material

OpenMaterial

Yes

The layer material.

index

int

Required for non-background layers.

The layer sequence number. The minimum value is 1. Each layer in a frame must have a unique sequence number in a single submission. Do not specify this for the background.

positionX

int

Required for non-background layers.

The x-coordinate of the layer. Do not specify this for the background. For more information, see Coordinate description.

positionY

int

Required for non-background layers.

The y-coordinate of the layer. Do not specify this for the background. For more information, see Coordinate description.

width

int

Required for non-background layers.

The layer width. Do not specify this for the background. The value cannot exceed the frame width.

height

int

Required for non-background layers.

The layer height. Do not specify this for the background. The value cannot exceed the frame height.

The background layer must fill the entire frame and is at the bottom by default.

  • By default, the width and height of the background layer are equal to the width and height of the frame.

  • By default, the positionX and positionY of the background layer are 0.

OpenMaterial Anchor/Material

Parameter

Type

Required

Description

id

string

Required for anchor layers.

The anchor ID.

url

string

Required for non-anchor layers.

The material URL (an HTTP address).

format

string

Required for non-anchor layers.

The material format. Valid values: video/mp4, image/png,

image/jpg, image/jpeg.

volume

int

No

The video volume. The range is from 0 to 100. The recommended value is 50. This is supported only for the video/mp4 format.

speed

string

No

The video playback speed. The range is from 0.8 to 5.0. The default is 1.

anchorStyleLevel

string

No

The motion posture and amplitude for the photo-based digital human.

NORMAL: Normal, CALM: Calm, ACTIVE: Active.

OpenSubtitle Caption

Parameter

Type

Required

Description

positionX

int

Yes

The x-coordinate. For more information, see Caption description.

positionY

int

Yes

The y-coordinate. For more information, see Caption description.

font

string

Yes

The font. Example: SimSun. For more information, see Font description.

fontSize

int

Yes

The font size. The allowed range is from 32 to 160.

fontColor

string

Yes

The text color in hexadecimal format, prefixed with #. Example: #ffffff.

alignment

string

Yes

The alignment.

  • BottomLeft: Aligns to the bottom left of the caption box.

  • BottomCenter: Aligns to the bottom center of the caption box.

  • BottomRight: Aligns to the bottom right of the caption box.

backgroundColor

string

No

The background color in RGB hexadecimal format, prefixed with #. Example: #ffffff.

maxCharLength

int

Yes

The maximum number of characters per line. We recommend setting this to text box width / font width.

textWidth

int

Yes

The text box width. For more information, see Caption description.

textHeight

int

Yes

The text box height. For more information, see Caption description.

1.1.1. Font description

  • Alibaba PuHuiTi

  • FZKai-Z03S - Founder KaiTi Simplified

  • FZHei-B01S - Founder HeiTi Simplified

  • FZShuSong-Z01S - Founder ShuSong Simplified

  • FZFangSong-Z02S - Founder FangSong Simplified

  • SimSun

  • WenQuanYi MicroHei - WenQuanYi Micro Hei

  • WenQuanYi Zen Hei Mono (WenQuanYi Monospace Zen Hei)

  • WenQuanYi Zen Hei Sharp - WenQuanYi Bitmap Zen Hei

  • Microsoft YaHei

  • Yuanti SC - YuanTi SC Regular

  • Roboto Bold - Google Roboto font, does not support Chinese.

  • Roboto - Google Roboto font, does not support Chinese.

  • KaiTi - Regular Script

  • SiYuan Heiti - Source Han Sans

  • SiYuan SimSun - Source Han Serif

  • HappyZcool-2016 - ZCOOL KuaiLe

1.1.2. Coordinate description

  • The coordinate parameters for anchors, materials, and watermarks represent the distance from the top-left corner of the frame to the top-left corner of the image.

  • If a coordinate value includes a decimal, the decimal part is discarded. For example, in the following figure, X=470 and Y=700.

1.1.3. Layers outside the frame

  • Images that extend beyond the frame are cropped.

  • The width and height of the cropped image are used.

  • Out-of-bounds coordinates on the x- and y-axes are set to 0.

image.png

Cropped image:

image.png

Effect within the frame:

image.png

1.1.4. Caption description

The following figure shows an example of the parameters.

{
    "positionX": 68, // Captions cannot be outside the frame. Minimum: 0. Maximum: frame width.
    "positionY": 392, // Captions cannot be outside the frame. Minimum: 0. Maximum: frame height.
    "maxCharLength": 7, // Maximum characters per line. Recommended: text box width / font width.
    "textWidth": 800, // Text box width. The text box cannot be outside the frame.
    "textHeight": 110, // Text box height. Must be greater than the font size.
    "fontSize": 100, // Font size.
    "font": "SiYuan SimSun",
    "fontColor": "#090707",
    "alignment": "BottomRight", // Align right.
    "backgroundColor": "#fefefe"
}

image.png

1.1.5. Background example

The image provided for the background layer must fill the entire canvas. You do not need to specify coordinate values because the system defaults to X=0 and Y=0.

image.png

1.1.6. Voice modification rules

When the type of the OpenVideoScript object is TEXT, you can configure voice modification. To modify the voice, set the speechOpen parameter of OpenVideoScript to true and place the content of the textContent field within the voice modification tags. The rules are as follows:

Tag

Description

Example

Supported TTS versions

<speak>

The root element. The <speak></speak> tags are required regardless of which other SSML tags you use.

<speak>This sentence has no SSML syntax effects.</speak>

The supported values are 0, 2, 3, and 4.

<break time="2.5s" />

Inserts a pause in the text. The time attribute sets the pause duration, from 0s to 10s.

<speak> The weather today is<break time="2.5s" />great. </speak>

The supported values are 0, 2, 3, and 4.

<word>

A connected speech tag. The specified phrase is not split. This tag can only be applied to Chinese text.

<speak> Nanjing City <word>Changjiang Bridge</word>. </speak>

Example of a nested pinyin tag: <speak><word>Changjiang<phoneme alphabet="py" ph="da1">Da</phoneme>qiao</word></speak>

0 supports connected speech but does not support nested pinyin tags.

2 Support

<phoneme alphabet="py" ph="xi1 xi1">

Specifies the pronunciation for the text within the tag. This tag can only be applied to Chinese text.

The ph attribute specifies the pinyin. Only one pinyin is supported.

  • The numbers 1 to 4 correspond to the four tones of Mandarin Chinese, and 5 corresponds to the neutral tone. For example, the pinyin for the word "father" (bàba) is written as "ba4 ba5".

<speak> <phoneme alphabet="py" ph="xi1">Xi</phoneme> Princess </speak>

The supported values are 0, 2, 3, and 4.

<phoneme alphabet="ipa" ph="æ">

Specifies the English pronunciation using the International Phonetic Alphabet (IPA). The ph attribute specifies the IPA transcription.

  • The text within the tag is not required to be a real word. The pronunciation is determined by the value of "ph".

  • The text within the tag cannot contain punctuation, spaces, or other non-English alphabetic characters.

<speak><phoneme alphabet="ipa" ph="æ">a</phoneme>, apple. It means apple. </speak>

2. Support

<sub alias="text replacement">

Replaces the enclosed text with the specified text. Currently, this is only applicable to Chinese voices.

<speak><sub alias="Speech Synthesis Markup Language">SSML</sub></speak>

0, 2, 3, 4

Complete example:

String textContent = "<speak> <sub alias="replacement">I am text replacement</sub> <phoneme alphabet="ipa"ph="æ">a</phoneme>, apple. It means apple.<phoneme alphabet="py"ph="xi1">Xi</phoneme> Princess , Nanjing City <word>Changjiang Bridge</word>. The weather today is<break time="2.5 s" />great. </speak>"

1.1.7. Academic phonetic chart

Original word

Academic IPA (supported by this system)

Educational IPA (common in the market)

Vowels

i

ɪ

ɪ

ɛ

e

æ

æ

ɑ

ɔ

ɔː

ʊ

ʊ

u

ʌ

ʌ

ə

ə

ɚ

ər

ɝ

ɜːr

ɔɪ

ɔɪ

Consonants

p

p

b

b

t

t

d

d

k

k

ɡ

g

dʒ or ʤ

f

f

v

v

θ

θ

ð

ð

s

s

z

z

ʃ

ʃ

ʒ

ʒ

h

h

m

m

n

n

ŋ

ŋ

j

j

w

w

ɹ

r

l

l

1.1.8. LabTex syntax

Currently, only voice models with a ttsVersion of 3 support LabTex syntax.

  • Formulas in the request must be enclosed in double dollar signs ($$).

  • If a formula in the request contains a backslash (\), it must be escaped as a double backslash (\\).

Example: The basic formula for a derivative is $$\\frac{d}{dx}(x^n) = nx^{n-1}$$

1.2. Response parameters

Parameter

Type

Description

success

boolean

true: Successful, false: Failed.

errorMessage

string

The error message.

errorCode

string

The error code.

taskId

string

The task ID.

2. Query digital human video synthesis information

GetProjectTask

2.1. Request parameters

Parameter name

Type

Required

Description

taskId

String

Yes

The task ID.

2.2. Response parameters

Parameter Name

Type

Description

status

String

The synthesis status. IN_PROGRESS: Synthesizing, FAIL: Failed,

SUCCESS: Successful, CANCEL: Canceled.

errorMsg

String

The reason for the synthesis failure.

videoDuration

String

The video duration.

videoUrl

String

The video URL.

3. Batch query digital human video synthesis information

BatchGetProjectTask

3.1. Request parameters

Parameter name

Type

Required

Description

taskIdList

List<String>

Yes

A list of task IDs.

3.2. Response parameters

Parameter name

Type

Description

resultList

List<Object>

The video information.

Object description

status

String

The synthesis status. IN_PROGRESS: Synthesizing, FAIL: Failed,

SUCCESS: Successful, CANCEL: Canceled.

errorMsg

String

The reason for the synthesis failure.

videoDuration

String

The video duration.

videoUrl

String

The video URL.

4. Stop a synthesis task

StopProjectTask

4.1. Request parameters

Parameter name

Type

Required

Description

taskId

String

Yes

The task ID.

4.2. Response parameters

Parameter Name

Type

Description

success

boolean

true: The request was successful. false: The request failed. This only indicates the result of the submission. To confirm if the task has actually stopped, call the "Query digital human video synthesis information" API and check the task status.

errorCode

String

The error code.

errorMsg

String

The reason for the failure.

5. Query resource information

API: SelectResource

5.1. Request parameters

None

5.2. Response parameters

Parameter Name

Type

Description

resourceInfoList

List<ResourceInfo>

Information about remaining resources.

ResourceInfo

Parameter Name

Type

Description

resourceType

Integer

The resource type. 2: AI video generation duration.

remainCount

Integer

The amount of remaining resources.

unit

String

The unit of the remaining resources. second: seconds.

lastExpire

Integer

The number of days until the resources expire.

6. Query digital human avatar models

ListAnchor

6.1. Request parameters

Parameter Name

Type

Required

Description

coverRate

string

No

Streamer Image Aspect Ratio

9:16: Portrait

16:9: Landscape

anchorType

string

N

The anchor type.

PUBLIC_MODEL: Public model

PRIVATE_MODEL: Private model

By default, public models (PUBLIC_MODEL) are queried.

digitalHumanType

string

N

Streamer type:

dynamicReality is a dynamic, real-scene digital human (temporarily unavailable). staticTransparency is a static digital human.

photoTransparentBg

Photo-based digital human with a transparent background

Non-transparent photo background

Digital Human with a Standard Photo Background

useScene

string

Yes

Scenarios

offlineSynthesis: Offline digital human

anchorCategory

string

N

v0.7 Digital Human Classification

DEFAULT_ANCHOR - Preset avatar (default value) PHOTO_ANCHOR - Photo avatar

VIDEO_ANCHOR: Video-based broadcast

pageSize

int

Yes

The page size.

pageNumber

int

Y

The page number.

6.2. Response parameters

Parameter name

Parameter type

Description

total

int

The total number of entries.

list

array: AnchorResponse

An array of anchor avatar objects.

success

Boolean

Indicates whether the request was successful.

errorMessage

String

The error message.

errorCode

String

Error codes

AnchorResponse

Parameter name

Parameter type

Description

anchoId

String

The anchor ID.

anchorMaterialName

String

The anchor name.

anchorType

String

The anchor type.

PUBLIC_MODEL: Public model

PRIVATE_MODEL: Private model

coverUrl

String

Model thumbnail

coverThumbnailUrl

String

Model thumbnail

coverWeight

int

The width of the thumbnail image in pixels.

coverHeight

int

The height of the thumbnail image in pixels.

coverRate

String

The thumbnail aspect ratio.

status

String

The status.

Usable: Published

digitalHumanType

String

Streamer type:

dynamicReality: A dynamic, realistic digital human (temporarily unavailable). staticTransparency: A static digital human.

Photo Background Transparency

Photorealistic digital human with a transparent background

photoNonTransparentBg

Photo-based digital human on a standard background

useScene

String

Scenarios

offlineSynthesis: Offline digital human

resourceTypeDesc

String

The resource specification description.

gender

String

The gender. F: Female, M: Male. This must match the gender of the voice model.

7. Query voice models

ListVoiceModels

7.1. Request parameters

Parameter name

Parameter type

Required

Description

voiceType

String

N

The voice type.

PRIVATE_VOICE: Private model voice

PUBLIC_VOICE: Public model voice

By default, public voices (PUBLIC_VOICE) are queried.

useScene

string

Yes

The scenario.

offlineSynthesis: Offline digital human

voiceLanguage

string

N

The language. The default value is Chinese (zh).

Enumeration:

Chinese

English

Spanish

French

French: French

German

German: German

Russian: Russian

Indonesian: Indonesian

Japanese: Japanese

pageSize

int

Yes

The page size.

pageNumber

int

Yes

The page number.

7.2. Response parameters

Parameter name

Parameter type

Description

total

int

The total number of entries.

list

array: VoiceModelResult

A collection of audio script templates.

success

Boolean

Indicates whether the request was successful.

errorMessage

String

The error message.

errorCode

String

The error code.

VoiceModelResponse

Parameter Name

Parameter type

Description

voiceId

bigInt

The voice model ID.

voiceName

String

The voice name.

voiceModel

String

The voice model (parameter value).

voiceGender

String

M: Male voice, F: Female voice. This must match the gender of the avatar.

voiceUrl

String

The URL of the audio sample.

voiceLanguage

String

The language. zh: Chinese, en: English.

voiceDesc

String

The voice model description.

useScene

String

Scenarios

offlineSynthesis: Offline digital human

resourceTypeDesc

String

The resource specification description.

ttsVersion

Integer

The TTS version. Valid values: 0, 1, 2, 3, 4.

TTS versions 3 and 4:

Do not support phonetic replacement, connected speech, or captions.

Support emotions.

The currently supported emotions are happy, sad, angry, fearful, disgusted, surprised, and neutral. The parameter values are ["happy", "sad", "angry", "fearful", "disgusted", "surprised", "neutral"]. The default is empty.

Support pitch. The range is from -12 to 12.

The default is 0.

8. Create a digital human

createAnchor

8.1. Request parameters

Parameter name

Type

Required

Description

anchorMaterialName

String

Yes

The name of the digital human avatar.

coverUrl

String

Required for photo-based digital humans.

The thumbnail image of the digital human avatar.

videoOssKey

String

Required for video-based digital humans.

The OSS address.

gender

String

Yes

The gender. M: Male, F: Female.

useScene

String

Yes

Scenarios

offlineSynthesis: Offline digital human

digitalHumanType

String

Yes

The anchor category.

For photo-based digital humans, you can choose:

photoTransparentBg: Photo-based digital human with a transparent background

photoNonTransparentBg: Photo-based digital human with a regular background

For video-based digital humans, you can choose:

dynamicReality: Dynamic real-life digital human

staticTransparency: Static transparent digital human

anchorCategory

String

N

The anchor type.

PHOTO_ANCHOR: Photo-based digital human (default)

VIDEO_ANCHOR: Video-based digital human

8.2. Response parameters

Parameter name

Parameter type

Description

data

String

The digital human ID.

success

Boolean

Indicates whether the request was successful.

errorMessage

String

The error message.

errorCode

String

Error codes

9. Submit a voice cloning task

CreateTrainTask

9.1. Request parameters

Parameter name

Type

Required

Description

taskType

String

Yes

The task type. Example: CopyAnchorAndVoice - Clones the voice and avatar. (Currently, only the voice is cloned.)

useScene

String

Yes

The scenario. Example: realTimeInteractivity - Real-time / offlineSynthesis - Offline

resSpecType

String

Yes

The resource specification type. Example: BASIC_MODEL - Foundation model / STANDARD_VOICE - Standard model

voiceLanguage

String

Yes

The language. Example: zh - Chinese, en - English.

voiceName

String

Yes

The voice name. Example: TestVoiceMale. This must be a unique value.

voicePat

String

Yes

The voice material URL. Example: https://yic-pre/video/test-0513.mp3

voiceGender

String

Yes

The voice gender. Example: M - Male / F - Female

9.2. Response parameters

Parameter

Type

Description

taskId

String

Task ID: 1111

10. Batch query voice cloning task information

BatchGetTrainTask

10.1. Request parameters

Parameter Name

Type

Required

Description

taskIdList

Array

Yes

A list of task IDs.

10.2. Response parameters

Parameter

Type

Description

voiceList

List<Object>

A list of voice information.

Object description

Parameter

Type

Description

taskId

String

The input task ID.

createTime

String

The creation time. Format: yyyy-MM-dd HH:mm:ss.

taskType

String

The task type. Example: CopyVoice - Clone voice.

aliyunSubId

String

RAM user

useScene

String

The scenario. Example: realTimeInteractivity - Real-time / offlineSynthesis - Offline.

resSpecType

String

The resource specification. Example: BASIC_MODEL - Foundation model / STANDARD_VOICE - Standard model.

name

String

The name. Example: TestVoiceMale.

gender

String

The gender. Example: M - Male, F - Female.

voiceMaterial

VoiceMaterial

The voice material information.

auditStatus

String

The review status. Example: waitAudit - Awaiting review, auditSuccess - Review approved, auditFail - Review rejected.

trainStatus

String

The training status. Example: trainInit - Awaiting training, trainSuccess - Training successful, trainFail - Training failed.

auditFailMessage

String

The reason for the review rejection.

trainFailMessage

String

The reason for the training failure.

VoiceMaterial information

Parameter name

Type

Description

voiceLanguage

String

The language. Example: zh.

voiceUrl

String

The URL of the voice material.

voiceId

Long

The voice model ID.

11. Get an OSS upload signature

API: GetOssUploadToken

11.1.1. Request parameters

Parameter

Type

Required

Description

Example value

fileName

String

Yes

The name of the file to upload. Do not use duplicate file names.

Test Video

fileType

String

Yes

The scenario for the uploaded file. VIDEO_ANCHOR: Video-based broadcast.

VIDEO_ANCHOR

uploadType

String

Yes

The upload method. 1: Upload using a signed URL.

1

11.1.2. Response parameters

Parameter

Type

Description

Example value

url

String

The file upload URL.

http://oss.xxxxx

key

String

The OSS key.

api/test.mp4

Integration details

PHP

Integration example

require 'vendor/autoload.php';
use AlibabaCloud\SDK\Imarketing\V20220704\Models\GetOssUploadSignatureRequest;
use AlibabaCloud\SDK\IntelligentCreation\V20240313\IntelligentCreation;
use Darabonba\OpenApi\Models\Config as AlibabaConfig;

$config = new AlibabaConfig();
$config->accessKeyId = '****';
$config->accessKeySecret = '****';
$config->endpoint = "intelligentcreation.cn-zhangjiakou.aliyuncs.com";

$intelligentCreationClient = new IntelligentCreation($config);

$request = new GetProjectTaskRequest();
$request->taskId = '1111';
try {
  $response = $intelligentCreationClient->getProjectTask($request);
  var_dump($response->toMap());
} catch (TeaError $e) {
  Log::error($e);
}

2.12.0

composer require alibabacloud/intelligentcreation-20240313 2.12.0

Java

Integration example

package com.aliyun.intelligentcreation20240313;

import com.aliyun.intelligentcreation20240313.models.*;
import com.aliyun.tea.TeaException;
import com.aliyun.teaopenapi.models.Config;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.util.HashMap;
import java.util.Map;

public class TestProjectTest {

    public static void main(String[] args) throws Exception {
        TestProjectTest testProjectTest = new TestProjectTest();

        try {
           String taskId = testProjectTest.submitProjectTaskRequest();
           testProjectTest.stopProjectTaskRequest(taskId);
           testProjectTest.getProjectTaskRequest(taskId);
           testProjectTest.selectResourceRequest(null);
            testProjectTest.listVoiceModelsRequest();
            System.out.println(taskId);
        } catch (TeaException e) {
            Gson gson = new Gson();
            System.out.println(e.getMessage());
            System.out.println(gson.toJson(e.getData()));
        } catch (Exception e) {

            e.printStackTrace();
        }


    }

    String url = "intelligentcreation.cn-zhangjiakou.aliyuncs.com";
    // Initialize the configuration.
    Config config = new Config().setAccessKeyId("**")
            .setAccessKeySecret("**")
            .setEndpoint(url);
    // Create a client.
    Client client = new Client(config);

    public TestProjectTest() throws Exception {
    }


    String submitProjectTaskRequest() throws Exception {
        Gson gson = new Gson();
        String para = "{\"scaleType\":\"16:9\",\"subtitleTag\":1,\"frames\":[{\"index\":1,\"layers\":[{\"type\":\"BACKGROUND\",\"material\":{\"format\":\"image/png\",\"url\":\"https://yic-pre.oss-cn-hangzhou.aliyuncs.com/common/image/backgroundImage/shu/1.png\"}},{\"type\":\"MATERIAL\",\"material\":{\"format\":\"image/png\",\"url\":\"https://yic-pre.oss-cn-hangzhou.aliyuncs.com/1539704706413278/image/material/1716348615967-%E5%86%B0%E6%B7%87%E6%B7%8B.png\"},\"index\":2,\"positionX\":76,\"positionY\":1169,\"width\":549,\"height\":750},{\"type\":\"ANCHOR\",\"material\":{\"id\":\"759459670880206851\",\"url\":\"https://yic-pre.oss-cn-hangzhou.aliyuncs.com/1539704706413278/image/anchor/1715148681933-55254f81420c4c82954042414136e52d.png\"},\"index\":3,\"positionX\":0,\"positionY\":0,\"width\":1080,\"height\":1920},{\"type\":\"WATERMARK\",\"material\":{\"type\":\"WATERMARK\",\"format\":\"image/png\",\"url\":\"https://yic-pre.oss-cn-hangzhou.aliyuncs.com/common/image/material/%E6%B0%B4%E5%8D%B003%403x.png"},\"index\":4,\"positionX\":248,\"positionY\":280,\"width\":191,\"height\":195}],\"videoScript\":{\"textContent\":\"Let's witness the perfect fusion of technology and medicine and move forward together.\",\"type\":\"TEXT\",\"voiceTemplateId\":82,\"volume\":50,\"speedRate\":1.5},\"subtitle\":{\"positionX\":0,\"positionY\":545,\"maxCharLength\":6,\"textWidth\":1080,\"fontSize\":60,\"font\":\"Microsoft YaHei\",\"fontColor\":\"#2a313d\",\"textHeight\":70,\"alignment\":\"BottomCenter\"}}]}";

        Map<String, Object> map = gson.fromJson(para, new TypeToken<Map<String, Object>>() {
        }.getType());

        SubmitProjectTaskRequest request = SubmitProjectTaskRequest.build(map);
        // Call the API.
        SubmitProjectTaskResponse response = client.submitProjectTask(request);

        System.out.println(gson.toJson(response));

        if (response.getStatusCode().equals(200)) {
            System.out.println("submitProjectTaskRequest request successful");
            return response.getBody().getTaskId();
        }
        return null;
    }

    void getProjectTaskRequest(String taskId) throws Exception {
        Gson gson = new Gson();

        Map<String, Object> map = new HashMap<>();
        map.put("taskId", taskId);

        GetProjectTaskRequest request = GetProjectTaskRequest.build(map);
        // Call the API.
        GetProjectTaskResponse response = client.getProjectTask(request);

        System.out.println(gson.toJson(response));

        if (response.getStatusCode().equals(200)) {
            System.out.println("getProjectTaskRequest request successful");
        }
    }

    void stopProjectTaskRequest(String taskId) throws Exception {
        Gson gson = new Gson();

        Map<String, Object> map = new HashMap<>();
        map.put("taskId", taskId);

        StopProjectTaskRequest request = StopProjectTaskRequest.build(map);
        // Call the API.
        StopProjectTaskResponse response = client.stopProjectTask(request);

        System.out.println(gson.toJson(response));

        if (response.getStatusCode().equals(200)) {
            System.out.println("stopProjectTaskRequest request successful");
        }
    }

    void selectResourceRequest(String projectId) throws Exception {
        Gson gson = new Gson();
        Map<String, Object> map = new HashMap<>();
        SelectResourceRequest request = SelectResourceRequest.build(map);
        SelectResourceResponse response = client.selectResource(request);

        System.out.println(gson.toJson(response));
        if (response.getStatusCode().equals(200)) {
            System.out.println("selectResourceRequest request successful");
        }
    }

    void listVoiceModelsRequest() throws Exception {
        Gson gson = new Gson();
        Map<String, Object> map = new HashMap<>();
        map.put("useScene", "offlineSynthesis");
        map.put("pageSize", 1);
        map.put("pageNumber", 10);
        ListVoiceModelsRequest request = ListVoiceModelsRequest.build(map);
        ListVoiceModelsResponse response = client.listVoiceModels(request);

        System.out.println(gson.toJson(response));
        if (response.getStatusCode().equals(200)) {
            System.out.println("listVoiceModelsRequest request successful");
        }
    }
}