Skip to content

Commit f0dfb8a

Browse files
author
mose-x.zm
committed
support wan27 add case
1 parent 5954c96 commit f0dfb8a

2 files changed

Lines changed: 113 additions & 10 deletions

File tree

dashscope/aigc/video_synthesis.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def call( # type: ignore[override]
6464
tail_frame: str = None,
6565
first_frame_url: str = None,
6666
last_frame_url: str = None,
67-
media: list = None,
67+
media: List[Dict] = None,
6868
**kwargs,
6969
) -> VideoSynthesisResponse:
7070
"""Call video synthesis service and get result.
@@ -152,7 +152,7 @@ def _get_input( # pylint: disable=too-many-branches
152152
tail_frame: str = None,
153153
first_frame_url: str = None,
154154
last_frame_url: str = None,
155-
media: list = None,
155+
media: List[Dict] = None,
156156
**kwargs,
157157
):
158158
inputs = {PROMPT: prompt, "extend_prompt": extend_prompt}
@@ -339,7 +339,7 @@ def async_call( # pylint: disable=arguments-renamed # type: ignore[override] #
339339
tail_frame: str = None,
340340
first_frame_url: str = None,
341341
last_frame_url: str = None,
342-
media: list = None,
342+
media: List[Dict] = None,
343343
**kwargs,
344344
) -> VideoSynthesisResponse:
345345
"""Create a video synthesis task, and return task information.
@@ -354,7 +354,7 @@ def async_call( # pylint: disable=arguments-renamed # type: ignore[override] #
354354
audio_url (str): The input audio url.
355355
reference_video_urls (List[str]): list of character reference video file urls uploaded by the user # pylint: disable=line-too-long
356356
reference_urls (List[str]): list of character reference file urls uploaded by the user # pylint: disable=line-too-long
357-
reference_url str: reference file url uploaded by the user # pylint: disable=line-too-long
357+
reference_url (str): reference file url uploaded by the user # pylint: disable=line-too-long
358358
reference_video_description (List[str]): For the description information of the picture and sound of the reference video, corresponding to ref video, it needs to be in the order of the url. If the quantity is different, an error will be reported # pylint: disable=line-too-long
359359
api_key (str, optional): The api api_key. Defaults to None.
360360
workspace (str): The dashscope workspace id.
@@ -558,7 +558,7 @@ async def call( # type: ignore[override] # pylint: disable=arguments-renamed #
558558
tail_frame: str = None,
559559
first_frame_url: str = None,
560560
last_frame_url: str = None,
561-
media: list = None,
561+
media: List[Dict] = None,
562562
**kwargs,
563563
) -> VideoSynthesisResponse:
564564
"""Call video synthesis service and get result.
@@ -573,7 +573,7 @@ async def call( # type: ignore[override] # pylint: disable=arguments-renamed #
573573
audio_url (str): The input audio url.
574574
reference_video_urls (List[str]): list of character reference video file urls uploaded by the user # pylint: disable=line-too-long
575575
reference_urls (List[str]): list of character reference file urls uploaded by the user # pylint: disable=line-too-long
576-
reference_url str: reference file url uploaded by the user # pylint: disable=line-too-long
576+
reference_url (str): reference file url uploaded by the user # pylint: disable=line-too-long
577577
reference_video_description (List[str]): For the description information of the picture and sound of the reference video, corresponding to ref video, it needs to be in the order of the url. If the quantity is different, an error will be reported # pylint: disable=line-too-long
578578
api_key (str, optional): The api api_key. Defaults to None.
579579
workspace (str): The dashscope workspace id.
@@ -661,7 +661,7 @@ async def async_call( # type: ignore[override] # pylint: disable=arguments-rena
661661
tail_frame: str = None,
662662
first_frame_url: str = None,
663663
last_frame_url: str = None,
664-
media: list = None,
664+
media: List[Dict] = None,
665665
**kwargs,
666666
) -> VideoSynthesisResponse:
667667
"""Create a video synthesis task, and return task information.
@@ -676,7 +676,7 @@ async def async_call( # type: ignore[override] # pylint: disable=arguments-rena
676676
audio_url (str): The input audio url.
677677
reference_video_urls (List[str]): list of character reference video file urls uploaded by the user # pylint: disable=line-too-long
678678
reference_urls (List[str]): list of character reference file urls uploaded by the user # pylint: disable=line-too-long
679-
reference_url str: reference file url uploaded by the user # pylint: disable=line-too-long
679+
reference_url (str): reference file url uploaded by the user # pylint: disable=line-too-long
680680
reference_video_description (List[str]): For the description information of the picture and sound of the reference video, corresponding to ref video, it needs to be in the order of the url. If the quantity is different, an error will be reported # pylint: disable=line-too-long
681681
api_key (str, optional): The api api_key. Defaults to None.
682682
workspace (str): The dashscope workspace id.

samples/test_video_synthesis.py

Lines changed: 105 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
prompt = "一只小猫在月光下奔跑"
77
audio_url = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3"
8-
reference_video_urls = [
8+
reference_urls = [
99
"https://test-data-center.oss-accelerate.aliyuncs.com/wanx/video/resources/with_human_voice_11s.mov",
1010
]
1111
api_key = os.getenv("DASHSCOPE_API_KEY")
@@ -16,7 +16,7 @@ def simple_call():
1616
rsp = VideoSynthesis.call(
1717
api_key=api_key,
1818
model="wan2.6-r2v",
19-
reference_video_urls=reference_video_urls,
19+
reference_urls=reference_urls,
2020
shot_type="multi",
2121
audio=True,
2222
watermark=True,
@@ -31,5 +31,108 @@ def simple_call():
3131
)
3232

3333

34+
def simple_call_t2v():
35+
print("----sync call, please wait a moment----")
36+
rsp = VideoSynthesis.call(
37+
api_key=api_key,
38+
model="wan2.7-t2v",
39+
audio=True,
40+
watermark=True,
41+
prompt=prompt,
42+
)
43+
if rsp.status_code == HTTPStatus.OK:
44+
print("response: %s" % rsp)
45+
else:
46+
print(
47+
"sync_call Failed, status_code: %s, code: %s, message: %s"
48+
% (rsp.status_code, rsp.code, rsp.message),
49+
)
50+
51+
media_i2v = [
52+
{
53+
"type": "last_frame",
54+
"url": "https://wanx.alicdn.com/material/20250318/last_frame.png"
55+
},
56+
{
57+
"type": "first_frame",
58+
"url": "https://wanx.alicdn.com/material/20250318/first_frame.png"
59+
},
60+
{
61+
"url": "https://test-data-center.oss-accelerate.aliyuncs.com/wanx/audio/mp3_3s.mp3",
62+
"type": "driven_audio"
63+
}
64+
]
65+
66+
def simple_call_wan27_i2v():
67+
print("----sync call, please wait a moment----")
68+
rsp = VideoSynthesis.call(
69+
api_key=api_key,
70+
model="wan2.7-i2v",
71+
media=media_i2v,
72+
shot_type="multi",
73+
audio=True,
74+
watermark=True,
75+
prompt=prompt,
76+
)
77+
if rsp.status_code == HTTPStatus.OK:
78+
print("response: %s" % rsp)
79+
else:
80+
print(
81+
"sync_call Failed, status_code: %s, code: %s, message: %s"
82+
% (rsp.status_code, rsp.code, rsp.message),
83+
)
84+
85+
media_r2v = [
86+
{
87+
"type": "reference_image",
88+
"url": "https://test-data-center.oss-accelerate.aliyuncs.com/wanx/image/res240_269.jpg"
89+
},
90+
{
91+
"type": "reference_image",
92+
"url": "https://test-data-center.oss-accelerate.aliyuncs.com/wanx/image/man_5K_7_7K_18_4M.JPG",
93+
"reference_voice": "https://test-data-center.oss-accelerate.aliyuncs.com/wanx/audio/2s.wav"
94+
},
95+
{
96+
"type": "reference_video",
97+
"url": "https://test-data-center.oss-accelerate.aliyuncs.com/wanx/video/resources/cast/100M.mov",
98+
"reference_voice": "https://test-data-center.oss-accelerate.aliyuncs.com/wanx/audio/mp3_1s.mp3"
99+
},
100+
{
101+
"type": "reference_video",
102+
"url": "https://test-data-center.oss-accelerate.aliyuncs.com/wanx/video/resources/cast/29_99s.mp4",
103+
"reference_description": "这是一个身穿蓝衣的男子<cast>,他有着浓密的络腮胡"
104+
},
105+
{
106+
"type": "reference_video",
107+
"url": "https://test-data-center.oss-accelerate.aliyuncs.com/wanx/video/resources/cast/cat_127.mp4",
108+
"reference_voice": "https://test-data-center.oss-accelerate.aliyuncs.com/wanx/audio/wav_10s.wav",
109+
"reference_description": "这是一只毛绒小猫<cast>,它正在对着镜头微笑"
110+
}
111+
]
112+
113+
def simple_call_wan27_r2v():
114+
print("----sync call, please wait a moment----")
115+
rsp = VideoSynthesis.call(
116+
api_key=api_key,
117+
model="wan2.7-r2v",
118+
media=media_r2v,
119+
shot_type="multi",
120+
audio=True,
121+
watermark=True,
122+
prompt=prompt,
123+
)
124+
if rsp.status_code == HTTPStatus.OK:
125+
print("response: %s" % rsp)
126+
else:
127+
print(
128+
"sync_call Failed, status_code: %s, code: %s, message: %s"
129+
% (rsp.status_code, rsp.code, rsp.message),
130+
)
131+
132+
133+
34134
if __name__ == "__main__":
35135
simple_call()
136+
# simple_call_t2v()
137+
# simple_call_wan27_i2v()
138+
# simple_call_wan27_r2v()

0 commit comments

Comments
 (0)