Skip to content

Commit 197170d

Browse files
mose-x.zmkevinlin09
authored andcommitted
Add input.audio_url to support wan2.5 video generation
1 parent 075ca37 commit 197170d

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

samples/VideoSynthesisUsage.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ public static void basicCall() throws ApiException, NoApiKeyException, InputRequ
1717
VideoSynthesis vs = new VideoSynthesis();
1818
VideoSynthesisParam param =
1919
VideoSynthesisParam.builder()
20-
.model(VideoSynthesis.Models.WANX_2_1_I2V_TURBO)
21-
// prompt not required
22-
// .prompt("一只戴着绿色眼镜的小狗")
23-
// .imgUrl("https://modelscope.oss-cn-beijing.aliyuncs.com/resource/dog.jpeg")
24-
.imgUrl("file:///Users/xxx/Documents/source/dog.jpeg")
20+
.model("wan2.5-t2v-preview")
21+
.prompt("一只戴着绿色眼镜的小狗在唱rap")
22+
.audioUrl("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3")
2523
.build();
2624
VideoSynthesisResult result = vs.call(param);
2725
System.out.println(result);

src/main/java/com/alibaba/dashscope/aigc/videosynthesis/VideoSynthesisParam.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public class VideoSynthesisParam extends HalfDuplexServiceParam {
5252
/** The input image url, Generate the URL of the image referenced by the video */
5353
@Builder.Default private String imgUrl = null;
5454

55+
/** The input audio url. */
56+
@Builder.Default private String audioUrl = null;
57+
5558
/** The extra parameters. */
5659
@GsonExclude @Singular protected Map<String, Object> extraInputs;
5760

@@ -77,6 +80,8 @@ public class VideoSynthesisParam extends HalfDuplexServiceParam {
7780

7881
@Builder.Default private Boolean watermark = null;
7982

83+
@Builder.Default private Boolean audio = null;
84+
8085
/** The inputs of the model. */
8186
@Override
8287
public JsonObject getInput() {
@@ -99,6 +104,9 @@ public JsonObject getInput() {
99104
if (imgUrl != null && !imgUrl.isEmpty()) {
100105
jsonObject.addProperty(IMG_URL, imgUrl);
101106
}
107+
if (audioUrl != null && !audioUrl.isEmpty()) {
108+
jsonObject.addProperty(AUDIO_URL, audioUrl);
109+
}
102110

103111
if (firstFrameUrl != null && !firstFrameUrl.isEmpty()) {
104112
jsonObject.addProperty(FIRST_FRAME_URL, firstFrameUrl);
@@ -153,6 +161,9 @@ public Map<String, Object> getParameters() {
153161
if (watermark != null) {
154162
params.put(WATERMARK, watermark);
155163
}
164+
if (audio != null) {
165+
params.put(AUDIO, audio);
166+
}
156167
params.putAll(super.getParameters());
157168
return params;
158169
}
@@ -184,6 +195,7 @@ public void validate() throws InputRequiredException {}
184195
public void checkAndUpload() throws NoApiKeyException, UploadFileException {
185196
Map<String, String> inputChecks = new HashMap<>();
186197
inputChecks.put(IMG_URL, this.imgUrl);
198+
inputChecks.put(AUDIO_URL, this.audioUrl);
187199
inputChecks.put(FIRST_FRAME_URL, this.firstFrameUrl);
188200
inputChecks.put(LAST_FRAME_URL, this.lastFrameUrl);
189201
inputChecks.put(HEAD_FRAME, this.headFrame);
@@ -195,6 +207,7 @@ public void checkAndUpload() throws NoApiKeyException, UploadFileException {
195207
this.putHeader("X-DashScope-OssResourceResolve", "enable");
196208

197209
this.imgUrl = inputChecks.get(IMG_URL);
210+
this.audioUrl = inputChecks.get(AUDIO_URL);
198211
this.firstFrameUrl = inputChecks.get(FIRST_FRAME_URL);
199212
this.lastFrameUrl = inputChecks.get(LAST_FRAME_URL);
200213
this.headFrame = inputChecks.get(HEAD_FRAME);

src/main/java/com/alibaba/dashscope/utils/ApiKeywords.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ public class ApiKeywords {
150150

151151
public static final String IMG_URL = "img_url";
152152

153+
public static final String AUDIO_URL = "audio_url";
154+
153155
public static final String REF_IMG = "ref_img";
154156

155157
public static final String MODALITIES = "modalities";

0 commit comments

Comments
 (0)