music-generation

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Music Generation Skill

音乐生成Skill

Overview

概述

This skill generates songs (vocal or instrumental) from a structured JSON spec using the MiniMax music generation API (
/v1/music_generation
). You describe the style/mood/scene in
prompt
, optionally provide
lyrics
, and the script returns an MP3.
此Skill通过MiniMax音乐生成API(
/v1/music_generation
),根据结构化的JSON规范生成歌曲(带人声或纯器乐)。你可以在
prompt
中描述风格/情绪/场景,可选提供
lyrics
,脚本会返回一个MP3文件。

Workflow

工作流程

Step 1: Understand Requirements

步骤1:理解需求

Identify the desired style, mood, scene, language, and whether the user wants vocals or a pure instrumental track. Decide whether to supply lyrics or let the model write them.
确定用户期望的风格、情绪、场景、语言,以及用户想要带人声的歌曲还是纯器乐曲目。决定是否提供歌词,还是让模型自动生成歌词。

Step 2: Create the Spec JSON

步骤2:创建规范JSON

Write a JSON file in
/mnt/user-data/workspace/
named
{descriptive-name}.json
:
json
{
  "title": "Rainy Night Cafe",
  "prompt": "indie folk, melancholic, introspective, walking alone, cafe",
  "lyrics": "[verse]\nStreetlights glow the night wind sighs\n[chorus]\nPush the wooden door warm air inside"
}
Fields:
  • title
    (optional): a human-readable name.
  • prompt
    (required): style, mood, and scene. Drives the musical character.
  • lyrics
    (optional): song lyrics. Use
    \n
    between lines and structure tags such as
    [Intro]
    ,
    [Verse]
    ,
    [Pre Chorus]
    ,
    [Chorus]
    ,
    [Bridge]
    ,
    [Outro]
    .
  • is_instrumental
    (optional, bool): set
    true
    for a pure instrumental track (no lyrics needed).
Behavior:
  • lyrics
    provided → those lyrics are sung.
  • is_instrumental: true
    → instrumental, no vocals.
  • neither → the model auto-writes lyrics from
    prompt
    (
    lyrics_optimizer
    ).
/mnt/user-data/workspace/
目录下创建一个名为
{描述性名称}.json
的JSON文件:
json
{
  "title": "Rainy Night Cafe",
  "prompt": "indie folk, melancholic, introspective, walking alone, cafe",
  "lyrics": "[verse]\nStreetlights glow the night wind sighs\n[chorus]\nPush the wooden door warm air inside"
}
字段说明:
  • title
    (可选):便于识别的歌曲名称。
  • prompt
    (必填):风格、情绪和场景描述,决定音乐的整体特征。
  • lyrics
    (可选):歌曲歌词。行与行之间用
    \n
    分隔,可使用
    [Intro]
    [Verse]
    [Pre Chorus]
    [Chorus]
    [Bridge]
    [Outro]
    等结构标签。
  • is_instrumental
    (可选,布尔值):设为
    true
    时生成纯器乐曲目(无需歌词)。
行为逻辑:
  • 提供
    lyrics
    → 将演唱该歌词。
  • 设置
    is_instrumental: true
    → 生成纯器乐,无人声。
  • 两者都不设置 → 模型根据
    prompt
    自动生成歌词(启用
    lyrics_optimizer
    )。

Step 3: Execute Generation

步骤3:执行生成

bash
python /mnt/skills/public/music-generation/scripts/generate.py \
  --prompt-file /mnt/user-data/workspace/rainy-night-cafe.json \
  --output-file /mnt/user-data/outputs/rainy-night-cafe.mp3
Parameters:
  • --prompt-file
    : Absolute path to the JSON spec (required).
  • --output-file
    : Absolute path for the output MP3 (required).
[!NOTE] Do NOT read the python file, just call it with the parameters.
bash
python /mnt/skills/public/music-generation/scripts/generate.py \
  --prompt-file /mnt/user-data/workspace/rainy-night-cafe.json \
  --output-file /mnt/user-data/outputs/rainy-night-cafe.mp3
参数说明:
  • --prompt-file
    :JSON规范文件的绝对路径(必填)。
  • --output-file
    :输出MP3文件的绝对路径(必填)。
[!注意] 请勿读取该Python文件,只需按参数调用它即可。

Environment

环境配置

  • MINIMAX_API_KEY
    (required): your MiniMax interface key.
  • MINIMAX_API_HOST
    (optional): default
    https://api.minimaxi.com
    .
  • MINIMAX_MUSIC_MODEL
    (optional): default
    music-2.6-free
    (works for all API-key users); paid/Token-Plan users can set
    music-2.6
    for higher limits.
  • MINIMAX_API_KEY
    (必填):你的MiniMax接口密钥。
  • MINIMAX_API_HOST
    (可选):默认值为
    https://api.minimaxi.com
  • MINIMAX_MUSIC_MODEL
    (可选):默认值为
    music-2.6-free
    (适用于所有API密钥用户);付费/Token套餐用户可设置为
    music-2.6
    以获得更高调用限额。

Output Handling

输出处理

  • Music is saved as MP3 (typically in
    /mnt/user-data/outputs/
    ).
  • Share the generated file with the user using the present_files tool.
  • Offer to iterate on style or lyrics if adjustments are needed.
  • 音乐将保存为MP3格式(通常存储在
    /mnt/user-data/outputs/
    目录下)。
  • 使用present_files工具将生成的文件分享给用户。
  • 如果需要调整,可主动提出对风格或歌词进行迭代优化。

Notes

注意事项

  • Keep
    prompt
    focused on style/mood/scene; put the actual sung words in
    lyrics
    .
  • For non-English songs, write
    lyrics
    in the target language.
  • prompt
    应聚焦于风格/情绪/场景描述;实际演唱的歌词请放在
    lyrics
    中。
  • 若要生成非英语歌曲,请用目标语言编写
    lyrics