> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# म्यूज़िक अपलोड करें

POST https://api.elevenlabs.io/v1/music/upload
Content-Type: multipart/form-data

बाद में inpainting के लिए इस्तेमाल करने हेतु एक म्यूज़िक फ़ाइल अपलोड करें। अपलोड की कीमत गाना जनरेट करने जितनी ही है। अपलोड किए गए सभी कॉन्टेंट की कॉपीराइट उल्लंघन के लिए जांच होती है। कॉपीराइट वाला कॉन्टेंट मिलने पर भी अनुरोध की आधी लागत ली जाएगी।

Reference: https://elevenlabs.io/docs/api-reference/music/upload

## Servers

- `https://api.elevenlabs.io` (Production, default)
- `https://api.us.elevenlabs.io` (Production US)
- `https://api.eu.residency.elevenlabs.io` (Production EU)
- `https://api.in.residency.elevenlabs.io` (Production India)
- `https://api.sg.residency.elevenlabs.io` (Production Singapore)

## Request

### Body (multipart/form-data)

This endpoint expects a multipart form containing a file.

- `file` (file, required) — अपलोड करने के लिए ऑडियो फ़ाइल।
- `extract_composition_plan` (V1MusicUploadPostRequestBodyContentMultipartFormDataSchemaExtractCompositionPlan, optional) — क्या अपलोड किए गए गाने के लिए कंपोज़िशन प्लान जनरेट करके लौटाना है। कौन-सा कंपोज़िशन प्लान फ़ॉर्मैट लौटाया जाए, इसे नियंत्रित करने के लिए मॉडल id (`music_v1`, `music_v2` या `music_v2_5`) दें। `true`/`false` देना अप्रचलित है; `true` डिफ़ॉल्ट रूप से `music_v1` प्लान फ़ॉर्मैट का उपयोग करता है। इसे सक्षम करने से लेटेंसी बढ़ेगी।
- `with_timestamps` (boolean, optional) — अपलोड किए गए गाने का ट्रांसक्रिप्शन करके शब्द-स्तरीय टाइमस्टैम्प लौटाने हैं या नहीं। यदि True है, तो रिस्पॉन्स में words_timestamps शामिल होंगे, लेकिन लेटेंसी बढ़ेगी।
- `with_waveform_visual` (boolean, optional) — अपलोड किए गए गाने का विज़ुअल वेवफ़ॉर्म लौटाना है या नहीं।

## Response

### 200

वैकल्पिक कंपोज़िशन प्लान के साथ म्यूज़िक फ़ाइल सफलतापूर्वक अपलोड की गई

- `song_id` (string, required) — अपलोड किए गए गाने का विशिष्ट पहचानकर्ता
- `composition_plan` (MusicUploadResponseCompositionPlan, optional, nullable) — अपलोड किए गए गाने से निकाला गया कंपोज़िशन प्लान। यह केवल तभी मौजूद होता है जब अनुरोध बॉडी में `extract_composition_plan` दिया गया हो।
- `words_timestamps` (list of WordTimestamp, optional, nullable) — अपलोड किए गए गाने से ट्रांसक्राइब किए गए शब्द-स्तरीय टाइमस्टैम्प। केवल तब मौजूद होते हैं जब रिक्वेस्ट बॉडी में `with_timestamps` True हो
- `waveform_visual` (list of integer, optional, nullable) — अपलोड किए गए गाने का लो-रिज़ॉल्यूशन वेवफ़ॉर्म, उसका प्रीव्यू दिखाने के लिए। इसमें ऑडियो के हर सेकंड के लिए -1000 से 1000 तक 4 मान होते हैं। स्टीरियो को मिलाकर एक चैनल बनाया जाता है। यह केवल तभी मौजूद होता है जब अनुरोध बॉडी में `with_waveform_visual` True हो।

## Errors

### 422 Unprocessable Entity Error

वैलिडेशन एरर

- `detail` (list of ValidationError, optional)

## Types

### MusicUploadResponseCompositionPlan

अपलोड किए गए गाने से निकाला गया कंपोज़िशन प्लान। यह केवल तभी मौजूद होता है जब अनुरोध बॉडी में `extract_composition_plan` दिया गया हो।

### WordTimestamp

- `word` (string, required)
- `start_ms` (integer, required)
- `end_ms` (integer, required)

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)

### MusicPrompt

`music_v1` मॉडल के लिए कंपोज़िशन प्लान। किसी अन्य मॉडल के साथ इस फ़ील्ड का इस्तेमाल करने पर एरर आएगा।

- `positive_global_styles` (list of string, required) — वे स्टाइल और म्यूज़िकल निर्देश जो पूरे गाने में होने चाहिए। बेहतर नतीजों के लिए अंग्रेज़ी का इस्तेमाल करें।
- `negative_global_styles` (list of string, required) — वे स्टाइल और म्यूज़िकल निर्देश जो पूरे गाने में नहीं होने चाहिए। बेहतर नतीजों के लिए अंग्रेज़ी का इस्तेमाल करें।
- `sections` (list of SongSection, required) — गाने के सेक्शन्स।

### CompositionPlan

`music_v2` और `music_v2_5` मॉडल के लिए कंपोज़िशन प्लान। किसी अन्य मॉडल के साथ इस फ़ील्ड का इस्तेमाल करने पर एरर आएगा।

- `chunks` (list of CompositionPlanChunksItems, required) — जनरेशन बनाने वाले चंक्स।

### ValidationErrorLocItems

### SongSection

- `section_name` (string, required) — सेक्शन का नाम। यह 1 से 100 वर्णों के बीच होना चाहिए।
- `positive_local_styles` (list of string, required) — वे स्टाइल और म्यूज़िकल निर्देश जो इस सेक्शन में होने चाहिए। बेहतर नतीजों के लिए अंग्रेज़ी का इस्तेमाल करें।
- `negative_local_styles` (list of string, required) — वे स्टाइल और म्यूज़िकल निर्देश जो इस सेक्शन में नहीं होने चाहिए। बेहतर नतीजों के लिए अंग्रेज़ी का इस्तेमाल करें।
- `duration_ms` (integer, required) — सेक्शन की अवधि मिलीसेकंड में। यह 3000ms और 120000ms के बीच होनी चाहिए।
- `lines` (list of string, required) — सेक्शन के बोल। हर सेक्शन में अधिकतम 30 पंक्तियां और हर पंक्ति में अधिकतम 200 वर्ण हो सकते हैं।
- `source_from` (SectionSource, optional, nullable) — section निकालने के लिए वैकल्पिक source। inpainting के लिए इस्तेमाल होता है।

### CompositionPlanChunksItems

### SectionSource

- `song_id` (string, required) — उस गाने की ID जिससे सेक्शन लेना है। गाना जनरेट करते समय आप रिस्पॉन्स हेडर में गाने की ID पा सकते हैं।
- `range` (TimeRange, required) — स्रोत गाने से निकालने की रेंज।
- `negative_ranges` (list of TimeRange, optional) — 'range' से बाहर रखने वाली रेंजेस।

### GenerationChunk-Input

- `text` (string, required) — इस चंक के लिए जनरेट किया जाने वाला टेक्स्ट कॉन्फ़िगरेशन। इसमें शुरुआत में स्क्वेयर ब्रैकेट में वैकल्पिक सेक्शन नाम, जैसे \[Verse 1], लिरिक्स की लाइनें और कर्ली ब्रेसेस में इनलाइन निर्देश, जैसे \{scratching}, शामिल हो सकते हैं। सेक्शन नाम 1 से 100 कैरेक्टर के बीच होना चाहिए। अधिकतम 30 लाइनें स्वीकार्य हैं और हर लाइन अधिकतम 200 कैरेक्टर की हो सकती है।
- `duration_ms` (integer, required) — चंक की अवधि मिलीसेकंड में। यह 3000ms और 120000ms के बीच होनी चाहिए।
- `positive_styles` (list of string, required) — वे स्टाइल और म्यूज़िकल निर्देश जो इस चंक में होने चाहिए। बेहतर नतीजों के लिए अंग्रेज़ी का इस्तेमाल करें। पहले चंक की स्टाइल सबसे महत्वपूर्ण होती हैं, क्योंकि वे गाने का समग्र टोन और जॉनर तय करती हैं। बाद के चंक्स की स्टाइल से बारीकियां, प्रगति या ज़ोर जोड़ा जा सकता है, या गाने की दिशा बदली जा सकती है। दिशा तय होने तक शुरुआती चंक्स में कम से कम 6-7 स्टाइल रखने का लक्ष्य रखें। 'great production quality' जैसी सामान्य स्टाइल सूची में जोड़ने के लिए अच्छे डिफ़ॉल्ट विकल्प हैं।
- `negative_styles` (list of string, optional) — वे स्टाइल और म्यूज़िकल निर्देश जो इस चंक में नहीं होने चाहिए। बेहतर नतीजों के लिए अंग्रेज़ी का इस्तेमाल करें। इसे खाली छोड़ना अच्छा डिफ़ॉल्ट है; इस फ़ील्ड का इस्तेमाल केवल तब करें, जब आप किसी खास स्टाइल या दिशा से स्पष्ट रूप से बचना चाहते हों।
- `context_adherence` (enum, optional, default: high) — मॉडल अपने आसपास के चंक के कॉन्टेक्स्ट का कितना पालन करता है। कम पालन का मतलब है कि मॉडल कॉन्टेक्स्ट से हटकर ज़्यादा रचनात्मक हो सकता है। ज़्यादा पालन का मतलब है कि मॉडल कॉन्टेक्स्ट के साथ ज़्यादा सुसंगत रहेगा।
  - Allowed values: `low`, `medium`, `high`
- `conditioning_ref` (AudioRefChunk, optional, nullable) — जनरेशन को कंडीशन करने के लिए ऑडियो रेफ़रेंस। पहला चंक सबसे महत्वपूर्ण है, क्योंकि यह बाद के सभी चंक्स की जनरेशन को प्रभावित करेगा। इसलिए, अगर आप पूरे गाने पर कंडीशनिंग लागू करना चाहते हैं, तो पहले चंक से शुरू करें।
- `condition_strength` (enum, optional, nullable) — मॉडल कंडीशनिंग रेफ़रेंस का कितनी मज़बूती से पालन करता है। कम स्ट्रेंथ का मतलब है कि मॉडल ज़्यादा रचनात्मक होगा और रेफ़रेंस से हटेगा। ज़्यादा स्ट्रेंथ का मतलब है कि मॉडल रेफ़रेंस के साथ ज़्यादा सुसंगत रहेगा।
  - Allowed values: `low`, `medium`, `high`, `xhigh`

### AudioRefChunk

- `song_id` (string, required) — उस गाने की ID जिससे चंक लेना है। गाना जनरेट करते समय आप रिस्पॉन्स हेडर में गाने की ID पा सकते हैं।
- `range` (TimeRange, required) — गाने से निकालने के लिए समय-सीमा।

### TimeRange

- `start_ms` (integer, required)
- `end_ms` (integer, required)

## Examples

**Request**

```json
{
  "file": "<file: string>"
}
```

**Response**

```json
{
  "song_id": "jR4Xz8kL2mNpQ9wVtY1b"
}
```

**SDK Code**

```python
import requests

url = "https://api.elevenlabs.io/v1/music/upload"

files = { "file": "open('string', 'rb')" }
payload = {
    "extract_composition_plan": ,
    "with_timestamps": ,
    "with_waveform_visual": 
}

response = requests.post(url, data=payload, files=files)

print(response.json())
```

```javascript
const url = 'https://api.elevenlabs.io/v1/music/upload';
const form = new FormData();
form.append('extract_composition_plan', '');
form.append('file', 'string');
form.append('with_timestamps', '');
form.append('with_waveform_visual', '');

const options = {method: 'POST'};

options.body = form;

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.elevenlabs.io/v1/music/upload"

	payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"extract_composition_plan\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"with_timestamps\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"with_waveform_visual\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")

	req, _ := http.NewRequest("POST", url, payload)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.elevenlabs.io/v1/music/upload")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"extract_composition_plan\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"with_timestamps\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"with_waveform_visual\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.elevenlabs.io/v1/music/upload")
  .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"extract_composition_plan\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"with_timestamps\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"with_waveform_visual\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.elevenlabs.io/v1/music/upload', [
  'multipart' => [
    [
        'name' => 'file',
        'filename' => 'string',
        'contents' => null
    ]
  ]
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.elevenlabs.io/v1/music/upload");
var request = new RestRequest(Method.POST);
request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"extract_composition_plan\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"with_timestamps\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"with_waveform_visual\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation
let parameters = [
  [
    "name": "extract_composition_plan",
    "value": 
  ],
  [
    "name": "file",
    "fileName": "string"
  ],
  [
    "name": "with_timestamps",
    "value": 
  ],
  [
    "name": "with_waveform_visual",
    "value": 
  ]
]

let boundary = "---011000010111000001101001"

var body = ""
var error: NSError? = nil
for param in parameters {
  let paramName = param["name"]!
  body += "--\(boundary)\r\n"
  body += "Content-Disposition:form-data; name=\"\(paramName)\""
  if let filename = param["fileName"] {
    let contentType = param["content-type"]!
    let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
    if (error != nil) {
      print(error as Any)
    }
    body += "; filename=\"\(filename)\"\r\n"
    body += "Content-Type: \(contentType)\r\n\r\n"
    body += fileContent
  } else if let paramValue = param["value"] {
    body += "\r\n\r\n\(paramValue)"
  }
}

let request = NSMutableURLRequest(url: NSURL(string: "https://api.elevenlabs.io/v1/music/upload")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```