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

# Crea dialogo

POST https://api.elevenlabs.io/v1/text-to-dialogue
Content-Type: application/json

Converte un elenco di coppie di testo e ID vocale in parlato (dialogo) e restituisce l'audio.

Reference: https://elevenlabs.io/docs/api-reference/text-to-dialogue/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, default: mp3_44100_128) — Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM and WAV formats with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs.
  - Allowed values: `alaw_8000`, `mp3_22050_32`, `mp3_24000_48`, `mp3_44100_128`, `mp3_44100_192`, `mp3_44100_32`, `mp3_44100_64`, `mp3_44100_96`, `opus_48000_128`, `opus_48000_192`, `opus_48000_32`, `opus_48000_64`, `opus_48000_96`, `pcm_16000`, `pcm_22050`, `pcm_24000`, `pcm_32000`, `pcm_44100`, `pcm_48000`, `pcm_8000`, `ulaw_8000`, `wav_16000`, `wav_22050`, `wav_24000`, `wav_32000`, `wav_44100`, `wav_48000`, `wav_8000`
- `enable_logging` (boolean, optional, default: true) — Quando enable_logging è impostato su false, per la richiesta verrà usata la modalità senza conservazione dei dati. Di conseguenza, le funzionalità della cronologia non saranno disponibili per questa richiesta, incluso il collegamento delle richieste. La modalità senza conservazione dei dati può essere usata solo dai clienti enterprise.

### Body (application/json)

This endpoint expects a Body_Text_to_dialogue__multi_voice__v1_text_to_dialogue_post.

- `inputs` (list of DialogueInput, required) — Un elenco di input di dialogo, ciascuno contenente testo e un ID della voce che verrà convertito in parlato. Il numero massimo di ID vocali univoci è 10. Per una generazione affidabile, mantieni il conteggio totale dei caratteri in tutti i valori `inputs[].text` pari o inferiore a 2.000 caratteri per richiesta. Le richieste più lunghe potrebbero terminare anticipatamente nelle risposte in streaming o restituire un errore di convalida.
- `model_id` (string, optional, default: eleven_v3) — Identificatore del modello che verrà usato; puoi interrogarli tramite GET /v1/models. Il modello deve supportare la sintesi vocale; puoi verificarlo tramite la proprietà can_do_text_to_speech.
- `language_code` (string, optional, nullable) — Codice lingua (ISO 639-1) usato per applicare una lingua al modello e alla normalizzazione del testo. Se il modello non supporta il codice lingua fornito, verrà ignorato. Questo parametro non è supportato per i modelli multilingual_v2.
- `settings` (ToDialogueSettingsResponseModel, optional, nullable) — Impostazioni che controllano la generazione del dialogo.
- `previous_text` (string, optional, nullable) — Il testo immediatamente precedente a questa generazione, usato per condizionare il modello alla continuità prosodica. Puoi inviare al massimo 100 caratteri. Non è supportato da tutti i modelli.
- `future_text` (string, optional, nullable) — Il testo immediatamente successivo a questa generazione, usato per condizionare il modello alla continuità prosodica. Puoi inviare al massimo 100 caratteri. Non è supportato da tutti i modelli.
- `pronunciation_dictionary_locators` (list of PronunciationDictionaryVersionLocatorRequestModel, optional, nullable) — Un elenco di locator dei dizionari di pronuncia (id, version_id) da applicare al testo. Verranno applicati nell'ordine indicato. Puoi includere fino a 3 locator per richiesta.
- `seed` (integer, optional, nullable) — Se specificato, il nostro sistema farà del suo meglio per eseguire il campionamento in modo deterministico, così che richieste ripetute con lo stesso seed e gli stessi parametri restituiscano lo stesso risultato. Il determinismo non è garantito. Deve essere un numero intero compreso tra 0 e 4294967295.
- `apply_text_normalization` (enum, optional, default: auto) — Questo parametro controlla la normalizzazione del testo con tre modalità: 'auto', 'on' e 'off'. Se impostato su 'auto', il sistema decide automaticamente se applicare la normalizzazione del testo, ad esempio scrivendo i numeri in lettere. Con 'on', la normalizzazione del testo viene sempre applicata, mentre con 'off' viene ignorata.
  - Allowed values: `auto`, `on`, `off`
- `use_pvc_as_ivc` (boolean, optional, default: false) — Indica se usare la versione IVC di una voce professionale. Può migliorare l'espressività e ridurre la latenza.
- `previous_request_ids` (list of string, optional, nullable) — Un elenco di request_ids delle generazioni di dialogo precedenti a questa. Viene usato per condizionare il modello e garantire continuità quando una grande attività viene suddivisa in più richieste. Puoi inviare al massimo 3 request_ids. L'ultimo request_id corrisponde all'audio più vicino alla richiesta corrente. Non è supportato da tutti i modelli.
- `next_request_ids` (list of string, optional, nullable) — Un elenco di request_ids delle generazioni di dialogo successive a questa. Utile per mantenere la continuità quando rigeneri una clip al centro di una sequenza. Puoi inviare al massimo 3 request_ids. Il primo request_id corrisponde all'audio più vicino alla richiesta corrente. Non è supportato da tutti i modelli.

## Response

### 200

Il file audio generato

- File download.

## Errors

### 422 Unprocessable Entity Error

Errore di convalida

- `detail` (list of ValidationError, optional)

## Types

### DialogueInput

- `text` (string, required) — Il testo da convertire in parlato.
- `voice_id` (string, required) — L'ID della voce da usare per la generazione.

### ToDialogueSettingsResponseModel

- `stability` (double, optional, nullable, default: 0.5) — Determina la stabilità della voce e il grado di casualità tra le generazioni. Valori più bassi introducono una gamma emotiva più ampia. Valori più alti possono produrre una voce monotona con emozioni limitate.
- `similarity` (double, optional, nullable, default: 0.75) — Determina quanto strettamente il modello viene guidato durante la generazione. Valori più alti fanno sì che il modello si attenga maggiormente alla voce, a scapito della varietà. Non è supportato da tutti i modelli.

### PronunciationDictionaryVersionLocatorRequestModel

- `pronunciation_dictionary_id` (string, required) — L'ID del dizionario di pronuncia.
- `version_id` (string, optional, nullable) — L'ID della versione del dizionario di pronuncia. Se non viene fornito, verrà usata la versione più recente.

### ValidationError

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

### ValidationErrorLocItems

## Examples

**Request**

```json
{
  "inputs": [
    {
      "text": "[giggling] Knock knock",
      "voice_id": "JBFqnCBsd6RMkjVDRZzb"
    },
    {
      "text": "[curious] Who is there?",
      "voice_id": "Aw4FAjKCGjjNkVhN1Xmq"
    }
  ]
}
```

**SDK Code**

```python
import requests

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

payload = { "inputs": [
        {
            "text": "[giggling] Knock knock",
            "voice_id": "JBFqnCBsd6RMkjVDRZzb"
        },
        {
            "text": "[curious] Who is there?",
            "voice_id": "Aw4FAjKCGjjNkVhN1Xmq"
        }
    ] }
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/text-to-dialogue';
const options = {
  method: 'POST',
  headers: {'xi-api-key': 'xi-api-key', 'Content-Type': 'application/json'},
  body: '{"inputs":[{"text":"[giggling] Knock knock","voice_id":"JBFqnCBsd6RMkjVDRZzb"},{"text":"[curious] Who is there?","voice_id":"Aw4FAjKCGjjNkVhN1Xmq"}]}'
};

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

	payload := strings.NewReader("{\n  \"inputs\": [\n    {\n      \"text\": \"[giggling] Knock knock\",\n      \"voice_id\": \"JBFqnCBsd6RMkjVDRZzb\"\n    },\n    {\n      \"text\": \"[curious] Who is there?\",\n      \"voice_id\": \"Aw4FAjKCGjjNkVhN1Xmq\"\n    }\n  ]\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/text-to-dialogue")

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  \"inputs\": [\n    {\n      \"text\": \"[giggling] Knock knock\",\n      \"voice_id\": \"JBFqnCBsd6RMkjVDRZzb\"\n    },\n    {\n      \"text\": \"[curious] Who is there?\",\n      \"voice_id\": \"Aw4FAjKCGjjNkVhN1Xmq\"\n    }\n  ]\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/text-to-dialogue")
  .header("xi-api-key", "xi-api-key")
  .header("Content-Type", "application/json")
  .body("{\n  \"inputs\": [\n    {\n      \"text\": \"[giggling] Knock knock\",\n      \"voice_id\": \"JBFqnCBsd6RMkjVDRZzb\"\n    },\n    {\n      \"text\": \"[curious] Who is there?\",\n      \"voice_id\": \"Aw4FAjKCGjjNkVhN1Xmq\"\n    }\n  ]\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.elevenlabs.io/v1/text-to-dialogue', [
  'body' => '{
  "inputs": [
    {
      "text": "[giggling] Knock knock",
      "voice_id": "JBFqnCBsd6RMkjVDRZzb"
    },
    {
      "text": "[curious] Who is there?",
      "voice_id": "Aw4FAjKCGjjNkVhN1Xmq"
    }
  ]
}',
  '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/text-to-dialogue");
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  \"inputs\": [\n    {\n      \"text\": \"[giggling] Knock knock\",\n      \"voice_id\": \"JBFqnCBsd6RMkjVDRZzb\"\n    },\n    {\n      \"text\": \"[curious] Who is there?\",\n      \"voice_id\": \"Aw4FAjKCGjjNkVhN1Xmq\"\n    }\n  ]\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 = ["inputs": [
    [
      "text": "[giggling] Knock knock",
      "voice_id": "JBFqnCBsd6RMkjVDRZzb"
    ],
    [
      "text": "[curious] Who is there?",
      "voice_id": "Aw4FAjKCGjjNkVhN1Xmq"
    ]
  ]] as [String : Any]

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

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