介绍
# ElevenLabs Music Generation
通过文本提示词生成完整的歌曲,包含 AI 生成的歌词和人声。
## 快速开始
```bash # Basic generation (30 seconds) uv run {baseDir}/scripts/generate_music.py "upbeat jazz piano"
# Longer track (3 minutes) uv run {baseDir}/scripts/generate_music.py "epic orchestral battle music" --length 180
# Instrumental only (no vocals) uv run {baseDir}/scripts/generate_music.py "lo-fi hip hop beats" --length 120 --instrumental
# Custom output path uv run {baseDir}/scripts/generate_music.py "romantic bossa nova" -o /tmp/bossa.mp3 ```
## 选项
| 标志 | 描述 | |------|-------------| | `-l, --length` | 时长,以秒为单位 (3-600,默认: 30) | | `-o, --output` | 输出文件路径 (默认: /tmp/music.mp3) | | `-i, --instrumental` | 强制使用纯音乐,无人声 |
## 提示词工程技巧
### 明确风格 - 包含流派、情绪、速度和乐器 - 参考年代或时期:"90年代巴西浪漫帕戈德 (pagode)"、"1960年代科幻电视主题曲" - 描述能量:"从柔和逐渐推向爆发"、"轻松且亲密"
### 针对人声 - 指定语言:"葡萄牙语人声"、"日语演唱" - 描述人声风格:"深情的男声"、"空灵的女声合唱" - 包含歌词主题:"关于爱与思念 (saudade)"、"颂扬友谊"
### 避免版权问题 - 不要直接提及艺人/乐队名称 - 描述风格而非进行比较:"经典的90年代浪漫桑巴风格",而不要说"像 Raça Negra" - 如果被拒绝,API 会返回建议的替代提示词
### 示例提示词
**MPB(巴西流行音乐)** ``` A soulful MPB track featuring gentle acoustic guitar, warm nylon strings, and dreamy Rhodes piano. Bossa nova-influenced rhythm with soft brushed drums. Vocals in Portuguese express themes of saudade and the beauty of life. ```
**史诗管弦乐** ``` Epic military march with powerful brass fanfares, thundering timpani drums, and a soaring choir. Triumphant and heroic, with deep bass tubas, bold trumpets, snare rolls, and an anthemic melody building to a glorious crescendo. ```
**摇篮曲** ``` Gentle orchestral lullaby with sweeping strings, soft brass, and ethereal wordless soprano vocals. Peaceful yet majestic, evoking wonder and hope. Perfect for falling asleep while dreaming of adventures. ```
**喜剧摇滚** ``` Brazilian comedy rock with absurd, hilarious Portuguese lyrics full of wordplay. Mix energetic rock guitars with unexpected rhythms - forró breakdowns, pagode moments. Theatrical, exaggerated vocals singing about ridiculous situations. ```
## 要求
- **ElevenLabs API Key**:设置 `ELEVENLABS_API_KEY` 环境变量 - **付费计划**:音乐 API 需要 Creator 计划或更高级别 - **uv**:用于运行带有依赖项的 Python 脚本
## 支持的功能
- 长达 10 分钟的文本生成音乐 - 多种语言的 AI 生成歌词和人声(英语、西班牙语、葡萄牙语、德语、日语等) - 纯音乐模式 - 支持大多数音乐风格和流派