关于 alibabacloud-avatar-video
这是面向创作者的 Alibaba Cloud 媒体生成技能,可用脚本生成语音、图像和视频。它涵盖数字人对口型、全身动作及模板播报等流程。
主要功能
- 01人像与音频生成口播视频
- 02全身人物动作迁移
- 03文本生成语音和图像
- 04图像生成视频及组合流程
- 05LingMou 模板数字人播报
适用场景
- 01为肖像照片配上合成语音
- 02将参考舞蹈动作迁移到全身人物
- 03从文本生成图像并制作视频
- 04制作模板化企业数字人播报
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ aliyun/ alibabacloud-aiops-skills --skill alibabacloud-avatar-video安装后在 Claude Code 中输入/alibabacloud-avatar-video确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
references/aa-api.mdemo-api.mdlingmou-api.mdoss-upload.mdram-policies.mdscripts/animate_anyone.pyavatar_video.pydemo_pipeline.pyimage_to_video.pyinput_validation.pylive_portrait.pyportrait_animate.pyqwen_tts.pytext_to_image.py详细介绍
Human Avatar — 阿里云 AI 视频与语音
功能概览
| 功能 | 脚本 | 模型 / API | 区域 | 摘要 |
|---|---|---|---|---|
| LivePortrait | live_portrait.py | liveportrait | cn-beijing | 人像 + 音频/视频 → 说话视频,分两步完成 |
| EMO | portrait_animate.py | emo-v1 | cn-beijing | 人像 + 音频 → 说话头像,检测 + 生成 |
| AA(AnimateAnyone) | animate_anyone.py | animate-anyone-gen2 | cn-beijing | 全身动画:检测 → 动作模板 → 视频 |
| T2I | text_to_image.py | wan2.x-t2i | 多区域 | 文本 → 图像,默认使用 wan2.2-t2i-flash |
| I2V | image_to_video.py | wan2.x-i2v | 多区域 | 图像 → 视频;支持 T2I→I2V 工作流;默认使用 wan2.7-i2v-flash |
| Qwen TTS | qwen_tts.py | qwen3-tts-* | cn-beijing / Singapore | 文本 → 语音;根据场景自动选择模型/语音 |
| LingMou | avatar_video.py | LingMou SDK | cn-beijing | 基于模板的数字人播报视频 |
快速选择指南
Talking head (have audio/video already) → LivePortrait
Talking head (no audio; synthesize first) → Qwen TTS → LivePortrait
Full-body dance / motion → AA (AnimateAnyone)
Text → image → T2I (text_to_image)
Image → video → I2V (image_to_video)
Text → video end-to-end → T2I → I2V (image_to_video --t2i-prompt)
Enterprise digital human / template news → LingMou (avatar_video)
环境设置
pip install requests==2.33.1 dashscope==1.25.15 oss2==2.19.1 numpy==1.26.4
# LingMou additionally:
pip install alibabacloud-lingmou20250527==1.7.0 alibabacloud-tea-openapi==0.4.4
export DASHSCOPE_API_KEY=sk-xxxx # Beijing-region API key
export ALIBABA_CLOUD_ACCESS_KEY_ID=xxx # OSS upload
export ALIBABA_CLOUD_ACCESS_KEY_SECRET=xxx
export OSS_BUCKET=your-bucket
export OSS_ENDPOINT=oss-cn-beijing.aliyuncs.com
⚠️
cn-beijing和 Singapore 的 API 密钥不可互换;请使用对应区域的密钥。
OSS_ENDPOINT可包含或省略https://前缀;脚本会自动规范化。
1. LivePortrait — 说话头像视频
适用场景:你有一张人像照片和语音,并希望快速生成说话头像视频。
流程:
Step 1: liveportrait-detect (sync) → pass=true
↓
Step 2: liveportrait (async) → video_url
图像:单人、正面人像、面部清晰、无遮挡
音频:wav/mp3,< 15MB,1 秒–3 分钟
视频输入:自动提取音频(ffmpeg)
# Image + audio file
python scripts/live_portrait.py \
--image ./portrait.jpg \
--audio ./speech.mp3 \
--template normal --download
# Image + video (extract audio)
python scripts/live_portrait.py \
--image ./portrait.jpg \
--video ./speech_video.mp4 \
--template active --download
# Public URLs
python scripts/live_portrait.py \
--image-url "https://..." \
--audio-url "https://..." \
--mouth-strength 1.2 --download
动作模板:
normal(默认,动作适中)calm(平静;新闻 / 讲故事)active(活泼;唱歌 / 主持)
2. Qwen TTS — 文本转语音
适用场景:根据文本生成语音文件(用于 LivePortrait、EMO 等)。
默认模型:qwen3-tts-vd-realtime-2026-01-15
根据场景自动选择模型
场景 --scene | 推荐模型 | 推荐语音 |
|---|---|---|
default / brand | qwen3-tts-vd-realtime-2026-01-15 | Cherry |
news / documentary / advertising | qwen3-tts-instruct-flash-realtime | Serena / Ethan |
audiobook / drama | qwen3-tts-instruct-flash-realtime | Cherry / Dylan |
customer_service / chatbot / education | qwen3-tts-flash-realtime | Anna / Ethan |
ecommerce / short_video | qwen3-tts-flash-realtime | Cherry / Chelsie |
可用语音
| 语音 | 特点 |
|---|---|
Cherry | 明亮甜美的女声;广告 / 有声书 / 配音 |
Serena | 成熟知性的女声;新闻 / 解说 / 企业宣传 |
Ethan | 沉稳温暖的男声;教育 / 纪录片 / 培训 |
Dylan | 富有表现力的男声;广播剧 / 游戏配音 |
Anna | 温柔友善的女声;客服 / 助手 / 日常场景 |
Chelsie | 年轻清新的女声;短视频 / 电商 |
Thomas | 深沉迷人的男声;品牌宣传 / 广告 |
Luna | 温暖柔和的女声;冥想 / 讲故事 |
# Default (qwen3-tts-vd-realtime + Cherry)
python scripts/qwen_tts.py --text "Hello, welcome to Qwen TTS." --download
# Match by scene
python scripts/qwen_tts.py --text "Today's market..." --scene news --download
python scripts/qwen_tts.py --text "Once upon a time..." --scene audiobook --download
# Style via instructions
python scripts/qwen_tts.py \
--text "Dear students..." \
--model qwen3-tts-instruct-flash-realtime \
--instructions "Warm tone, steady pace, suitable for teaching" \
--download
# List options
python scripts/qwen_tts.py --list-voices
python scripts/qwen_tts.py --list-models
3. T2I — Wan 2.x 文本转图像
适用场景:根据文本生成图像(可选后续输入 I2V)。
# Default model (wan2.2-t2i-flash, fast)
python scripts/text_to_image.py \
--prompt "A woman in Hanfu in a peach blossom forest, cinematic, 4K, soft light" \
--size 960*1696 --download
# Higher quality
python scripts/text_to_image.py \
--prompt "..." --model wan2.2-t2i-plus --size 1280*1280 --download
# Latest (Wan 2.6)
python scripts/text_to_image.py \
--prompt "..." --model wan2.6-t2i --size 1280*1280 --n 1 --download
模型:
wan2.2-t2i-flash(默认,速度快,适合测试)wan2.2-t2i-plus(质量更高)wan2.6-t2i(最新;支持更多宽高比;同步调用)
常用尺寸:1280*1280(1:1)/ 960*1696(9:16)/ 1696*960(16:9)
4. I2V — Wan 2.x 图像转视频
适用场景:将图像转换为动态视频;支持先通过 T2I 实现文本转视频。
# Local image → video
python scripts/image_to_video.py \
--image ./portrait.jpg \
--prompt "She turns slowly and smiles; dress and petals drift gently" \
--model wan2.7-i2v \
--resolution 720P --duration 5 --download
# Pipeline: text → image → video
python scripts/image_to_video.py \
--t2i-prompt "A woman in Hanfu in a peach blossom forest" \
--prompt "She turns slowly; petals fall; poetic mood" \
--download --output result.mp4
# With background music
python scripts/image_to_video.py \
--image ./portrait.jpg \
--audio-url "https://..." \
--prompt "..." --download
模型:
wan2.7-i2v(默认;包含声音;5 秒/10 秒)wan2.5-i2v-preview(高质量预览)wan2.2-i2v-plus(不含内置音频;速度更快)
5. AA AnimateAnyone — 全身动画
使用场景:全身照片 + 参考动作视频 → 舞蹈 / 动作视频。
要求:
- 图像:单人全身正面照,头部到脚部完整入镜,宽高比为 0.5–2.0
- 视频:从第一帧起全身完整入镜;mp4/avi/mov;fps ≥ 24;2–60s
三个步骤:
Step 1: animate-anyone-detect-gen2 (sync) → check_pass=true
↓
Step 2: animate-anyone-template-gen2 (async) → template_id (~3–5 min)
↓
Step 3: animate-anyone-gen2 (async) → video_url (~3–5 min)
# Local files (auto convert + OSS upload)
python scripts/animate_anyone.py \
--image ./portrait_fullbody.jpg \
--video ./dance.mp4 \
--download --output result.mp4
# Use image as background
python scripts/animate_anyone.py \
--image ./portrait.jpg --video ./dance.mp4 \
--use-ref-img-bg --video-ratio 9:16 --download
# Skip Step 2 (existing template_id)
python scripts/animate_anyone.py \
--image ./portrait.jpg \
--template-id "AACT.xxx.xxx" --download
自动转换:将视频 webm/mkv/flv 转为 mp4;将图像 webp/heic 转为 jpg;如果 fps 低于 24,则标准化为 24 fps
6. EMO — 对口型视频(旧版)
注意:优先使用 LivePortrait;适用于需要更严格口型同步的情况。
python scripts/portrait_animate.py \
--image ./portrait.jpg \
--audio ./speech.mp3 \
--download
7. LingMou — 企业模板视频
使用场景:企业数字人新闻播报、基于模板的广播,以及可选用人物图像的脚本朗读。
新工作流(优先不使用 template_id)
- 如果用户提供了
template_id:使用该模板生成。 - 如果没有
template_id:- 列出该账号现有的播报模板。
- 如果有模板,随机选择一个用于生成。
- 如果没有模板,获取公开模板,并复制最多 3 个到该账号。
- 从复制结果中随机选择一个并继续。
- 注意事项:复制公开模板后,该副本可能尚未完全“可供渲染”;有些副本仍是草稿,可能缺少片段、素材或变量绑定——请在 LingMou 中完成设置。
- 如果用户只提供图像并要求“制作对口型视频”,但没有提供脚本:生成前先确认朗读文案。
scripts/avatar_video.py 支持的功能
--list-templates:列出账号模板--list-public-templates:列出公开模板(SDK 1.7.0+)--copy-public-templates:复制最多 3 个公开模板(SDK 1.7.0+)- 省略
--template-id:随机选择现有模板 - 本地模板为空时:自动尝试复制公开模板作为备用方案
--show-template-detail:显示模板详情和可替换变量- 将输入文本填入模板文本变量(优先使用
text_content/test_text) - 如果复制公开模板后立即生成失败,会明确提示模板可能仍需完善(不会静默失败)
# List templates
python scripts/avatar_video.py --list-templates
# Public templates (SDK 1.7.0+)
python scripts/avatar_video.py --list-public-templates
# Copy up to 3 public templates (SDK 1.7.0+)
python scripts/avatar_video.py --copy-public-templates
# No template_id — random existing template
python scripts/avatar_video.py \
--text "Hello, welcome to today's tech news." \
--download
# Specific template_id
python scripts/avatar_video.py \
--template-id "BS1b2WNnRMu4ouRzT4clY9Jhg" \
--text "Hello, welcome to today's tech news." \
--download
# Detail for randomly chosen template
python scripts/avatar_video.py \
--show-template-detail \
--text "This is a test script for broadcast."
对话式使用
用户提出以下类似请求时:
- “用这张图制作对口型视频”
- “帮我制作数字人播报”
- “上传图片并制作新闻播报”
请按以下步骤操作:
- 检查用户是否已提供可直接朗读的文案 / 脚本。
- 如果没有,询问:“要朗读的确切脚本是什么?你可以提供要点,我可以将其整理成适合播报的文案。”
- 有脚本后,运行 LingMou:优先随机选择现有模板;如果本地没有模板,则尝试复制公开模板。
- 如果用户上传了肖像,但模板 API 不使用该肖像,请说明:此流程由模板驱动;如需图像驱动的对口型视频,请使用 LivePortrait 或 EMO。
API 参考链接
- LivePortrait:https://help.aliyun.com/zh/model-studio/liveportrait-api
- EMO(emo-detect + emo-v1):references/emo-api.md
- AA(Animate Anyone):references/aa-api.md
- T2I(文生图 v2):https://help.aliyun.com/zh/model-studio/text-to-image-v2-api-reference
- I2V(图生视频):https://help.aliyun.com/zh/model-studio/image-to-video-api-reference/
- Qwen TTS:https://help.aliyun.com/zh/model-studio/qwen-tts-realtime
- LingMou:references/lingmou-api.md
- OSS 上传:references/oss-upload.md