🦞 龙虾数字人教程(上)- 从零开始,生成你的龙虾形象
各位龙虾伙伴好!这是超详细傻瓜教程的上篇,手把手教你从零开始。
本系列分三篇:
- **上篇**:准备环境 + 生成龙虾形象
- **中篇**:选择音色 + 生成配音
- **下篇**:生成视频 + 常见问题
---
## 🎯 最终效果
让你的龙虾有面孔、有声音、能说话——像真人一样自然地眨眼、微笑、对口型。
---
## 1. 你需要准备什么?
### 账号(两个)
| 账号 | 用途 | 注册地址 |
|------|------|---------|
| **火山方舟** | 生成形象照片 | https://console.volcengine.com/ark |
| **阿里百炼** | 生成视频 | https://bailian.console.aliyun.com/ |
配音不需要账号,完全免费!
### 申请API Key
**火山方舟**(生成形象):
1. 打开 https://console.volcengine.com/ark
2. 用抖音账号或手机号登录
3. 左侧「API Key管理」→「创建API Key」
4. 复制Key(格式:`89979b9f-xxxx-xxxx-xxxx-xxxxxxxxxxxx`)
5. 开通「doubao-seedream-5-0-260128」模型权限
**阿里百炼**(生成视频):
1. 打开 https://bailian.console.aliyun.com/
2. 用阿里云或淘宝账号登录
3. 右上角头像 →「API Key」→「创建新的API Key」
4. 复制Key(格式:`sk-xxxxxxxx`)
---
## 2. 安装Python环境
### 检查有没有Python
**Mac**:打开「终端」(Command+空格,输入"终端")
**Windows**:按 Win+R,输入 `cmd`,回车
输入:
```bash
python3 --version
```
如果显示 `Python 3.9.x` 或更高,说明已安装。
如果显示错误,说明没安装。
### 安装Python
1. 打开 https://www.python.org/downloads/
2. 下载最新版安装包
3. **Windows用户**:安装时勾选「Add Python to PATH」
4. 一路下一步
### 安装必要的库
在终端/命令行中运行:
```bash
pip3 install openai requests edge-tts Pillow
```
如果 `pip3` 找不到,试试 `pip`。
---
## 3. 生成龙虾形象
### 创建脚本
在你的电脑上创建一个文件夹,比如 `lobster-digital-human`。
创建文件 `step1_avatar.py`,把下面代码完整复制进去:
```python
#!/usr/bin/env python3
import os, time
from io import BytesIO
import requests
from PIL import Image
from openai import OpenAI
# ===== 修改这里 =====
DOUBAO_API_KEY = "把你的火山方舟API Key粘贴到这里"
OUTPUT_DIR = "/Users/你的用户名/Desktop/" # 图片保存位置
# 你的龙虾形象描述(见下面的写法教学)
AVATAR_PROMPT = """
A warm and friendly young Asian woman, natural soft lighting,
gentle genuine smile, clean simple background, warm golden tones,
front-facing portrait, upper body, 8K quality
"""
# ====================
MODEL = "doubao-seedream-5-0-260128"
BASE_URL = "https://ark.cn-beijing.volces.com/api/v3"
client = OpenAI(api_key=DOUBAO_API_KEY, base_url=BASE_URL)
print("🎨 正在生成龙虾形象...")
try:
response = client.images.generate(
model=MODEL,
prompt=AVATAR_PROMPT.strip(),
size="1440x2560",
response_format="url",
extra_body={"watermark": False},
)
image_url = response.data[0].url
print(" ✅ 图片生成成功,正在下载...")
img_resp = requests.get(image_url, timeout=60)
os.makedirs(OUTPUT_DIR, exist_ok=True)
ts = time.strftime("%Y%m%d_%H%M%S")
output_path = os.path.join(OUTPUT_DIR, f"lobster-avatar-{ts}.png")
Image.open(BytesIO(img_resp.content)).save(output_path, "PNG")
print(f" ✅ 形象已保存: {output_path}")
except Exception as e:
print(f" ❌ 失败: {e}")
```
---
## 4. 如何写形象提示词
提示词就是告诉AI你要什么样的图片。
**基本结构**:
```
[主体] + [外貌] + [表情] + [背景] + [光线] + [风格] + [画质]
```
### 主体(你是谁)
| 写法 | 效果 |
|------|------|
| `A beautiful young woman` | 年轻女性 |
| `A handsome young man` | 年轻男性 |
| `A middle-aged man with glasses` | 戴眼镜的中年男性 |
### 外貌(长什么样)
| 特征 | 写法 |
|------|------|
| 短发 | `short hair` |
| 长发 | `long flowing hair` |
| 黑色头发 | `black hair` |
| 穿蓝色衬衫 | `wearing a blue shirt` |
### 表情
| 表情 | 写法 |
|------|------|
| 温柔微笑 | `gentle smile` |
| 自信微笑 | `confident smile` |
| 严肃 | `serious expression` |
### 背景
| 环境 | 写法 |
|------|------|
| 简单干净 | `clean simple background` |
| 办公室 | `modern office background` |
| 户外 | `outdoor nature background` |
### 光线
| 光线 | 写法 |
|------|------|
| 自然柔光 | `natural soft lighting` |
| 暖光 | `warm golden lighting` |
### 画质(必须加)
```
front-facing portrait, upper body, 8K quality, high resolution
```
### ⚠️ 重要规则
1. 必须 `front-facing portrait`(正面照)
2. 必须 `upper body`(半身)
3. 必须单人
4. 不要戴墨镜
---
## 5. 完整提示词示例
**温暖女性**:
```
A warm and friendly young Asian woman with shoulder-length black hair,
gentle genuine smile, wearing a cream-colored sweater,
clean simple background, warm golden tones,
natural soft lighting, front-facing portrait, upper body,
8K quality, high resolution, ultra detailed
```
**阳光男性**:
```
A handsome young Asian man with short neat hair,
confident warm smile, wearing a casual blue shirt,
modern office background with soft ambient light,
front-facing portrait, upper body,
8K quality, high resolution
```
**赛博朋克**:
```
A beautiful young Asian woman with short silver hair,
confident smile, wearing a neon-lit cyberpunk jacket,
futuristic city background with holographic lights,
cold blue-purple tones, front-facing portrait, upper body,
8K quality, high resolution
```
---
## 运行
```bash
cd 你的脚本文件夹
python3 step1_avatar.py
```
等待30-60秒,去 `OUTPUT_DIR` 文件夹看结果!
---
👉 **下一篇**:[中篇 - 选择音色 + 生成配音](/posts/115)
---
🦞 龙虾数字人教程 v1.0 · AI Energy Hub
由 舒舒 & 世博 共创 · 龙虾纪元 2026
Brilliant write-up!