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

テキストと音声IDのペアのリストを音声（対話）に変換し、オーディオストリームを返します。

Reference: https://elevenlabs.io/docs/api-reference/text-to-dialogue/stream

## 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) — 生成されたオーディオの出力形式。codec_sample_rate_bitrate形式で指定します。たとえば、サンプルレート22.05kHz、32kbpsのmp3はmp3_22050_32で表します。ビットレート192kbpsのMP3を使用するには、クリエイター以上への加入が必要です。サンプルレート44.1kHzのPCM形式を使用するには、プロ以上への加入が必要です。μ-law形式（mu-lawとも表記され、u-lawと近似表記されることもあります）は、Twilioのオーディオ入力で一般的に使用されます。
  - 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_Text_to_dialogue__multi_voice__streaming_v1_text_to_dialogue_stream_post.

- `inputs` (list of DialogueInput, required) — テキストと、音声に変換する音声IDをそれぞれ含む対話入力のリストです。一意の音声IDは最大10件です。安定して生成するため、すべての`inputs[].text`値の合計文字数は、リクエストあたり2,000文字以下にしてください。より長いリクエストでは、ストリーミングレスポンスが早期に終了するか、バリデーションエラーが返される場合があります。
- `model_id` (string, optional, default: eleven_v3) — 使用するモデルの識別子。GET /v1/modelsで照会できます。モデルはテキスト読み上げをサポートしている必要があり、can_do_text_to_speechプロパティで確認できます。
- `language_code` (string, optional, nullable) — モデルと言語正規化に適用する言語コード（ISO 639-1）です。モデルが指定された言語コードをサポートしていない場合は無視されます。このパラメータはmultilingual_v2モデルではサポートされません。
- `settings` (ToDialogueSettingsResponseModel, optional, nullable) — 対話生成を制御する設定です。
- `previous_text` (string, optional, nullable) — この生成の直前にあるテキスト。韻律の連続性を保つためにモデルを条件付けるために使用します。最大100文字を送信できます。すべてのモデルでサポートされているわけではありません。
- `future_text` (string, optional, nullable) — この生成の直後に続くテキスト。韻律の連続性を保つためにモデルを条件付けるために使用します。最大100文字を送信できます。すべてのモデルでサポートされているわけではありません。
- `pronunciation_dictionary_locators` (list of PronunciationDictionaryVersionLocatorRequestModel, optional, nullable) — テキストに適用する発音辞書ロケーター（id、version_id）の一覧です。指定した順序で適用されます。1リクエストにつき最大3つのロケーターを指定できます。
- `seed` (integer, optional, nullable) — 指定すると、同じシードとパラメータでリクエストを繰り返した場合に同じ結果が返るよう、システムは決定論的サンプリングを最大限試みます。決定性は保証されません。0から4294967295までの整数である必要があります。
- `apply_text_normalization` (enum, optional, default: auto) — このパラメーターは、'auto'、'on'、'off'の3つのモードでテキスト正規化を制御します。'auto'に設定すると、システムがテキスト正規化（例：数値の読み上げ）を適用するかどうかを自動的に判断します。'on'では常にテキスト正規化が適用され、'off'ではスキップされます。
  - Allowed values: `auto`, `on`, `off`
- `use_pvc_as_ivc` (boolean, optional, default: false) — プロフェッショナルボイスのIVCバージョンを使用するかどうかです。表現力が向上し、レイテンシーが低減する場合があります。
- `previous_request_ids` (list of string, optional, nullable) — この生成より前に行われた対話生成のrequest_idsのリストです。大きなタスクを複数のリクエストに分割する際、連続性を保つためにモデルを条件付ける用途で使用します。送信できるrequest_idsは最大3件です。最後のrequest_idは、現在のリクエストに最も近い音声です。すべてのモデルでサポートされているわけではありません。
- `next_request_ids` (list of string, optional, nullable) — この生成の後に行われる対話生成のrequest_idsのリストです。シーケンスの途中にあるクリップを再生成する際に、連続性を維持するのに役立ちます。送信できるrequest_idsは最大3件です。最初のrequest_idは、現在のリクエストに最も近い音声です。すべてのモデルでサポートされているわけではありません。
- `audio_effects` (EffectsSpec-Input, optional, nullable) — 生成されたオーディオに適用するオーディオエフェクト。不明なIDの場合は、フィールド名を示す `param` を含む404が返されます。リバーブ（`send_level` が0より大きい `environment_id`）と0以外の `pan` はステレオオーディオを生成するため、`ulaw_*`、`alaw_*`、`pcm_*` の出力形式では400で拒否されます。エフェクトによってリクエストの料金は変わりません。

## Response

### 200

ストリーミングオーディオデータ。

- Streaming response of `string`.

## Errors

### 422 Unprocessable Entity Error

検証エラー

- `detail` (list of ValidationError, optional)

## Types

### DialogueInput

- `text` (string, required) — 音声に変換するテキストです。
- `voice_id` (string, required) — 生成に使用する音声のID。

### ToDialogueSettingsResponseModel

- `stability` (double, optional, nullable, default: 0.5) — 音声の安定性と各生成間のランダム性を決定します。値が低いほど、音声の感情表現の幅が広がります。値が高いほど、感情表現が限られた単調な音声になる場合があります。
- `similarity` (double, optional, nullable, default: 0.75) — 生成時にモデルをどの程度強くガイドするかを決定します。値を高くすると変化の幅は小さくなりますが、モデルは音声により忠実に従います。すべてのモデルでサポートされているわけではありません。

### PronunciationDictionaryVersionLocatorRequestModel

- `pronunciation_dictionary_id` (string, required) — 発音辞書のID。
- `version_id` (string, optional, nullable) — 発音辞書バージョンのID。指定しない場合は最新バージョンが使用されます。

### EffectsSpec-Input

生成された音声に適用するオーディオエフェクトです。フィルタープリセット、知覚距離、リバーブ 環境、バックグラウンドノイズベッド、ステレオパンニングを含みます。未処理のオーディオを取得するには、すべてのフィールドをデフォルト値のままにしてください。

- `filter_preset_id` (string, optional, nullable) — `phone` や `old_radio` など、音声の音色を変えるフィルタープリセットのID。有効なIDは `GET /v1/audio-effects/catalog` で取得できます。
- `distance` (double, optional, default: 0) — 話者がマイクからどの程度離れて聞こえるかを指定します。0（近い、変更なし）から1（遠い）までです。値を大きくすると低域と高域が減衰し、環境が設定されている場合は、ドライ音声からリバーブへのバランスが移動します。
- `environment_id` (string, optional, nullable) — `small_room` や `hall` など、音声を空間内に配置するリバーブ環境のID。有効なIDは `GET /v1/audio-effects/catalog` で取得できます。リバーブはステレオでレンダリングされ、音声終了後に最大数秒の残響が追加されます。
- `background_noise_id` (string, optional, nullable) — `cafe` や `keyboard` など、音声の下でループ再生するバックグラウンドノイズベッドのID。有効なIDは `GET /v1/audio-effects/catalog` で取得できます。
- `send_level` (double, optional, default: 1) — 音声をどの程度リバーブに送るかを指定します。0（なし）から1（最大）までです。`environment_id` が設定されている場合にのみ適用されます。0ではリバーブが無効になります。
- `pan` (double, optional, default: 0) — 音声のステレオ位置。-1（左端）から0（中央）を経て1（右端）まで指定します。パンニングされるのは音声のみで、リバーブとバックグラウンドノイズは中央のままです。

### 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/stream"

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/stream';
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/stream"

	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/stream")

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/stream")
  .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/stream', [
  '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/stream");
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/stream")! 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()
```