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

# 吹き替えを調整して再生成する

> **Note**
>
> **ハウツーガイド** · [ダビングクイックスタート](/docs/ja/eleven-api/guides/cookbooks/dubbing)で説明しているように、ダビングプロジェクトを作成し、
> 少なくとも1つの言語を生成済みであることを前提としています。

> **Warning**
>
> このガイドで使用する文字起こし編集および再生成エンドポイントは、エンタープライズワークスペースでのみ利用できます。
> アクセスについては[sales](https://elevenlabs.io/contact-sales)にお問い合わせください。

吹き替えの精度は、元となる文字起こしの精度に左右されます。このガイドでは、修正できる2つの箇所（元の文字起こしと言語の翻訳）と、内容に問題がなければオーディオを再生成する方法を説明します。

## リビジョンの仕組み

各プロジェクトと各言語には、それぞれ`0`から始まる`revision`カウンターがあります。

* 元の文字起こしを編集すると、プロジェクトの`revision`が増加します。文字起こし自体では増加しません。
* 翻訳を編集すると、その言語の`revision`が増加します。元の文字起こしや他の言語には影響しません。
* 言語には`output_revision`もあります。これは現在のオーディオの生成元となったリビジョンです。`output_revision`が`revision`より古い場合、ダウンロードしたオーディオは最新ではなく、言語のステータスは`stale`になります。

可能であれば、言語を追加する前に元の文字起こしを修正してください。翻訳は元の文字起こしから作成されるため、先に修正しておけば、すべての言語が正しいテキストから始まります。言語が存在する状態で元の文字起こしを編集すると、その言語は`stale`になり、再生成が必要です。

## 元の文字起こしを編集する

元の文字起こしを読み取り、各セグメントの安定した`id`を取得してから、セグメントを編集、追加、または削除します。

```python
import os
from dotenv import load_dotenv
from elevenlabs.client import ElevenLabs

load_dotenv()

elevenlabs = ElevenLabs(api_key=os.getenv("ELEVENLABS_API_KEY"))

# Replace with your project's ID
project_id = "proj_1601kwkyxp0hfzvtmyxwqxx6mcy3"

# Read the source transcript
transcript = elevenlabs.dubbing.project.transcript.get(project_id)
first_segment = transcript.segments[0]

# Correct a segment's text
elevenlabs.dubbing.project.transcript.update_segment(
    project_id,
    segment_id=first_segment.id,
    text="Welcome to our latest product demo.",
)

# Add a segment (reuse an existing speaker_id so it is dubbed with that voice)
added = elevenlabs.dubbing.project.transcript.create_segment(
    project_id,
    text="Thanks for watching.",
    speaker_id=first_segment.speaker_id,
    start_s=40.0,
    end_s=42.0,
)

# Delete the segment we just added
elevenlabs.dubbing.project.transcript.delete_segment(
    project_id,
    segment_id=added.segment.id,
)
```

```typescript
import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js";
import "dotenv/config";

const elevenlabs = new ElevenLabsClient();

// Replace with your project's ID
const projectId = "proj_1601kwkyxp0hfzvtmyxwqxx6mcy3";

// Read the source transcript
const transcript = await elevenlabs.dubbing.project.transcript.get(projectId);
const firstSegment = transcript.segments[0];

// Correct a segment's text
await elevenlabs.dubbing.project.transcript.updateSegment(projectId, firstSegment.id, {
  text: "Welcome to our latest product demo.",
});

// Add a segment (reuse an existing speakerId so it is dubbed with that voice)
const added = await elevenlabs.dubbing.project.transcript.createSegment(projectId, {
  text: "Thanks for watching.",
  speakerId: firstSegment.speakerId,
  startS: 40.0,
  endS: 42.0,
});

// Delete the segment we just added
await elevenlabs.dubbing.project.transcript.deleteSegment(projectId, added.segment.id);
```

タイミングを編集する場合、`end_s`は`start_s`より大きくなければなりません。新しいセグメントには4つのフィールド（`text`、`speaker_id`、`start_s`、`end_s`）すべてが必要です。セグメントの`id`はサーバーによって割り当てられます。

## 翻訳を調整する

言語の文字起こしでは、各元セグメントとその翻訳が対応付けられます。セグメントの`id`は元の文字起こしと一致するため、翻訳を元のテキストと対応させられます。単一セグメントの翻訳を編集して、機械翻訳を上書きします。`null`を渡すと翻訳がクリアされ、そのセグメントは再翻訳対象になります。

```python
project_id = "proj_1601kwkyxp0hfzvtmyxwqxx6mcy3"
language_id = "lang_1001kwkyxp0je6ktn4knsfrasx5s"

# Read the language's translations
target = elevenlabs.dubbing.project.language.transcript.get(project_id, language_id)
first_segment = target.segments[0]

# Refine a single translation
elevenlabs.dubbing.project.language.transcript.update_segment(
    project_id,
    language_id,
    segment_id=first_segment.id,
    translation="Bienvenido a nuestra última demostración de producto.",
)
```

```typescript
const projectId = "proj_1601kwkyxp0hfzvtmyxwqxx6mcy3";
const languageId = "lang_1001kwkyxp0je6ktn4knsfrasx5s";

// Read the language's translations
const target = await elevenlabs.dubbing.project.language.transcript.get(projectId, languageId);
const firstSegment = target.segments[0];

// Refine a single translation
await elevenlabs.dubbing.project.language.transcript.updateSegment(
  projectId,
  languageId,
  firstSegment.id,
  { translation: "Bienvenido a nuestra última demostración de producto." }
);
```

翻訳を編集すると、その言語の`revision`が増加します。言語がすでに完了していた場合は`stale`になり、再生成するまで以前のオーディオが保持されます。

## オーディオを再生成する

元の文字起こしまたは翻訳を編集した後、現在の文字起こしから新しい吹き替えを生成するために言語を再生成します。再生成には通常の生成と同様に料金がかかります。

```python
import time

# Regenerate from the current transcript
elevenlabs.dubbing.project.language.transcript.regenerate(project_id, language_id)

# Poll until the new output is ready
while True:
    language = elevenlabs.dubbing.project.language.get(project_id, language_id)
    if language.status == "completed":
        break
    if language.status == "failed":
        raise RuntimeError("Regeneration failed")
    time.sleep(5)

print("Fresh output at", language.outputs.lossless_audio)
```

```typescript
// Regenerate from the current transcript
await elevenlabs.dubbing.project.language.transcript.regenerate(projectId, languageId);

// Poll until the new output is ready
let language = await elevenlabs.dubbing.project.language.get(projectId, languageId);
while (language.status !== "completed") {
  if (language.status === "failed") throw new Error("Regeneration failed");
  await new Promise((resolve) => setTimeout(resolve, 5000));
  language = await elevenlabs.dubbing.project.language.get(projectId, languageId);
}

console.log("Fresh output at", language.outputs!.losslessAudio!);
```

プロジェクトが`ready`でない場合、または言語がすでに生成中など安定した状態でない場合、再生成は`409 Conflict`を返します。言語が再び`completed`に達すると、`output_revision`は`revision`と一致し、ダウンロードしたオーディオに編集内容が反映されます。

> **Note**
>
> 言語を追加する際に、`cloning_strength`音声設定（0～10、デフォルトは7）で、吹き替え話者が元の音声をどの程度強くクローンするかを制御できます。
> 詳しくは、[言語ターゲットの作成](/docs/ja/api-reference/dubbing/language-targets/create-language-target)のAPI
> リファレンスを参照してください。