> 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/sound-generation
Content-Type: application/json

दुनिया के सबसे उन्नत साउंड इफेक्ट्स मॉडल का इस्तेमाल करके अपने वीडियो, वॉइसओवर या वीडियो गेम्स के लिए टेक्स्ट को साउंड इफेक्ट्स में बदलें।

Reference: https://elevenlabs.io/docs/api-reference/text-to-sound-effects/convert

## 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

### Query parameters

- `output_format` (enum, optional) — जनरेट किए गए ऑडियो का output format। codec_sample_rate_bitrate के रूप में फ़ॉर्मैट किया जाता है। इसलिए, 32kbs पर 22.05kHz sample rate वाले mp3 को mp3_22050_32 के रूप में दर्शाया जाता है। 192kbps bitrate वाले MP3 के लिए Creator tier या उससे ऊपर का subscription चाहिए। 44.1kHz sample rate वाले PCM के लिए Pro tier या उससे ऊपर का subscription चाहिए। ध्यान दें कि μ-law format (कभी-कभी mu-law लिखा जाता है, और अक्सर u-law के रूप में अनुमानित) का उपयोग आमतौर पर Twilio audio inputs के लिए होता है।
  - Allowed values: `mp3_22050_32`, `mp3_24000_48`, `mp3_44100_32`, `mp3_44100_64`, `mp3_44100_96`, `mp3_44100_128`, `mp3_44100_192`, `pcm_8000`, `pcm_16000`, `pcm_22050`, `pcm_24000`, `pcm_32000`, `pcm_44100`, `pcm_48000`, `ulaw_8000`, `alaw_8000`, `opus_48000_32`, `opus_48000_64`, `opus_48000_96`, `opus_48000_128`, `opus_48000_192`
- `enable_logging` (boolean, optional, default: true) — जब enable_logging को false पर सेट किया जाता है, तो अनुरोध के लिए ज़ीरो रिटेंशन मोड इस्तेमाल होगा। ज़ीरो रिटेंशन मोड का इस्तेमाल सिर्फ़ एंटरप्राइज़ ग्राहक कर सकते हैं।

### Body (application/json)

This endpoint expects a Body_Sound_Generation_v1_sound_generation_post.

- `text` (string, required) — वह टेक्स्ट जिसे साउंड इफेक्ट में बदला जाएगा।
- `loop` (boolean, optional, default: false) — क्या ऐसा साउंड इफेक्ट बनाना है जो सहज रूप से लूप हो। यह केवल 'eleven_text_to_sound_v2 model' के लिए उपलब्ध है।
- `duration_seconds` (double, optional, nullable) — जनरेट होने वाली साउंड की अवधि सेकंड में। यह कम से कम 0.5 और अधिकतम 30 होनी चाहिए। None सेट होने पर, हम प्रॉम्प्ट के आधार पर अनुकूल अवधि का अनुमान लगाएंगे। डिफ़ॉल्ट None है।
- `prompt_influence` (double, optional, nullable, default: 0.3) — ज़्यादा prompt influence से आपकी जनरेशन prompt का अधिक बारीकी से पालन करती है और जनरेशन में विविधता कम होती है। मान 0 और 1 के बीच होना चाहिए। डिफ़ॉल्ट 0.3 है।
- `model_id` (enum, optional, default: eleven_text_to_sound_v2) — साउंड जनरेशन के लिए इस्तेमाल किया जाने वाला मॉडल ID।
  - Allowed values: `eleven_text_to_sound_v2`

## Response

### 200

MP3 फ़ाइल के रूप में जनरेट किया गया साउंड इफेक्ट

- File download.

## Errors

### 422 Unprocessable Entity Error

वैलिडेशन एरर

- `detail` (list of ValidationError, optional)

## Types

### ValidationError

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

### ValidationErrorLocItems

## Examples

**Request**

```json
{
  "text": "Spacious braam suitable for high-impact movie trailer moments"
}
```

**SDK Code**

```python
import requests

url = "https://api.elevenlabs.io/v1/sound-generation"

payload = { "text": "Spacious braam suitable for high-impact movie trailer moments" }
headers = {
    "xi-api-key": "xi-api-key",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.elevenlabs.io/v1/sound-generation';
const options = {
  method: 'POST',
  headers: {'xi-api-key': 'xi-api-key', 'Content-Type': 'application/json'},
  body: '{"text":"Spacious braam suitable for high-impact movie trailer moments"}'
};

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/sound-generation"

	payload := strings.NewReader("{\n  \"text\": \"Spacious braam suitable for high-impact movie trailer moments\"\n}")

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

	req.Header.Add("xi-api-key", "xi-api-key")
	req.Header.Add("Content-Type", "application/json")

	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/sound-generation")

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

request = Net::HTTP::Post.new(url)
request["xi-api-key"] = 'xi-api-key'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"text\": \"Spacious braam suitable for high-impact movie trailer moments\"\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/sound-generation")
  .header("xi-api-key", "xi-api-key")
  .header("Content-Type", "application/json")
  .body("{\n  \"text\": \"Spacious braam suitable for high-impact movie trailer moments\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.elevenlabs.io/v1/sound-generation', [
  'body' => '{
  "text": "Spacious braam suitable for high-impact movie trailer moments"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'xi-api-key' => 'xi-api-key',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.elevenlabs.io/v1/sound-generation");
var request = new RestRequest(Method.POST);
request.AddHeader("xi-api-key", "xi-api-key");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"text\": \"Spacious braam suitable for high-impact movie trailer moments\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "xi-api-key": "xi-api-key",
  "Content-Type": "application/json"
]
let parameters = ["text": "Spacious braam suitable for high-impact movie trailer moments"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.elevenlabs.io/v1/sound-generation")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
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()
```