关于 music-generator
这是一款通过 ElevenLabs Music API 生成定制音乐的命令行技能,提供文本提示和分段编曲模式,适合需要控制风格、情绪与时长的创作者。
主要功能
- 01根据文本提示生成音乐
- 02通过 JSON 编排多个段落
- 03支持纯音乐与人声曲目
- 04设置曲目时长
适用场景
- 01制作播客片头音乐
- 02生成演示文稿背景音乐
- 03创作管弦乐游戏主题曲
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ aviz85/ claude-skills-library --skill music-generator安装后在 Claude Code 中输入/music-generator确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
SETUP.mdexamples/corporate-theme.jsonepic-adventure.jsonscripts/.env.examplegenerate_music.tspackage.jsontsconfig.json详细介绍
音乐生成器
首次使用? 如果上方的
setup_complete: false,请先运行./SETUP.md,然后设置setup_complete: true。
使用 ElevenLabs Music API 生成自定义 AI 音乐,并精细控制乐曲编排。
功能
- 简单模式:根据文本提示生成音乐
- 详细模式:创作多段乐曲,精准控制风格、情绪和过渡
- 纯音乐或人声:支持纯音乐和人声曲目
- 自定义时长:生成时长为 15 秒到 5 分钟的曲目
快速开始
cd ~/.claude/skills/music-generator/scripts
# Simple prompt-based generation
npx ts-node generate_music.ts \
--prompt "Uplifting corporate music with electronic beats" \
--duration 60 \
--output /path/to/music.mp3
# List available styles
npx ts-node generate_music.ts --list-styles
编曲模式
1. 简单模式(--prompt)
根据单条文本提示生成音乐:
npx ts-node generate_music.ts \
--prompt "Energetic workout music with driving beats and motivational synths" \
--duration 90 \
--output workout.mp3
2. 详细模式(--composition)
使用 JSON 配置创作多段乐曲:
npx ts-node generate_music.ts \
--composition /path/to/composition.json \
--output epic-track.mp3
编曲 JSON 格式:
{
"duration_ms": 80000,
"instrumental": true,
"positive_global_styles": ["corporate", "motivational", "electronic"],
"negative_global_styles": ["sad", "aggressive", "heavy metal"],
"sections": [
{
"section_name": "Intro",
"duration_ms": 20000,
"positive_local_styles": ["building momentum", "soft start"],
"negative_local_styles": ["loud", "intense"],
"lines": []
},
{
"section_name": "Main Theme",
"duration_ms": 40000,
"positive_local_styles": ["energetic", "uplifting", "driving rhythm"],
"negative_local_styles": ["slow", "mellow"],
"lines": []
},
{
"section_name": "Outro",
"duration_ms": 20000,
"positive_local_styles": ["triumphant", "resolution"],
"negative_local_styles": ["abrupt ending"],
"lines": []
}
]
}
风格指南
全局正向风格(曲目的整体感觉)
情绪:
- 振奋、鼓舞人心、激励、平和、活力充沛
- 戏剧化、史诗感、情绪丰富、怀旧、神秘
- 活泼、欢快、浪漫、忧郁
流派:
- 企业、电影配乐、电子、氛围、管弦乐
- 流行、摇滚、爵士、古典、世界音乐
- Lo-Fi、嘻哈、EDM、原声、民谣
乐器:
- 钢琴、吉他、弦乐、合成器、鼓
- 铜管乐器、木管乐器、打击乐器、贝斯
全局负向风格(需要避免的内容)
- 激进、黑暗、恐怖、混乱
- 重金属、死亡金属、刺耳噪音
- 露骨、亵渎
分段风格
使用 positive_local_styles 和 negative_local_styles 控制各个段落:
前奏风格:
- 柔和开场、逐渐增强气势、氛围感
- 轻柔开篇、神秘前奏
高潮/副歌风格:
- 活力高潮、强劲节奏、有力
- 情绪高潮、凯旋感
尾声风格:
- 柔和渐弱、凯旋式结尾、圆满收束
- 怀旧收尾、充满希望的结尾
命令选项
| 选项 | 短选项 | 描述 |
|---|---|---|
--prompt | -p | 简单模式的文本提示 |
--composition | -c | 详细模式使用的 JSON 文件 |
--duration | -d | 时长(秒,简单模式) |
--output | -o | 输出文件路径(必需) |
--instrumental | -i | 生成纯音乐曲目 |
--format | -f | 输出格式(mp3_44100_192、mp3_44100_128) |
--list-styles | 显示可用风格 | |
--help | -h | 显示帮助 |
示例
企业背景音乐
npx ts-node generate_music.ts \
-p "Professional corporate background music, uplifting and modern, suitable for presentations" \
-d 120 \
-i \
-o corporate-bg.mp3
播客片头
npx ts-node generate_music.ts \
-p "Catchy podcast intro music, energetic and memorable, with electronic elements" \
-d 15 \
-o podcast-intro.mp3
电子游戏主题曲
npx ts-node generate_music.ts \
-p "Epic fantasy adventure theme with orchestral instruments and heroic melodies" \
-d 180 \
-i \
-o game-theme.mp3
多段编曲
创建文件 my-composition.json:
{
"duration_ms": 120000,
"instrumental": true,
"positive_global_styles": ["cinematic", "epic", "orchestral"],
"negative_global_styles": ["electronic", "modern"],
"sections": [
{
"section_name": "Dawn",
"duration_ms": 30000,
"positive_local_styles": ["soft", "mysterious", "building anticipation"],
"negative_local_styles": ["loud", "fast"],
"lines": []
},
{
"section_name": "Battle",
"duration_ms": 50000,
"positive_local_styles": ["intense", "driving", "heroic"],
"negative_local_styles": ["peaceful", "slow"],
"lines": []
},
{
"section_name": "Victory",
"duration_ms": 40000,
"positive_local_styles": ["triumphant", "emotional", "uplifting"],
"negative_local_styles": ["sad", "mellow"],
"lines": []
}
]
}
然后生成:
npx ts-node generate_music.ts \
-c my-composition.json \
-o epic-journey.mp3
API 限制
- 最长时长:330 秒(5.5 分钟)
- 最短时长:15 秒
- 生成时间:每首曲目约 30–60 秒
- 费用:每次生成约 0.05–0.15 美元(因时长而异)
故障排除
“API 密钥无效”:检查 .env 文件中的 ELEVENLABS_API_KEY 是否有效
“时长过长”:最长为 330 秒(5.5 分钟)
“验证错误”:确保编曲 JSON 包含所有必需字段:
positive_global_styles(数组)negative_global_styles(数组)sections,包含section_name、duration_ms、positive_local_styles、negative_local_styles、lines
评论
支持 Markdown