> 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/how-to/speech-to-text/realtime/client-side-streaming)または
> [サーバー側 ストリーミング](/docs/ja/eleven-api/guides/how-to/speech-to-text/realtime/server-side-streaming)ガイドを完了していることを前提としています。

## 概要

> **Warning**
>
> 文字起こし編集は実験的な機能で、確定した文字起こしごとに最低10秒分のオーディオが課金対象となり、基本の文字起こし
> 料金に30％の追加料金がかかります。詳しい料金については、[API料金 ページ](https://elevenlabs.io/pricing?price.section=speech_to_text\&price.sections=speech_to_text,speech_to_text#pricing-table)
> をご覧ください。

リアルタイム文字起こしでは、確定した各文字起こしに自然言語による編集指示を適用できます。たとえば、音声で話された日付を固定形式で表記したり、略語や頭字語を展開したりできます。指示は接続を開く際に一度だけ渡され、確定した各文字起こしの後に、編集後のテキストを含む個別の`edited_transcript`イベントが続きます。

部分的な文字起こしが編集されることはありません。`committed_transcript`イベントも変更されないため、この機能を有効にしても既存のインテグレーションはそのまま動作します。

> **Warning**
>
> 文字起こし編集は`entity_detection`と併用できません。両方を設定した接続は
> `invalid_request`エラーで拒否されます。

## 文字起こし編集を有効にする

接続時に`transcriptEdit`オプション（WebSocket APIの`transcript_edit`クエリパラメーター）で指示を渡します。指示は最大2000文字です。指示の書き方については、[バッチ文字起こし編集ガイド](/docs/ja/eleven-api/guides/how-to/speech-to-text/batch/transcript-editing#writing-instructions)をご覧ください。

すべてのSDKで、編集済みの文字起こしは`RealtimeEvents.EDITED_TRANSCRIPT`イベントを通じて届きます。

### クライアント側

[クライアント側ストリーミングガイド](/docs/ja/eleven-api/guides/how-to/speech-to-text/realtime/client-side-streaming)で説明しているように、サーバーで発行した単回使用トークンとともにブラウザで`@elevenlabs/client`を使用します。

```typescript
import { Scribe, RealtimeEvents } from "@elevenlabs/client";

// Fetch a single-use token from your server first
const response = await fetch("/scribe-token", yourAuthHeaders);
const { token } = await response.json();

const connection = Scribe.connect({
  token,
  modelId: "scribe_v2_realtime",
  transcriptEdit: "Write all dates in ISO 8601 format (YYYY-MM-DD)",
  microphone: {
    echoCancellation: true,
    noiseSuppression: true,
  },
});

connection.on(RealtimeEvents.COMMITTED_TRANSCRIPT, (data) => {
  console.log("Committed:", data.text);
});

connection.on(RealtimeEvents.EDITED_TRANSCRIPT, (data) => {
  console.log("Edited:", data.edited_text);
});
```

### サーバー側

[サーバー側ストリーミングガイド](/docs/ja/eleven-api/guides/how-to/speech-to-text/realtime/server-side-streaming#configure-the-sdk)で説明しているように、サーバーで公式SDKを使用します。このガイドと異なるのはオプションとイベントハンドラーのみです。オーディオの送信と接続の終了は同じ方法で行います。

```python
import asyncio
import os
from dotenv import load_dotenv
from elevenlabs import AudioFormat, ElevenLabs, RealtimeAudioOptions, RealtimeEvents

load_dotenv()

async def main():
    elevenlabs = ElevenLabs(api_key=os.getenv("ELEVENLABS_API_KEY"))

    connection = await elevenlabs.speech_to_text.realtime.connect(RealtimeAudioOptions(
        model_id="scribe_v2_realtime",
        audio_format=AudioFormat.PCM_16000,
        sample_rate=16000,
        transcript_edit="Write all dates in ISO 8601 format (YYYY-MM-DD)",
    ))

    def on_committed_transcript(data):
        print(f"Committed: {data.get('text', '')}")

    def on_edited_transcript(data):
        print(f"Edited: {data.get('edited_text', '')}")

    connection.on(RealtimeEvents.COMMITTED_TRANSCRIPT, on_committed_transcript)
    connection.on(RealtimeEvents.EDITED_TRANSCRIPT, on_edited_transcript)

    # Send audio chunks as shown in the server-side streaming guide, then close.
    await connection.close()

if __name__ == "__main__":
    asyncio.run(main())
```

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

const elevenlabs = new ElevenLabsClient();

const connection = await elevenlabs.speechToText.realtime.connect({
  modelId: "scribe_v2_realtime",
  audioFormat: AudioFormat.PCM_16000,
  sampleRate: 16000,
  transcriptEdit: "Write all dates in ISO 8601 format (YYYY-MM-DD)",
});

connection.on(RealtimeEvents.COMMITTED_TRANSCRIPT, (data) => {
  console.log("Committed:", data.text);
});

connection.on(RealtimeEvents.EDITED_TRANSCRIPT, (data) => {
  console.log("Edited:", data.edited_text);
});

// Send audio chunks as shown in the server-side streaming guide, then close.
```

## 編集済み文字起こしを受け取る

有効にすると、確定した各文字起こしの後に、確定テキストとその編集版を含む`edited_transcript`イベントが続きます。

```json
{
  "message_type": "edited_transcript",
  "text": "our next meeting is on the twelfth of July twenty twenty-six",
  "edited_text": "our next meeting is on 2026-07-12"
}
```

注意が必要な動作：

* 編集は確定したセグメントごとに適用されます。編集は非同期で実行されるため、`edited_transcript`イベントは対応する`committed_transcript`イベントの直後に送信されます。次の部分的な文字起こしの後に届く場合があり、連続するセグメントの編集結果は順序が前後する可能性があります。`text`フィールドを使用して、編集結果と対応する確定済み文字起こしを照合してください。
* セグメントに編集が加えられなかった場合、`edited_text`は`text`と同一です。
* セグメントの編集結果を生成できない場合、そのセグメントの`edited_transcript`イベントは送信されません。`committed_transcript`イベントには影響しません。
* `committed_transcript_with_timestamps`の単語レベルのタイムスタンプは、編集後のテキストではなく、元の確定テキストを示します。

## 次のステップ

#### [バッチ文字起こし編集](/docs/ja/eleven-api/guides/how-to/speech-to-text/batch/transcript-editing)

指示の書き方とバッチレスポンス形式。

#### [イベントリファレンス](/docs/ja/eleven-api/guides/how-to/speech-to-text/realtime/event-reference)

リアルタイムSTT APIのイベントとエラータイプの完全な一覧。