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

# 吹き替えターゲットの文字起こしセグメントを更新

PATCH https://api.elevenlabs.io/v1/dubbing/project/{project_id}/language/{language_id}/transcript/segments
Content-Type: application/json

エンタープライズ限定。1つのアトミックリクエストで、言語ターゲットの複数セグメントの翻訳を編集します。すべての編集が適用されるか、まったく適用されません。ターゲットの`revision`を更新し、すでに完了している場合は`stale`としてマークします。ソース文字起こしとプロジェクト内の他の言語には影響せず、ターゲットを再生成するまでオーディオは変更されません。

Reference: https://elevenlabs.io/docs/api-reference/dubbing/target-transcript/update-target-segment

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

### Path parameters

- `project_id` (string, required) — 吹き替えプロジェクトの識別子。
- `language_id` (string, required) — 対象言語の識別子。

### Body (application/json)

This endpoint expects a DubbingBulkTargetSegmentUpdateRequest.

- `segments` (map from string to DubbingTargetSegmentUpdateRequest, required) — セグメントIDから、そのセグメントに適用する翻訳編集へのマップ。エントリは1件以上500件以下です。

## Response

### 200

成功レスポンス。

- `segments` (list of DubbingTargetTranscriptSegment, required) — 更新後の状態にある編集済み対象セグメント。
- `revision` (integer, required) — 編集後のターゲットのリビジョン。

## Errors

### 422 Unprocessable Entity Error

検証エラー

- `detail` (list of ValidationError, optional)

## Types

### DubbingTargetSegmentUpdateRequest

ターゲットセグメントへの部分的な編集です。省略したフィールドは変更されず、指定した`null` はその値をクリアします（クリアの意味については各フィールドを参照してください）。

- `translation` (string, optional, nullable) — 新しい翻訳テキスト。セグメントを再翻訳対象としてマークする場合はnullを指定します。

### DubbingTargetTranscriptSegment

ターゲット文字起こしの1つのセグメントです。ソースセグメントとその翻訳で構成されます。

- `id` (string, required) — セグメントの安定した識別子です（ソース由来）。
- `speaker_id` (string, required) — セグメントの話者の識別子。
- `start_s` (double, required) — セグメントの開始時刻（秒）。
- `end_s` (double, required) — セグメントの終了時刻（秒）。
- `source_text` (string, required) — セグメントのソース言語テキスト。
- `translation` (string, optional, nullable) — 翻訳済みのテキストです。まだ翻訳されていない場合（翻訳が必要な場合）はnullです。

### ValidationError

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

### ValidationErrorLocItems

## Examples

**Request**

```json
{
  "segments": {
    "0199a3f0-1c2d-7abc-8def-0123456789ab": {
      "translation": "Bienvenido a nuestra última demostración de producto."
    },
    "0199a3f0-3e4f-7abc-8def-0123456789cd": {
      "translation": "Empecemos."
    }
  }
}
```

**Response**

```json
{
  "segments": [
    {
      "id": "0199a3f0-1c2d-7abc-8def-0123456789ab",
      "speaker_id": "default_speaker",
      "start_s": 0,
      "end_s": 2.5,
      "source_text": "Welcome to our product demo.",
      "translation": "Bienvenido a nuestra última demostración de producto."
    },
    {
      "id": "0199a3f0-3e4f-7abc-8def-0123456789cd",
      "speaker_id": "narrator",
      "start_s": 2.5,
      "end_s": 4,
      "source_text": "Let's get started.",
      "translation": "Empecemos."
    }
  ],
  "revision": 5
}
```

**SDK Code**

```python
import requests

url = "https://api.elevenlabs.io/v1/dubbing/project/proj_1601kwkyxp0hfzvtmyxwqxx6mcy3/language/lang_1001kwkyxp0je6ktn4knsfrasx5s/transcript/segments"

payload = { "segments": {
        "0199a3f0-1c2d-7abc-8def-0123456789ab": { "translation": "Bienvenido a nuestra última demostración de producto." },
        "0199a3f0-3e4f-7abc-8def-0123456789cd": { "translation": "Empecemos." }
    } }
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript
const url = 'https://api.elevenlabs.io/v1/dubbing/project/proj_1601kwkyxp0hfzvtmyxwqxx6mcy3/language/lang_1001kwkyxp0je6ktn4knsfrasx5s/transcript/segments';
const options = {
  method: 'PATCH',
  headers: {'Content-Type': 'application/json'},
  body: '{"segments":{"0199a3f0-1c2d-7abc-8def-0123456789ab":{"translation":"Bienvenido a nuestra última demostración de producto."},"0199a3f0-3e4f-7abc-8def-0123456789cd":{"translation":"Empecemos."}}}'
};

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/dubbing/project/proj_1601kwkyxp0hfzvtmyxwqxx6mcy3/language/lang_1001kwkyxp0je6ktn4knsfrasx5s/transcript/segments"

	payload := strings.NewReader("{\n  \"segments\": {\n    \"0199a3f0-1c2d-7abc-8def-0123456789ab\": {\n      \"translation\": \"Bienvenido a nuestra última demostración de producto.\"\n    },\n    \"0199a3f0-3e4f-7abc-8def-0123456789cd\": {\n      \"translation\": \"Empecemos.\"\n    }\n  }\n}")

	req, _ := http.NewRequest("PATCH", 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/dubbing/project/proj_1601kwkyxp0hfzvtmyxwqxx6mcy3/language/lang_1001kwkyxp0je6ktn4knsfrasx5s/transcript/segments")

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

request = Net::HTTP::Patch.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"segments\": {\n    \"0199a3f0-1c2d-7abc-8def-0123456789ab\": {\n      \"translation\": \"Bienvenido a nuestra última demostración de producto.\"\n    },\n    \"0199a3f0-3e4f-7abc-8def-0123456789cd\": {\n      \"translation\": \"Empecemos.\"\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.patch("https://api.elevenlabs.io/v1/dubbing/project/proj_1601kwkyxp0hfzvtmyxwqxx6mcy3/language/lang_1001kwkyxp0je6ktn4knsfrasx5s/transcript/segments")
  .header("Content-Type", "application/json")
  .body("{\n  \"segments\": {\n    \"0199a3f0-1c2d-7abc-8def-0123456789ab\": {\n      \"translation\": \"Bienvenido a nuestra última demostración de producto.\"\n    },\n    \"0199a3f0-3e4f-7abc-8def-0123456789cd\": {\n      \"translation\": \"Empecemos.\"\n    }\n  }\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.elevenlabs.io/v1/dubbing/project/proj_1601kwkyxp0hfzvtmyxwqxx6mcy3/language/lang_1001kwkyxp0je6ktn4knsfrasx5s/transcript/segments', [
  'body' => '{
  "segments": {
    "0199a3f0-1c2d-7abc-8def-0123456789ab": {
      "translation": "Bienvenido a nuestra última demostración de producto."
    },
    "0199a3f0-3e4f-7abc-8def-0123456789cd": {
      "translation": "Empecemos."
    }
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.elevenlabs.io/v1/dubbing/project/proj_1601kwkyxp0hfzvtmyxwqxx6mcy3/language/lang_1001kwkyxp0je6ktn4knsfrasx5s/transcript/segments");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"segments\": {\n    \"0199a3f0-1c2d-7abc-8def-0123456789ab\": {\n      \"translation\": \"Bienvenido a nuestra última demostración de producto.\"\n    },\n    \"0199a3f0-3e4f-7abc-8def-0123456789cd\": {\n      \"translation\": \"Empecemos.\"\n    }\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = ["segments": [
    "0199a3f0-1c2d-7abc-8def-0123456789ab": ["translation": "Bienvenido a nuestra última demostración de producto."],
    "0199a3f0-3e4f-7abc-8def-0123456789cd": ["translation": "Empecemos."]
  ]] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.elevenlabs.io/v1/dubbing/project/proj_1601kwkyxp0hfzvtmyxwqxx6mcy3/language/lang_1001kwkyxp0je6ktn4knsfrasx5s/transcript/segments")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
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()
```