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

# マルチチャンネルスピーチtoテキスト

> **Note**
>
> **ハウツーガイド** · [スピーチtoテキストの クイックスタート](/docs/ja/eleven-api/guides/cookbooks/speech-to-text)を完了していることを前提としています。

## 概要

マルチチャンネルのスピーチtoテキスト機能では、各チャンネルに異なる話者が含まれるオーディオファイルを書き起こせます。話者が別々のオーディオチャンネルに分離されている録音に特に便利で、話者ダイアライゼーションなしで、よりクリアな文字起こしを作成できます。

各チャンネルは独立して処理され、チャンネル番号に基づいて自動的に話者IDが割り当てられます（チャンネル0→`speaker_0`、チャンネル1→`speaker_1`など）。システムは入力オーディオファイルから個別のチャンネルを抽出し、並列で書き起こします。デフォルトでは、APIはチャンネルごとに1つの文字起こしを返します。代わりにすべてのチャンネルを開始時刻順に並べた1つのリストへ統合し、各単語に`channel_index`を付けた単一の文字起こしを受け取るには、`multichannel_output_style=combined`を設定してください。

### 主なユースケース

* **ステレオインタビュー録音** - 左チャンネルにインタビュアー、右チャンネルにインタビュー対象者
* **マルチトラックのポッドキャスト録音** - 参加者ごとに別トラックへ録音
* **コールセンター録音** - エージェントと顧客を別チャンネルに分離
* **会議録音** - 各参加者を別チャンネルに分離
* **法廷手続き** - 複数の当事者を異なるチャンネルに録音

## 要件

* [APIキー](https://elevenlabs.io/app/settings/api-keys)を持つElevenLabsアカウント
* マルチチャンネルオーディオファイル（WAV、MP3、またはその他の対応形式）
* オーディオファイルあたり最大5チャンネル
* 各チャンネルには1人の話者のみを含めること

## 仕組み

#### マルチチャンネルオーディオを準備する

オーディオファイル内で話者が別々のチャンネルに分離されていることを確認してください。マルチチャンネル機能は最大5チャンネルに対応しており、各チャンネルは特定の話者にマッピングされます。

* チャンネル0→`speaker_0`
* チャンネル1→`speaker_1`
* チャンネル2→`speaker_2`
* チャンネル3→`speaker_3`
* チャンネル4→`speaker_4`

#### APIパラメーターを設定する

スピーチtoテキストリクエストを送信する際は、以下を設定する必要があります。

* `use_multi_channel`: `true`
* `diarize`: `false`（マルチチャンネルモードでは、チャンネルを介して話者を分離します）

必要に応じて、次の設定でレスポンス形式を制御できます。

* `multichannel_output_style`: `separate`（デフォルト）は、チャンネルごとに1つの文字起こしを返します。`combined`はすべてのチャンネルを、開始時刻順に並べた単一の文字起こしへ統合します。各単語には`channel_index`が付与され、標準のシングルチャンネルレスポンス形式と一致します。`combined`にはタイムスタンプが必要です（`timestamps_granularity`を`none`以外にする必要があります）。Webhook配信、エンティティ検出、または編集との併用はサポートされていません。

話者数はチャンネル数によって自動的に決定されるため、マルチチャンネルモードでは`num_speakers`パラメーターを使用できません。マルチチャンネルモードでは、各チャンネルに話者が1人だけいることを前提としています。複数の話者がいる場合、そのチャンネル内のすべての話者に同じ話者IDが割り当てられます。

#### レスポンスを処理する

デフォルト（`multichannel_output_style=separate`）では、マルチチャンネルオーディオはシングルチャンネルとは異なるレスポンス形式を返します。

> **Note**
>
> `use_multi_channel: true`を設定していても、シングルチャンネル（モノラル）のオーディオファイルを指定した場合は、
> マルチチャンネル形式ではなく、標準のシングルチャンネルレスポンスを受け取ります。マルチチャンネルレスポンス
> 形式が返されるのは、オーディオファイルに実際に複数のチャンネルが含まれている場合のみです。

**`Single channel response`**

```python title="Single channel response"
{
  "language_code": "en",
  "language_probability": 0.98,
  "text": "Hello world",
  "words": [...]
}
```

**`Multichannel response`**

```python title="Multichannel response"
{
  "transcripts": [
    {
      "language_code": "en",
      "language_probability": 0.98,
      "text": "Hello from channel one.",
      "channel_index": 0,
      "words": [...]
    },
    {
      "language_code": "en",
      "language_probability": 0.97,
      "text": "Greetings from channel two.",
      "channel_index": 1,
      "words": [...]
    }
  ]
}
```

**`Combined response (multichannel_output_style=combined)`**

```python title="Combined response (multichannel_output_style=combined)"
{
  "language_code": "en",
  "language_probability": 0.98,
  "text": "Hello from channel one. Greetings from channel two.",
  "words": [
    { "text": "Hello", "start": 0.0, "end": 0.5, "type": "word", "speaker_id": "speaker_0", "channel_index": 0 },
    { "text": "Greetings", "start": 0.6, "end": 1.2, "type": "word", "speaker_id": "speaker_1", "channel_index": 1 }
  ]
}
```

`multichannel_output_style=combined`では、レスポンスはシングルチャンネルの文字起こしと同じフラットな形式（トップレベルの`text`と`words`、`transcripts`配列なし）になり、すべてのチャンネルが開始時刻順に並べられた1つのリストへ統合されます。すべての単語には、チャンネルを識別する`channel_index`（および`speaker_id`）が含まれます。

## 実装

### 基本的なマルチチャンネル文字起こし

2人の話者がいるステレオオーディオファイルを書き起こす完全な例を示します。

**`Python`**

```python title="Python"
from elevenlabs import ElevenLabs

elevenlabs = ElevenLabs(api_key="YOUR_API_KEY")

def transcribe_multichannel(audio_file_path):
    with open(audio_file_path, 'rb') as audio_file:
        result = elevenlabs.speech_to_text.convert(
            file=audio_file,
            model_id='scribe_v2',
            use_multi_channel=True,
            diarize=False,
            timestamps_granularity='word'
        )
    return result

# Process the response

result = transcribe_multichannel('stereo_interview.wav')

if hasattr(result, 'transcripts'): # Multichannel response
    for transcript in result.transcripts:
        channel = transcript.channel_index
        text = transcript.text
        print(f"Channel {channel} (speaker_{channel}): {text}")
    else: # Single channel response (fallback)
        print(f"Text: {result.text}")

```

**`JavaScript`**

```javascript title="JavaScript"
import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js";
import fs from "fs";

const elevenlabs = new ElevenLabsClient({
  apiKey: process.env.ELEVENLABS_API_KEY,
});

async function transcribeMultichannel(audioFilePath) {
  try {
    const audioFile = fs.createReadStream(audioFilePath);

    const result = await elevenlabs.speechToText.convert({
      file: audioFile,
      modelId: "scribe_v2",
      useMultiChannel: true,
      diarize: false,
      timestampsGranularity: "word",
    });

    // With useMultiChannel: true the SDK returns one transcript per channel
    result.transcripts.forEach((transcript) => {
      console.log(`Channel ${transcript.channelIndex}: ${transcript.text}`);
    });

    return result;
  } catch (error) {
    console.error("Error transcribing audio:", error);
    throw error;
  }
}
```

**`cURL`**

```bash title="cURL"
curl -X POST "https://api.elevenlabs.io/v1/speech-to-text" \
  -H "xi-api-key: YOUR_API_KEY" \
  -F "file=@stereo_audio_file.wav" \
  -F "model_id=scribe_v2" \
  -F "use_multi_channel=true" \
  -F "diarize=false" \
  -F "timestamps_granularity=word"
```

### 会話形式の文字起こしを作成する

時系列順の会話形式の文字起こしを取得する最も簡単な方法は、`multichannel_output_style=combined`をリクエストすることです。APIは開始時刻順にすでに並べられた単一の`words`リストを返し、各単語には`channel_index`と`speaker_id`が含まれます。

**`Combined output (recommended)`**

```python title="Combined output (recommended)"
with open("stereo_interview.wav", "rb") as audio_file:
    result = elevenlabs.speech_to_text.convert(
        file=audio_file,
        model_id="scribe_v2",
        use_multi_channel=True,
        multichannel_output_style="combined",
        diarize=False,
        timestamps_granularity="word",
    )

for word in result.words:
    if word.type == "word":
        print(f"speaker_{word.channel_index}: {word.text}")
```

デフォルトの`separate`出力を使用している場合は、代わりにクライアント側でチャンネルごとの文字起こしを統合できます。

```python
def create_conversation_transcript(multichannel_result):
    """Create a conversation-style transcript with speaker labels"""
    all_words = []

    if hasattr(multichannel_result, 'transcripts'):
        # Collect all words from all channels
        for transcript in multichannel_result.transcripts:
            for word in transcript.words or []:
                if word.type == 'word':
                    all_words.append({
                        'text': word.text,
                        'start': word.start,
                        'speaker_id': word.speaker_id,
                        'channel': transcript.channel_index
                    })

    # Sort by timestamp
    all_words.sort(key=lambda w: w['start'])

    # Group consecutive words by speaker
    conversation = []
    current_speaker = None
    current_text = []

    for word in all_words:
        if word['speaker_id'] != current_speaker:
            if current_text:
                conversation.append({
                    'speaker': current_speaker,
                    'text': ' '.join(current_text)
                })
            current_speaker = word['speaker_id']
            current_text = [word['text']]
        else:
            current_text.append(word['text'])

    # Add the last segment
    if current_text:
        conversation.append({
            'speaker': current_speaker,
            'text': ' '.join(current_text)
        })

    return conversation

# Format the output
conversation = create_conversation_transcript(result)
for turn in conversation:
    print(f"{turn['speaker']}: {turn['text']}")
```

## マルチチャンネルでWebhookを使用する

マルチチャンネル文字起こしは、非同期処理のための[Webhook配信](/docs/ja/eleven-api/guides/how-to/speech-to-text/batch/webhooks)に対応しています。

> **Note**
>
> Webhookは`separate`（チャンネルごと）の形式を返します。`multichannel_output_style=combined`は
> 現在Webhook配信ではサポートされていません。同期リクエストを使用するか、チャンネルごとの
> Webhookペイロードをクライアント側で統合してください。

```python
from elevenlabs import ElevenLabs

elevenlabs = ElevenLabs(api_key="YOUR_API_KEY")

async def transcribe_multichannel_with_webhook(audio_file_path):
    with open(audio_file_path, 'rb') as audio_file:
        result = await elevenlabs.speech_to_text.convert_async(
            file=audio_file,
            model_id='scribe_v2',
            use_multi_channel=True,
            diarize=False,
            webhook=True  # Enable webhook delivery
        )

    print(f"Transcription started with task ID: {result.task_id}")
    return result.task_id
```

## エラー処理

### よくある検証エラー

#### マルチチャンネルモードでdiarize=trueを設定する

**エラー**：マルチチャンネルモードはダイアライゼーションをサポートしておらず、話者が発話する
チャンネルに基づいて話者を割り当てます。

**解決方法**：マルチチャンネルモードを使用する場合は、常に`diarize=false`を設定してください。

#### num_speakersパラメーターを指定する

**エラー**：use_multi_channelが有効な場合はnum_speakersを指定できません。話者数はチャンネル数によって
自動的に決定されます。**解決方法**：リクエストから`num_speakers`
パラメーターを削除してください。

#### 6チャンネル以上のオーディオファイル

**エラー**：マルチチャンネルモードは最大5チャンネルに対応していますが、オーディオファイルにはXチャンネルが含まれています。

**解決方法**：最初の5チャンネルのみを処理するか、事前にオーディオを処理してチャンネル数を
減らしてください。

#### タイムスタンプなしで統合出力を使用する

**エラー**：multichannel_output_style='combined'にはタイムスタンプが必要です。timestamps_granularityを
'word'または'character'に設定してください。

**解決方法**：統合出力では単語を時刻順に並べるため、`timestamps_granularity`を`word`
（デフォルト）または`character`に設定してください。

#### Webhookで統合出力を使用する

**エラー**：multichannel_output_style='combined'は、Webhook配信ではまだサポートされていません。

**解決方法**：`combined`を使用する同期リクエストを送信するか、Webhook使用時はデフォルトの`separate`出力を
維持し、クライアント側で統合してください。

## ベストプラクティス

### オーディオの準備

> **Tip**
>
> 最適な結果を得るには：- パフォーマンス向上のため16kHzのサンプルレートを使用する - 処理前に無音または未使用の
> チャンネルを削除する - 各チャンネルに話者が1人だけ含まれるようにする - 可能な場合は最高品質のためにロスレス形式
> （WAV）を使用する

### パフォーマンスの最適化

同時実行コストはチャンネル数に比例して増加します。60秒・3チャンネルのファイルの同時実行コストは、シングルチャンネルファイルの3倍です。

次の式を使用して、マルチチャンネルオーディオの処理時間を見積もることができます。

$$
Processing\ Time = (D \cdot 0.3) + 2 + (N \cdot 0.5)
$$

各項目：

* $D$ = ファイルの長さ（秒）
* $N$ = チャンネル数
* $0.3$ = 処理速度係数（リアルタイムの約30%）
* $2$ = 固定オーバーヘッド（秒）
* $0.5$ = チャンネルあたりのオーバーヘッド（秒）

**例**：60秒のステレオファイル（2チャンネル）の場合：

$$
Processing\ Time = (60 \cdot 0.3) + 2 + (2 \cdot 0.5) = 18 + 2 + 1 = 21\ seconds
$$

### メモリに関する考慮事項

大きなマルチチャンネルファイルでは、ストリーミングまたはチャンク分割を検討してください。

**`Python`**

```python title="Python"
def process_large_multichannel_file(file_path, chunk_duration=300):
    """Process large files in chunks (5-minute segments)"""

    from pydub import AudioSegment
    from elevenlabs import ElevenLabs
    import os

    elevenlabs = ElevenLabs(api_key="YOUR_API_KEY")
    audio = AudioSegment.from_file(file_path)
    duration_ms = len(audio)
    chunk_size_ms = chunk_duration * 1000

    all_transcripts = []

    for start_ms in range(0, duration_ms, chunk_size_ms):
        end_ms = min(start_ms + chunk_size_ms, duration_ms)

        # Extract chunk
        chunk = audio[start_ms:end_ms]
        chunk_file = f"temp_chunk_{start_ms}.wav"
        chunk.export(chunk_file, format="wav")

        # Transcribe chunk using SDK
        with open(chunk_file, 'rb') as audio_file:
            result = elevenlabs.speech_to_text.convert(
                file=audio_file,
                model_id='scribe_v2',
                use_multi_channel=True,
                diarize=False,
                timestamps_granularity='word'
            )

        # Adjust timestamps
        if hasattr(result, 'transcripts'):
            for transcript in result.transcripts:
                for word in transcript.words or []:
                    word.start += start_ms / 1000
                    word.end += start_ms / 1000
            all_transcripts.extend(result.transcripts)

        # Clean up
        os.remove(chunk_file)

    return all_transcripts

```

**`JavaScript`**

```javascript title="JavaScript"
import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js";
import { exec } from "child_process";
import fs from "fs";
import path from "path";
import { promisify } from "util";

const execAsync = promisify(exec);
const elevenlabs = new ElevenLabsClient({
  apiKey: process.env.ELEVENLABS_API_KEY,
});

async function processLargeMultichannelFile(filePath, chunkDuration = 300) {
  /**
   * Process large files in chunks (5-minute segments)
   * Requires ffmpeg to be installed
   */

  // Get audio duration using ffprobe
  const { stdout } = await execAsync(
    `ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "${filePath}"`
  );
  const durationSeconds = parseFloat(stdout);

  const allTranscripts = [];

  for (let startSeconds = 0; startSeconds < durationSeconds; startSeconds += chunkDuration) {
    const endSeconds = Math.min(startSeconds + chunkDuration, durationSeconds);
    const chunkFile = path.join(path.dirname(filePath), `temp_chunk_${startSeconds}.wav`);

    // Extract chunk using ffmpeg
    await execAsync(
      `ffmpeg -i "${filePath}" -ss ${startSeconds} -t ${chunkDuration} -c:a pcm_s16le "${chunkFile}" -y`
    );

    try {
      // Transcribe chunk
      const audioFile = fs.createReadStream(chunkFile);
      const result = await elevenlabs.speechToText.convert({
        file: audioFile,
        modelId: "scribe_v2",
        useMultiChannel: true,
        diarize: false,
        timestampsGranularity: "word",
      });

      // Adjust timestamps
      if (result.transcripts) {
        for (const transcript of result.transcripts) {
          for (const word of transcript.words || []) {
            word.start += startSeconds;
            word.end += startSeconds;
          }
        }
        allTranscripts.push(...result.transcripts);
      }
    } finally {
      // Clean up
      fs.unlinkSync(chunkFile);
    }
  }

  return { transcripts: allTranscripts };
}
```

## FAQ

#### オーディオに6チャンネル以上ある場合はどうなりますか？

APIはエラーを返します。APIに送信する5つのチャンネルを選択するか、APIへ送信する前に一部のチャンネルを
ミックスダウンする必要があります。

#### マルチチャンネルモードでモノラルオーディオを処理できますか？

はい、できますが不要です。`use_multi_channel=true`を指定してモノラルオーディオを送信すると、
マルチチャンネル形式ではなく標準のシングルチャンネルレスポンスを受け取ります。

#### チャンネルごとに別々の文字起こしではなく、1つに統合された文字起こしを取得できますか？

はい。`multichannel_output_style=combined`を設定すると、すべてのチャンネルを統合し、開始時刻順に並べた
単一の文字起こしを受け取れます。各単語には`channel_index`が付加されます。これは標準の
シングルチャンネルレスポンス形式と一致します。タイムスタンプが必要で、Webhook
配信では使用できません。

#### 話者IDはどのように割り当てられますか？

話者IDはチャンネル番号に基づいて決定されます。チャンネル0はspeaker_0、チャンネル1は
speaker_1というように割り当てられます。

#### チャンネルごとに異なる言語を使用できますか？

はい。各チャンネルは独立して処理されるため、異なる言語を検出できます。言語検出はチャンネルごとに
行われます。`multichannel_output_style=combined`では、トップレベルの
`language_code`は最も確信度の高いチャンネルを反映しますが、各単語には引き続き
`channel_index`が含まれます。

## 次のステップ

#### [APIリファレンス](/docs/ja/api-reference/speech-to-text)

スピーチtoテキストAPIの完全なリファレンスとパラメーター。

#### [Webhook](/docs/ja/eleven-api/guides/how-to/speech-to-text/batch/webhooks)

Webhook経由で文字起こし結果を非同期に受け取ります。