名称: elevenlabs-voices
版本: 2.1.5
描述: 使用 ElevenLabs API 实现高质量的语音合成,包含 18 种人物音色、32 种语言支持、音效生成、批量处理及语音设计功能。
标签: [tts, voice, speech, elevenlabs, audio, sound-effects, voice-design, multilingual]
元数据: {"openclaw":{"requires":{"bins":["python3"],"env":{"ELEVEN_API_KEY":"必填","ELEVENLABS_API_KEY":"可选"},"note":"请设置 ELEVEN_API_KEY。ELEVENLABS_API_KEY 是其可接受的别名。"}}}
基于 ElevenLabs API 的综合性语音合成工具包。
首次使用此技能(不存在 config.json 文件时),请运行交互式设置向导:
python3 scripts/setup.py
向导将引导您完成:
1. API 密钥 - 输入您的 ElevenLabs API 密钥(必需)
2. 默认语音 - 从热门音色中选择(Rachel、Adam、Bella 等)
3. 语言 - 设置首选语言(支持 32 种)
4. 音频质量 - 标准或高质量输出
5. 成本追踪 - 启用用量与成本监控
6. 预算限制 - 可选的月度支出上限
🔒 隐私说明: 您的 API 密钥仅本地存储在 config.json 中,不会离开您的设备,并已通过 .gitignore 自动排除在 git 版本控制之外。
如需随时重新配置,只需再次运行设置向导。
| 音色 | 口音 | 性别 | 人物设定 | 最佳用途 |
|---|---|---|---|---|
| rachel | 🇺🇸 美式 | 女声 | 温暖 | 对话、教程 |
| adam | 🇺🇸 美式 | 男声 | 旁白 | 纪录片、有声书 |
| bella | 🇺🇸 美式 | 女声 | 专业 | 商务、演示 |
| brian | 🇺🇸 美式 | 男声 | 安抚 | 冥想、舒缓内容 |
| george | 🇬🇧 英式 | 男声 | 讲故事者 | 有声书、故事讲述 |
| alice | 🇬🇧 英式 | 女声 | 教育者 | 教程、讲解 |
| callum | 🇺🇸 美式 | 男声 | 顽皮 | 游戏、趣味内容 |
| charlie | 🇦🇺 澳式 | 男声 | 充满活力 | 体育、激励 |
| jessica | 🇺🇸 美式 | 女声 | 活泼 | 社交媒体、休闲 |
| lily | 🇬🇧 英式 | 女声 | 演员 | 戏剧、优雅内容 |
| matilda | 🇺🇸 美式 | 女声 | 专业 | 企业、新闻 |
| river | 🇺🇸 美式 | 中性 | 中性 | 包容性、信息性 |
| roger | 🇺🇸 美式 | 男声 | 随意 | 播客、轻松 |
| daniel | 🇬🇧 英式 | 男声 | 播音员 | 新闻、公告 |
| eric | 🇺🇸 美式 | 男声 | 可信赖 | 商务、企业 |
| chris | 🇺🇸 美式 | 男声 | 友好 | 教程、平易近人 |
| will | 🇺🇸 美式 | 男声 | 乐观 | 激励、鼓舞人心 |
| liam | 🇺🇸 美式 | 男声 | 社交 | YouTube、社交媒体 |
default → rachel (温暖、友好)narrator → adam (纪录片)professional → matilda (企业)storyteller → george (有声书)educator → alice (教程)calm → brian (冥想)energetic → liam (社交媒体)trustworthy → eric (商务)neutral → river (包容性)british → georgeaustralian → charliebroadcaster → daniel (新闻)多语言 v2 模型支持以下语言:
| 代码 | 语言 | 代码 | 语言 |
|---|---|---|---|
| en | 英语 | pl | 波兰语 |
| de | 德语 | nl | 荷兰语 |
| es | 西班牙语 | sv | 瑞典语 |
| fr | 法语 | da | 丹麦语 |
| it | 意大利语 | fi | 芬兰语 |
| pt | 葡萄牙语 | no | 挪威语 |
| ru | 俄语 | tr | 土耳其语 |
| uk | 乌克兰语 | cs | 捷克语 |
| ja | 日语 | sk | 斯洛伐克语 |
| ko | 韩语 | hu | 匈牙利语 |
| zh | 中文 | ro | 罗马尼亚语 |
| ar | 阿拉伯语 | bg | 保加利亚语 |
| hi | 印地语 | hr | 克罗地亚语 |
| ta | 泰米尔语 | el | 希腊语 |
| id | 印尼语 | ms | 马来语 |
| vi | 越南语 | th | 泰语 |
# 用德语合成
python3 tts.py --text "Guten Tag!" --voice rachel --lang de
# 用法语合成
python3 tts.py --text "Bonjour le monde!" --voice adam --lang fr
# 列出所有语言
python3 tts.py --languages
# 列出所有音色
python3 scripts/tts.py --list
# 生成语音
python3 scripts/tts.py --text "Hello world" --voice rachel --output hello.mp3
# 使用预设
python3 scripts/tts.py --text "Breaking news..." --voice broadcaster --output news.mp3
# 多语言
python3 scripts/tts.py --text "Bonjour!" --voice rachel --lang fr --output french.mp3
实时流式生成音频(适用于长文本):
# 生成时流式输出音频
python3 scripts/tts.py --text "This is a long story..." --voice adam --stream
# 流式输出并自定义输出文件
python3 scripts/tts.py --text "Chapter one..." --voice george --stream --output chapter1.mp3
从文件处理多个文本:
# 从换行分隔的文本文件
python3 scripts/tts.py --batch texts.txt --voice rachel --output-dir ./audio
# 从 JSON 文件
python3 scripts/tts.py --batch batch.json --output-dir ./output
JSON 批量格式:
[
{"text": "First line", "voice": "rachel", "output": "line1.mp3"},
{"text": "Second line", "voice": "adam", "output": "line2.mp3"},
{"text": "Third line"}
]
简单文本格式(每行一个):
Hello, this is the first sentence.
This is the second sentence.
And this is the third.
# 显示用量统计和成本估算
python3 scripts/tts.py --stats
# 重置统计
python3 scripts/tts.py --reset-stats
根据文本描述生成 AI 驱动的音效:
# 生成音效
python3 scripts/sfx.py --prompt "Thunder rumbling in the distance"
# 指定时长 (0.5-22 秒)
python3 scripts/sfx.py --prompt "Cat meowing" --duration 3 --output cat.mp3
# 调整提示词影响力 (0.0-1.0)
python3 scripts/sfx.py --prompt "Footsteps on gravel" --influence 0.5
# 批量生成音效
python3 scripts/sfx.py --batch sounds.json --output-dir ./sfx
# 显示提示词示例
python3 scripts/sfx.py --examples
提示词示例:
- "远处雷声隆隆"
- "猫满足地呼噜"
- "机械键盘打字声"
- "宇宙飞船引擎嗡鸣"
- "咖啡馆背景闲聊声"
根据文本描述创建自定义音色:
# 基础语音设计
python3 scripts/voice-design.py --gender female --age middle_aged --accent american \
--description "温暖、慈母般的声音"
# 使用自定义预览文本
python3 scripts/voice-design.py --gender male --age young --accent british \
--text "Welcome to the adventure!" --output preview.mp3
# 保存到您的 ElevenLabs 库
python3 scripts/voice-design.py --gender female --age young --accent american \
--description "充满活力的播客主持人" --save "MyHost"
# 列出所有设计选项
python3 scripts/voice-design.py --options
语音设计选项:
| 选项 | 可选值 |
|---|---|
| 性别 | male, female, neutral |
| 年龄 | young, middle_aged, old |
| 口音 | american, british, african, australian, indian, latin, middle_eastern, scandinavian, eastern_european |
| 口音强度 | 0.3-2.0 (轻微到强烈) |
自定义单词发音方式:
编辑 pronunciations.json:
{
"rules": [
{
"word": "OpenClaw",
"replacement": "Open Claw",
"comment": "按两个单词发音"
},
{
"word": "API",
"replacement": "A P I",
"comment": "拼读缩写"
}
]
}
使用:
# 发音规则会自动应用
python3 scripts/tts.py --text "The OpenClaw API is great" --voice rachel
# 禁用发音规则
python3 scripts/tts.py --text "The API is great" --voice rachel --no-pronunciations
本技能追踪您的字符用量并估算成本:
python3 scripts/tts.py --stats
输出示例:
📊 ElevenLabs 用量统计
总字符数: 15,230
总请求数: 42
统计起始: 2024-01-15
💰 预估成本:
Starter $4.57 ($0.30/千字符)
Creator $3.66 ($0.24/千字符)
Pro $2.74 ($0.18/千字符)
Scale $1.68 ($0.11/千字符)
OpenClaw 内置的 TTS 支持可使用 ElevenLabs。在 ~/.openclaw/openclaw.json 中配置:
{
"tts": {
"enabled": true,
"provider": "elevenlabs",
"elevenlabs": {
"apiKey": "your-api-key-here",
"voice": "rachel",
"model": "eleven_multilingual_v2"
}
}
}
在 OpenClaw 对话中:
- 使用 /tts on 启用自动 TTS
- 直接使用 tts 工具进行一次性语音合成
- 请求 "朗读这个" 或 "说出这个"
# OpenClaw 可以直接运行这些脚本
exec python3 /path/to/skills/elevenlabs-voices/scripts/tts.py --text "Hello" --voice rachel
脚本按以下顺序查找 API 密钥:
ELEVEN_API_KEY 或 ELEVENLABS_API_KEY 环境变量~/.openclaw/openclaw.json → tts.elevenlabs.apiKey).env 文件创建 .env 文件:
echo 'ELEVEN_API_KEY=your-key-here' > .env
每个音色都经过调优以获得最佳输出:
| 设置项 | 范围 | 描述 |
|---|---|---|
| stability | 0.0-1.0 | 值越高越稳定,越低越富有表现力 |
| similarity_boost | 0.0-1.0 | 与原音色的匹配程度 |
| style | 0.0-1.0 | 说话风格的夸张程度 |
elevenlabs-voices/
├── SKILL.md # 本文档
├── README.md # 快速入门指南
├── config.json # 本地配置(由 setup 创建,在 .gitignore 中)
├── voices.json # 音色定义与设置
├── pronunciations.json # 自定义发音规则
├── examples.md # 详细使用示例
├── scripts/
│ ├── setup.py # 交互式设置向导
│ ├── tts.py # 主 TTS 脚本
│ ├── sfx.py # 音效生成器
│ └── voice-design.py # 语音设计工具
└── references/
└── voice-guide.md # 音色选择指南
scripts/setup.py)config.json 中(已添加到 .gitignore)--lang 参数--stream 标志sfx.py)--batch 标志--stats 标志voice-design.py)