mcpField
M
music

music

github.com/calesthio创意与媒体73.0k1.1k 次安装1 天前更新
代码仓库

关于 music

music 是通过 ElevenLabs API 根据文本提示词或结构化作曲方案生成音乐的技能,支持器乐曲和带歌词的歌曲。它提供作曲、方案规划以及返回音频和元数据的方法。

主要功能

  1. 01根据文本提示词生成音乐
  2. 02创建和编辑作曲方案
  3. 03生成音频及详细元数据
  4. 04为支持的修补工作流上传音频

适用场景

  1. 01根据描述制作器乐曲
  2. 02规划并调整较长的管弦乐作品

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/calesthio/openmontage --skill music

安装后在 Claude Code 中输入/music确认已加载。

附带文件references/api_reference.mdreferences/installation.md

详细介绍

ElevenLabs 音乐生成

通过文本提示词生成音乐——支持纯音乐曲目、带歌词的歌曲,以及通过编曲计划进行精细控制。

设置: 请参阅安装指南。对于 JavaScript,请仅使用 @elevenlabs/* 软件包。

快速开始

Python
from elevenlabs import ElevenLabs

client = ElevenLabs()

audio = client.music.compose(
    prompt="A chill lo-fi hip hop beat with jazzy piano chords",
    music_length_ms=30000
)

with open("output.mp3", "wb") as f:
    for chunk in audio:
        f.write(chunk)
JavaScript
import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js";
import { createWriteStream } from "fs";

const client = new ElevenLabsClient();
const audio = await client.music.compose({
  prompt: "A chill lo-fi hip hop beat with jazzy piano chords",
  musicLengthMs: 30000,
});
audio.pipe(createWriteStream("output.mp3"));
cURL
curl -X POST "https://api.elevenlabs.io/v1/music" \
  -H "xi-api-key: $ELEVENLABS_API_KEY" -H "Content-Type: application/json" \
  -d '{"prompt": "A chill lo-fi beat", "music_length_ms": 30000}' --output output.mp3

方法

方法描述
music.compose根据提示词或编曲计划生成音频
music.composition_plan.create生成结构化计划,以便进行精细控制
music.compose_detailed生成音频、编曲计划和元数据
music.upload上传音频文件,以便在后续修补工作流中使用,并可选择提取其编曲计划

完整参数详情请参阅 API 参考。

拥有修补功能访问权限的企业客户端可使用 music.upload。

编曲计划

如需精细控制,请先生成编曲计划,再进行修改,然后创作音乐:

plan = client.music.composition_plan.create(
    prompt="An epic orchestral piece building to a climax",
    music_length_ms=60000
)

# Inspect/modify styles and sections
print(plan.positiveGlobalStyles)  # e.g. ["orchestral", "epic", "cinematic"]

audio = client.music.compose(
    composition_plan=plan,
    music_length_ms=60000
)

内容限制

  • 不得提及特定艺术家、乐队或受版权保护的歌词
  • bad_prompt 错误会附带 prompt_suggestion,其中包含替代措辞
  • bad_composition_plan 错误会附带 composition_plan_suggestion

错误处理

try:
    audio = client.music.compose(prompt="...", music_length_ms=30000)
except Exception as e:
    print(f"API error: {e}")

常见错误:401(密钥无效)、422(参数无效)、429(请求频率受限)。

参考资料

评论

支持 Markdown