> 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/flows/text-to-speech
Content-Type: application/json

चुने गए मॉडल के साथ स्पीच जनरेशन शुरू करें। टेक्स्ट टू स्पीच बिलिंग के तहत हर कैरेक्टर के लिए शुल्क लिया जाता है। असिंक्रोनस जनरेशन लाइफ़साइकल के लिए या वहाँ उपलब्ध न होने वाले मॉडल के लिए इसे `/v1/text-to-speech` के बजाय इस्तेमाल करें; सीधे, सिंक्रोनस स्पीच सिंथेसिस के लिए `/v1/text-to-speech` बेहतर है।

Reference: https://elevenlabs.io/docs/api-reference/flows/text-to-speech/create

## 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 (application/json)

This endpoint expects a TextToSpeechGenerationRequest.

- `TextToSpeechGenerationRequest`
  - `model_id`: `eleven_flash_v2_5` (ElevenFlashV2_5Request)
    - `text` (string, required) — स्पीच में सिंथेसाइज़ करने वाला टेक्स्ट।
    - `voice` (string, required) — बोलने के लिए इस्तेमाल की जाने वाली वॉइस का ID।
    - `language_code` (string, optional, nullable) — आउटपुट पर लागू करने के लिए ISO 639-1 भाषा कोड। टेक्स्ट से भाषा पहचानने के लिए इसे छोड़ दें।
    - `output_format` (enum, optional, default: mp3_44100_128) — `codec_sampleRateHz_bitrateKbps` के रूप में आउटपुट की ऑडियो एन्कोडिंग। `mp3_44100_192` के लिए Creator टियर या उससे ऊपर का प्लान ज़रूरी है।
      - Allowed values: `mp3_22050_32`, `mp3_24000_48`, `mp3_44100_32`, `mp3_44100_64`, `mp3_44100_96`, `mp3_44100_128`, `mp3_44100_192`
    - `pronunciation_dictionary_locators` (list of PronunciationDictionaryVersionLocator, optional) — प्राथमिकता क्रम में टेक्स्ट पर लागू करने के लिए उच्चारण शब्दकोश। अधिकतम 3।
    - `voice_settings` (ElevenFlashV2_5VoiceSettings, optional, nullable) — वॉइस की saved settings के लिए overrides, जो केवल इस generation पर लागू होते हैं।
    - `webhook` (WebhookTarget, optional, nullable) — जनरेशन पूरा होने या विफल होने पर उसका परिणाम workspace के कॉन्फ़िगर किए गए flows webhooks पर भेजने के लिए शामिल करें। webhook payload संबंधित GET endpoint के अंतिम रिस्पॉन्स से मेल खाता है।
  - `model_id`: `eleven_multilingual_v2` (ElevenMultilingualV2Request)
    - `text` (string, required) — स्पीच में सिंथेसाइज़ करने वाला टेक्स्ट।
    - `voice` (string, required) — बोलने के लिए इस्तेमाल की जाने वाली वॉइस का ID।
    - `output_format` (enum, optional, default: mp3_44100_128) — `codec_sampleRateHz_bitrateKbps` के रूप में आउटपुट की ऑडियो एन्कोडिंग। `mp3_44100_192` के लिए Creator टियर या उससे ऊपर का प्लान ज़रूरी है।
      - Allowed values: `mp3_22050_32`, `mp3_24000_48`, `mp3_44100_32`, `mp3_44100_64`, `mp3_44100_96`, `mp3_44100_128`, `mp3_44100_192`
    - `pronunciation_dictionary_locators` (list of PronunciationDictionaryVersionLocator, optional) — प्राथमिकता क्रम में टेक्स्ट पर लागू करने के लिए उच्चारण शब्दकोश। अधिकतम 3।
    - `voice_settings` (TtsVoiceSettings, optional, nullable) — वॉइस की saved settings के लिए overrides, जो केवल इस generation पर लागू होते हैं।
    - `webhook` (WebhookTarget, optional, nullable) — जनरेशन पूरा होने या विफल होने पर उसका परिणाम workspace के कॉन्फ़िगर किए गए flows webhooks पर भेजने के लिए शामिल करें। webhook payload संबंधित GET endpoint के अंतिम रिस्पॉन्स से मेल खाता है।
  - `model_id`: `eleven_v3` (ElevenV3Request)
    - `text` (string, required) — स्पीच में सिंथेसाइज़ करने वाला टेक्स्ट।
    - `voice` (string, required) — बोलने के लिए इस्तेमाल की जाने वाली वॉइस का ID।
    - `language_code` (string, optional, nullable) — आउटपुट पर लागू करने के लिए ISO 639-1 भाषा कोड। टेक्स्ट से भाषा पहचानने के लिए इसे छोड़ दें।
    - `output_format` (enum, optional, default: mp3_44100_128) — `codec_sampleRateHz_bitrateKbps` के रूप में आउटपुट की ऑडियो एन्कोडिंग। `mp3_44100_192` के लिए Creator टियर या उससे ऊपर का प्लान ज़रूरी है।
      - Allowed values: `mp3_22050_32`, `mp3_24000_48`, `mp3_44100_32`, `mp3_44100_64`, `mp3_44100_96`, `mp3_44100_128`, `mp3_44100_192`
    - `pronunciation_dictionary_locators` (list of PronunciationDictionaryVersionLocator, optional) — प्राथमिकता क्रम में टेक्स्ट पर लागू करने के लिए उच्चारण शब्दकोश। अधिकतम 3।
    - `voice_settings` (ElevenV3VoiceSettings, optional, nullable) — वॉइस की saved settings के लिए overrides, जो केवल इस generation पर लागू होते हैं।
    - `webhook` (WebhookTarget, optional, nullable) — जनरेशन पूरा होने या विफल होने पर उसका परिणाम workspace के कॉन्फ़िगर किए गए flows webhooks पर भेजने के लिए शामिल करें। webhook payload संबंधित GET endpoint के अंतिम रिस्पॉन्स से मेल खाता है।

## Response

### 200

सफल रिस्पॉन्स

- `id` (string, required) — जनरेशन का यूनीक आइडेंटिफ़ायर। आउटपुट पाने के लिए इसे संबंधित GET एंडपॉइंट को दें।
- `status` ("pending", required) — नई बनाई गई जनरेशन हमेशा `pending` होती है।

## Errors

### 422 Unprocessable Entity Error

वैलिडेशन एरर

- `detail` (list of ValidationError, optional)

## Types

### PronunciationDictionaryVersionLocator

स्पीच सिंथेसिस के दौरान लागू करने के लिए उच्चारण शब्दकोश।

- `pronunciation_dictionary_id` (string, required) — `POST /v1/pronunciation-dictionaries/add-from-file` या `POST /v1/pronunciation-dictionaries/add-from-rules` से बनाई गई उच्चारण डिक्शनरी की ID।
- `version_id` (string, optional, nullable) — इस्तेमाल करने के लिए डिक्शनरी का वर्ज़न। नवीनतम वर्ज़न इस्तेमाल करने के लिए इसे छोड़ दें।

### ElevenFlashV2_5VoiceSettings

वॉइस की saved settings के लिए overrides, जो एक generation पर लागू होते हैं।

- `stability` (double, optional, nullable) — अलग-अलग जनरेशन में वॉइस कितनी एक जैसी रहती है। कम वैल्यू ज़्यादा अभिव्यंजक और विविध स्पीच देती हैं।
- `similarity_boost` (double, optional, nullable) — आउटपुट मूल वॉइस से कितनी निकटता से मेल खाता है।
- `speed` (double, optional, nullable) — जनरेट की गई स्पीच की गति, जिसमें 1.0 वॉइस की प्राकृतिक गति है।

### WebhookTarget

- `type`: `all` (WebhookTargetAll)
- `type`: `ids` (WebhookTargetIds)
  - `ids` (list of string, required) — नतीजा भेजने के लिए workspace flows webhooks के ID। हर ID workspace के कॉन्फ़िगर किए गए flows webhooks में से एक होना चाहिए।

### TtsVoiceSettings

वॉइस की saved settings के लिए overrides, जो एक generation पर लागू होते हैं।

- `stability` (double, optional, nullable) — अलग-अलग जनरेशन में वॉइस कितनी एक जैसी रहती है। कम वैल्यू ज़्यादा अभिव्यंजक और विविध स्पीच देती हैं।
- `similarity_boost` (double, optional, nullable) — आउटपुट मूल वॉइस से कितनी निकटता से मेल खाता है।
- `style` (double, optional, nullable) — बोलने की शैली को कितना बढ़ा-चढ़ाकर पेश किया गया है।
- `use_speaker_boost` (boolean, optional, nullable) — क्या कुछ अतिरिक्त लेटेंसी के बदले मूल स्पीकर से समानता बढ़ानी है।
- `speed` (double, optional, nullable) — जनरेट की गई स्पीच की गति, जिसमें 1.0 वॉइस की प्राकृतिक गति है।

### ElevenV3VoiceSettings

वॉइस की saved settings के लिए overrides, जो एक generation पर लागू होते हैं।

- `stability` (double, optional, nullable) — अलग-अलग जनरेशन में वॉइस कितनी एक जैसी रहती है। कम वैल्यू ज़्यादा अभिव्यंजक और विविध स्पीच देती हैं।

### ValidationError

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

### ValidationErrorLocItems

## Examples

**Request**

```json
{
  "model_id": "string",
  "text": "The first move is what sets everything in motion.",
  "voice": "JBFqnCBsd6RMkjVDRZzb"
}
```

**Response**

```json
{
  "id": "JWr5N6X9ZTqf8jD2LmQb",
  "status": "pending"
}
```

**SDK Code**

```python
import requests

url = "https://api.elevenlabs.io/v1/flows/text-to-speech"

payload = {
    "model_id": "string",
    "text": "The first move is what sets everything in motion.",
    "voice": "JBFqnCBsd6RMkjVDRZzb"
}
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript
const url = 'https://api.elevenlabs.io/v1/flows/text-to-speech';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"model_id":"string","text":"The first move is what sets everything in motion.","voice":"JBFqnCBsd6RMkjVDRZzb"}'
};

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/flows/text-to-speech"

	payload := strings.NewReader("{\n  \"model_id\": \"string\",\n  \"text\": \"The first move is what sets everything in motion.\",\n  \"voice\": \"JBFqnCBsd6RMkjVDRZzb\"\n}")

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

	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/flows/text-to-speech")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model_id\": \"string\",\n  \"text\": \"The first move is what sets everything in motion.\",\n  \"voice\": \"JBFqnCBsd6RMkjVDRZzb\"\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/flows/text-to-speech")
  .header("Content-Type", "application/json")
  .body("{\n  \"model_id\": \"string\",\n  \"text\": \"The first move is what sets everything in motion.\",\n  \"voice\": \"JBFqnCBsd6RMkjVDRZzb\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.elevenlabs.io/v1/flows/text-to-speech', [
  'body' => '{
  "model_id": "string",
  "text": "The first move is what sets everything in motion.",
  "voice": "JBFqnCBsd6RMkjVDRZzb"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.elevenlabs.io/v1/flows/text-to-speech");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model_id\": \"string\",\n  \"text\": \"The first move is what sets everything in motion.\",\n  \"voice\": \"JBFqnCBsd6RMkjVDRZzb\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "model_id": "string",
  "text": "The first move is what sets everything in motion.",
  "voice": "JBFqnCBsd6RMkjVDRZzb"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.elevenlabs.io/v1/flows/text-to-speech")! 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()
```