कंपोज़िशन प्लान

संरचित JSON के साथ संगीत जनरेशन पर सटीक नियंत्रण

कंपोज़िशन प्लान संगीत जनरेशन पर बारीक नियंत्रण देते हैं। music_v2 या music_v2_5 प्लान चंक्स की एक क्रमबद्ध सूची है, जिसमें हर चंक गाने का एक सेक्शन तय करता है और उसके अपने स्टाइल, बोल और अवधि होती है। तेज़ी से प्रोटोटाइप बनाने के लिए टेक्स्ट प्रॉम्प्ट इस्तेमाल करें और जब आपको खास चंक स्ट्रक्चर, बोलों की सटीक टाइमिंग या जटिल अरेंजमेंट चाहिए हों, तब कंपोज़िशन प्लान इस्तेमाल करें।

कंपोज़िशन प्लान और टेक्स्ट प्रॉम्प्ट एक-दूसरे के विकल्प हैं। दोनों नहीं, इनमें से किसी एक का इस्तेमाल करें।

{
"chunks": [
{
"text": "[Verse 1]\nWoke up today with a feeling inside\nSomething is changing I cannot hide\nThe sun on my face and the wind at my back\nI'm finally ready to get on track",
"duration_ms": 16000,
"positive_styles": [
"upbeat pop",
"female vocalist with clear tone",
"acoustic guitar and light synths",
"gentle and conversational vocals",
"light drums in background",
"polished production",
"120 BPM",
"C major"
],
"negative_styles": ["dark", "aggressive", "slow tempo", "a cappella"],
"context_adherence": "high"
},
{
"text": "[Verse 2]\nUsed to be scared of the world outside\nBuilding up walls where I used to hide\nBut now I see clearly what I need to do\nTake that first step into something new",
"duration_ms": 16000,
"positive_styles": [
"confident vocals",
"fuller guitar strumming",
"steady drum beat",
"bass joins in"
],
"negative_styles": ["a cappella", "sparse", "quiet"],
"context_adherence": "high"
},
{
"text": "[Pre-Chorus]\nNo more waiting for tomorrow\nThis is my time now",
"duration_ms": 8000,
"positive_styles": [
"building intensity",
"rising synth melody",
"driving drums",
"full band playing"
],
"negative_styles": ["a cappella", "dropping out"],
"context_adherence": "high"
},
{
"text": "[Chorus]\nI'm breaking through\nNothing's gonna stop me now\nI'm breaking through\nFinally found out how",
"duration_ms": 16000,
"positive_styles": [
"powerful and anthemic vocals",
"full band at maximum energy",
"punchy drums and bass",
"layered synths and guitar"
],
"negative_styles": ["a cappella", "minimal", "stripped back"],
"context_adherence": "high"
},
{
"text": "[Outro]",
"duration_ms": 8000,
"positive_styles": [
"instrumental fade out",
"guitar melody repeating",
"drums softening",
"gentle ending"
],
"negative_styles": ["vocals", "abrupt ending", "building"],
"context_adherence": "high"
}
]
}

चंक-आधारित कंपोज़िशन प्लान के लिए music_v2 या music_v2_5 चाहिए। कंपोज़ करते समय model_id="music_v2_5" पास करें।

क्विकस्टार्ट

अपनी API कुंजी सेट अप करने और SDK इंस्टॉल करने के लिए म्यूज़िक क्विकस्टार्ट देखें, फिर ज़्यादा नियंत्रण के लिए कंपोज़िशन प्लान इस्तेमाल करें।

1

कंपोज़िशन प्लान से संगीत जनरेट करें

import os
from dotenv import load_dotenv
from elevenlabs.client import ElevenLabs
load_dotenv()
elevenlabs = ElevenLabs(api_key=os.environ.get("ELEVENLABS_API_KEY"))
composition_plan = {
"chunks": [
{
"text": "[Verse]\nWalking down an empty street\nWondering who I'll meet",
"duration_ms": 15000,
"positive_styles": ["pop", "upbeat", "female vocals", "soft vocals", "acoustic guitar"],
"negative_styles": ["dark", "slow"],
"context_adherence": "high"
},
{
"text": "[Chorus]\nThis is my moment\nI won't let it go",
"duration_ms": 15000,
"positive_styles": ["powerful vocals", "full band"],
"negative_styles": [],
"context_adherence": "high"
}
]
}
audio = elevenlabs.music.compose(
composition_plan=composition_plan,
model_id="music_v2_5",
# with_timestamps=True, # Optional: return word-level timestamps
)
with open("output.mp3", "wb") as f:
for chunk in audio:
f.write(chunk)
2

प्रॉम्प्ट से प्लान जनरेट करें

टेक्स्ट विवरण से एक कंपोज़िशन प्लान जनरेट करें, फिर जनरेट करने से पहले उसमें बदलाव करें:

plan = elevenlabs.music.composition_plan.create(
prompt="An upbeat pop song about summer adventures",
music_length_ms=60000,
model_id="music_v2_5"
)
# Modify the generated plan
plan["chunks"][0]["text"] = "[Verse 1]\nCustom lyrics here"
audio = elevenlabs.music.compose(composition_plan=plan, model_id="music_v2_5")

स्ट्रक्चर रेफरेंस

चंक्स

कंपोज़िशन प्लान अधिकतम 30 चंक्स की एक क्रमबद्ध सूची है। हर चंक अपने text और स्टाइल से गाने का एक सेक्शन जनरेट करता है। पहला चंक सबसे अहम होता है: उसके स्टाइल पूरे गाने का ओवरऑल टोन और जॉनर तय करते हैं।

फ़ील्डटाइपविवरण
textstringस्क्वेयर ब्रैकेट में सेक्शन का नाम ([Verse 1]), बोलों की लाइनें और कर्ली ब्रेसेस में इनलाइन निर्देश ({scratching})।
duration_msnumberमिलीसेकंड में लंबाई (3,000 - 120,000)।
positive_stylesarrayशामिल किए जाने वाले स्टाइल और निर्देश (अधिकतम 50)।
negative_stylesarrayजिन स्टाइल और निर्देशों से बचना है (अधिकतम 50)। डिफ़ॉल्ट रूप से खाली।
context_adherencestringlow, medium, या high (डिफ़ॉल्ट)। चंक अपने आसपास के चंक्स का कितनी बारीकी से पालन करता है।

एक गाने में अधिकतम 30 चंक्स हो सकते हैं। कुल अवधि 3 सेकंड से 10 मिनट के बीच होनी चाहिए और हर चंक 3 से 120 सेकंड के बीच होना चाहिए।

पहले चंक के स्टाइल सबसे महत्वपूर्ण होते हैं, क्योंकि वे ओवरऑल टोन और जॉनर तय करते हैं। दिशा तय होने तक शुरुआती चंक्स में कम से कम 6-7 स्टाइल रखने की कोशिश करें। “great production quality” जैसे सामान्य स्टाइल सूची में जोड़ने के लिए अच्छे डिफ़ॉल्ट हैं।

मौजूदा सेक्शंस को बिना बदले रखने या उन पर नया ऑडियो कंडीशन करने के लिए चंक्स, स्टोर किए गए गाने के ऑडियो को भी रेफरेंस कर सकते हैं। मौजूदा गानों को एडिट और जोड़ने के लिए म्यूज़िक इनपेंटिंग देखें।

बोल लिखना

text फ़ील्ड में सेक्शन का नाम, बोल और इनलाइन निर्देश शामिल होते हैं:

  • स्क्वेयर ब्रैकेट में सेक्शन का नाम: [Verse 1], [Chorus], [Bridge]
  • सादे टेक्स्ट के रूप में बोल, जहाँ हर लाइन लाइन ब्रेक (\n) से अलग हो
  • कोष्ठक में फोनेटिक ध्वनियाँ: (hmmm hmmm), (ooh), (yeah)
  • कर्ली ब्रेसेस में इनलाइन निर्देश: {guitar solo}, {scratching}, {instrumental break}

छोटे, इनलाइन संकेतों के लिए कर्ली ब्रेसेस इस्तेमाल करें। पूरे चंक पर लागू होने वाली व्यापक विशेषताओं—जॉनर, इंस्ट्रूमेंटेशन या ओवरऑल वोकल स्टाइल—के लिए positive_styles इस्तेमाल करें।

{
"text": "[Verse]\n(soft female vocals) I've been waiting\n(instrumental break)\nfor you"
}

सुधारे गए उदाहरण में, ओवरऑल वोकल स्टाइल को positive_styles में रखा गया है, जबकि छोटे इनलाइन संकेत को कोष्ठक की बजाय कर्ली ब्रेसेस के साथ text में रखा गया है।

स्टाइल टिप्स

स्टाइल डिस्क्रिप्टर के साथ स्पष्ट रहें:

{
"positive_styles": [
"warm acoustic guitar with light fingerpicking",
"soft female vocals with intimate delivery",
"gentle percussion with brushed snare",
"80 BPM"
]
}

अनचाही ध्वनियों को रोकने के लिए नेगेटिव स्टाइल का भरपूर इस्तेमाल करें। स्टाइल अंग्रेज़ी में होने चाहिए (बोल किसी भी भाषा में हो सकते हैं)।

अगर आप स्टाइल में कॉपीराइटेड सामग्री शामिल करते हैं, तो API सुझाए गए विकल्प के साथ bad_composition_plan त्रुटि देता है। कॉपीराइटेड सामग्री को संभालना देखें।

उदाहरण

सिनेमैटिक इंस्ट्रूमेंटल

{
"chunks": [
{
"text": "[Tension Build]",
"duration_ms": 15000,
"positive_styles": [
"cinematic",
"orchestral",
"epic",
"low strings tremolo",
"building intensity",
"80 BPM",
"D minor"
],
"negative_styles": ["vocals", "lyrics", "pop", "electronic", "bright"],
"context_adherence": "high"
},
{
"text": "[Climax]",
"duration_ms": 15000,
"positive_styles": ["full orchestra", "brass fanfare", "triumphant"],
"negative_styles": ["quiet", "vocals"],
"context_adherence": "high"
},
{
"text": "[Resolution]",
"duration_ms": 10000,
"positive_styles": ["gentle strings", "piano melody", "fading out"],
"negative_styles": ["intense", "vocals"],
"context_adherence": "high"
}
]
}

वॉइसओवर के साथ विज्ञापन

{
"chunks": [
{
"text": "[Intro]",
"duration_ms": 5000,
"positive_styles": [
"upbeat",
"modern pop",
"energetic",
"120 BPM",
"instrumental",
"catchy hook"
],
"negative_styles": ["sad", "slow", "dark", "vocals"],
"context_adherence": "high"
},
{
"text": "[Voiceover]\nIntroducing the future of productivity\nWork smarter, not harder",
"duration_ms": 10000,
"positive_styles": ["spoken voiceover", "confident male voice", "background music"],
"negative_styles": ["singing"],
"context_adherence": "high"
},
{
"text": "[Outro]",
"duration_ms": 5000,
"positive_styles": ["musical sting", "memorable"],
"negative_styles": ["vocals"],
"context_adherence": "high"
}
]
}

अगले चरण