> 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/hi/eleven-api/guides/cookbooks/speech-to-text) पूरा कर लिया है।

## परिचय

मल्टीचैनल स्पीच टू टेक्स्ट फीचर आपको ऐसी ऑडियो फ़ाइलों का ट्रांसक्रिप्शन करने देता है जिनमें हर चैनल में अलग स्पीकर होता है। यह खास तौर पर उन रिकॉर्डिंग के लिए उपयोगी है जिनमें स्पीकर अलग-अलग ऑडियो चैनलों पर अलग किए गए हों। इससे स्पीकर डायरीकरण की ज़रूरत के बिना साफ़ ट्रांसक्रिप्शन मिलते हैं।

हर चैनल को अलग से प्रोसेस किया जाता है और उसके चैनल नंबर के आधार पर उसे अपने-आप एक स्पीकर ID दी जाती है (चैनल 0 → `speaker_0`, चैनल 1 → `speaker_1`, आदि)। सिस्टम आपकी इनपुट ऑडियो फ़ाइल से अलग-अलग चैनल निकालता है और उनका समानांतर ट्रांसक्रिप्शन करता है। डिफ़ॉल्ट रूप से API हर चैनल के लिए एक ट्रांसक्रिप्ट लौटाता है; इसके बजाय सभी चैनलों को शुरू होने के समय के अनुसार क्रमबद्ध एक ही सूची में मर्ज किए गए एकल ट्रांसक्रिप्ट के रूप में पाने के लिए `multichannel_output_style=combined` सेट करें, जिसमें हर शब्द को उसके `channel_index` से टैग किया गया हो।

### आम उपयोग के मामले

* **स्टीरियो इंटरव्यू रिकॉर्डिंग** - बाएं चैनल पर इंटरव्यूअर, दाएं चैनल पर इंटरव्यू देने वाला
* **मल्टी-ट्रैक पॉडकास्ट रिकॉर्डिंग** - हर प्रतिभागी अलग ट्रैक पर रिकॉर्ड किया गया
* **कॉल सेंटर रिकॉर्डिंग** - एजेंट और ग्राहक अलग-अलग चैनलों पर
* **कॉन्फ़्रेंस रिकॉर्डिंग** - अलग-अलग प्रतिभागी अलग चैनलों पर
* **अदालती कार्यवाही** - कई पक्ष अलग-अलग चैनलों पर रिकॉर्ड किए गए

## आवश्यकताएं

* [API key](https://elevenlabs.io/app/settings/api-keys) वाला ElevenLabs अकाउंट
* मल्टीचैनल ऑडियो फ़ाइल (WAV, MP3 या अन्य समर्थित फ़ॉर्मैट)
* हर ऑडियो फ़ाइल में अधिकतम 5 चैनल
* हर चैनल में केवल एक स्पीकर होना चाहिए

## यह कैसे काम करता है

#### अपना मल्टीचैनल ऑडियो तैयार करें

पक्का करें कि आपकी ऑडियो फ़ाइल में स्पीकर अलग-अलग चैनलों पर अलग हों। मल्टीचैनल फीचर अधिकतम 5 चैनलों का समर्थन करता है, जिसमें हर चैनल एक खास स्पीकर से मैप होता है:

* चैनल 0 → `speaker_0`
* चैनल 1 → `speaker_1`
* चैनल 2 → `speaker_2`
* चैनल 3 → `speaker_3`
* चैनल 4 → `speaker_4`

#### API पैरामीटर कॉन्फ़िगर करें

स्पीच-टू-टेक्स्ट अनुरोध करते समय, आपको ये सेट करने होंगे:

* `use_multi_channel`: `true`
* `diarize`: `false` (मल्टीचैनल मोड चैनलों के ज़रिए स्पीकर को अलग करता है)

वैकल्पिक रूप से, रिस्पॉन्स का स्वरूप नियंत्रित करने के लिए:

* `multichannel_output_style`: `separate` (डिफ़ॉल्ट) हर चैनल के लिए एक ट्रांसक्रिप्ट लौटाता है। `combined` सभी चैनलों को एक ही ट्रांसक्रिप्ट में मर्ज करता है, जिसके शब्द शुरू होने के समय के अनुसार क्रमबद्ध होते हैं और हर शब्द में `channel_index` होता है — जो मानक सिंगल-चैनल रिस्पॉन्स के स्वरूप से मेल खाता है। `combined` के लिए टाइमस्टैम्प ज़रूरी हैं (`timestamps_granularity` `none` नहीं होना चाहिए) और यह वेबहुक डिलीवरी या एंटिटी डिटेक्शन/रिडैक्शन के साथ समर्थित नहीं है।

`num_speakers` पैरामीटर को मल्टीचैनल मोड के साथ इस्तेमाल नहीं किया जा सकता, क्योंकि स्पीकर की संख्या चैनलों की संख्या से अपने-आप तय होती है। मल्टीचैनल मोड मानता है कि हर चैनल में ठीक एक स्पीकर होगा। अगर ज़्यादा स्पीकर हैं, तो यह चैनल के सभी स्पीकर को एक ही स्पीकर ID देगा।

#### रिस्पॉन्स प्रोसेस करें

डिफ़ॉल्ट रूप से (`multichannel_output_style=separate`), मल्टीचैनल ऑडियो सिंगल-चैनल से अलग रिस्पॉन्स फ़ॉर्मैट लौटाता है:

> **Note**
>
> अगर आप `use_multi_channel: true` सेट करते हैं, लेकिन सिंगल-चैनल (मोनो) ऑडियो फ़ाइल देते हैं, तो आपको
> मल्टीचैनल फ़ॉर्मैट के बजाय मानक सिंगल-चैनल रिस्पॉन्स मिलेगा। मल्टीचैनल रिस्पॉन्स
> फ़ॉर्मैट केवल तब लौटता है जब ऑडियो फ़ाइल में वास्तव में कई चैनल हों।

**`सिंगल चैनल रिस्पॉन्स`**

```python title="सिंगल चैनल रिस्पॉन्स"
{
  "language_code": "en",
  "language_probability": 0.98,
  "text": "Hello world",
  "words": [...]
}
```

**`मल्टीचैनल रिस्पॉन्स`**

```python title="मल्टीचैनल रिस्पॉन्स"
{
  "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": [...]
    }
  ]
}
```

**`संयुक्त रिस्पॉन्स (multichannel_output_style=combined)`**

```python title="संयुक्त रिस्पॉन्स (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` ऐरे नहीं), जिसमें सभी चैनल शुरू होने के समय के अनुसार क्रमबद्ध एक ही सूची में मर्ज होते हैं। हर शब्द में उसके चैनल की पहचान करने के लिए `channel_index` (और `speaker_id`) शामिल होता है।

## इम्प्लीमेंटेशन

### बुनियादी मल्टीचैनल ट्रांसक्रिप्शन

यहां दो स्पीकर वाली स्टीरियो ऑडियो फ़ाइल का ट्रांसक्रिप्शन करने का पूरा उदाहरण है:

**`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 हर शब्द पर `channel_index` और `speaker_id` के साथ, शुरू होने के समय के अनुसार पहले से क्रमबद्ध एक ही `words` सूची लौटाता है:

**`संयुक्त आउटपुट (सुझाया गया)`**

```python title="संयुक्त आउटपुट (सुझाया गया)"
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']}")
```

## मल्टीचैनल के साथ वेबहुक इस्तेमाल करना

मल्टीचैनल ट्रांसक्रिप्शन असिंक्रोनस प्रोसेसिंग के लिए [वेबहुक डिलीवरी](/docs/hi/eleven-api/guides/how-to/speech-to-text/batch/webhooks) का समर्थन करता है:

> **Note**
>
> वेबहुक `separate` (हर चैनल का अलग) फ़ॉर्मैट लौटाते हैं। `multichannel_output_style=combined` अभी
> वेबहुक डिलीवरी के साथ समर्थित नहीं है — सिंक्रोनस अनुरोध इस्तेमाल करें, या हर चैनल का
> वेबहुक पेलोड क्लाइंट-साइड पर मर्ज करें।

```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`
पैरामीटर हटा दें।

#### 5 से ज़्यादा चैनल वाली ऑडियो फ़ाइल

**त्रुटि**: मल्टीचैनल मोड अधिकतम 5 चैनलों का समर्थन करता है, लेकिन ऑडियो फ़ाइल में X चैनल हैं।

**समाधान**: केवल पहले 5 चैनल प्रोसेस करें या चैनल की संख्या घटाने के लिए अपनी ऑडियो को पहले
प्रोसेस करें।

#### टाइमस्टैम्प के बिना संयुक्त आउटपुट इस्तेमाल करना

**त्रुटि**: multichannel_output_style='combined' के लिए टाइमस्टैम्प ज़रूरी हैं; timestamps_granularity
को 'word' या 'character' पर सेट करें।

**समाधान**: संयुक्त आउटपुट शब्दों को समय के अनुसार क्रमबद्ध करता है, इसलिए `timestamps_granularity` को `word`
(डिफ़ॉल्ट) या `character` पर सेट करें।

#### वेबहुक के साथ संयुक्त आउटपुट इस्तेमाल करना

**त्रुटि**: multichannel_output_style='combined' अभी वेबहुक डिलीवरी के साथ समर्थित नहीं है।

**समाधान**: `combined` के साथ सिंक्रोनस अनुरोध इस्तेमाल करें, या वेबहुक इस्तेमाल करते समय डिफ़ॉल्ट `separate` आउटपुट
रखें और क्लाइंट-साइड पर मर्ज करें।

## सर्वोत्तम तरीके

### ऑडियो तैयार करना

> **Tip**
>
> बेहतरीन नतीजों के लिए: - बेहतर परफ़ॉर्मेंस के लिए 16kHz सैंपल रेट इस्तेमाल करें - प्रोसेसिंग से पहले शांत या इस्तेमाल न होने वाले
> चैनल हटा दें - पक्का करें कि हर चैनल में सिर्फ़ एक स्पीकर हो - बेहतरीन क्वालिटी के लिए जहां संभव हो लॉसलेस फ़ॉर्मैट
> (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

#### अगर मेरे ऑडियो में 5 से ज़्यादा चैनल हों तो क्या होगा?

API एक त्रुटि लौटाएगा। आपको API को भेजने के लिए 5 चैनल चुनने होंगे या API को भेजने से पहले
कुछ चैनलों को मिक्स डाउन करना होगा।

#### क्या मैं मल्टीचैनल मोड के साथ मोनो ऑडियो प्रोसेस कर सकता हूं?

हां, लेकिन यह ज़रूरी नहीं है। अगर आप `use_multi_channel=true` के साथ मोनो ऑडियो भेजते हैं, तो आपको
मल्टीचैनल फ़ॉर्मैट के बजाय मानक सिंगल-चैनल रिस्पॉन्स मिलेगा।

#### क्या अलग-अलग हर-चैनल ट्रांसक्रिप्ट की जगह एक संयुक्त ट्रांसक्रिप्ट मिल सकता है?

हां। सभी चैनलों को मर्ज करके शुरू होने के समय के अनुसार क्रमबद्ध एक ट्रांसक्रिप्ट पाने के लिए `multichannel_output_style=combined` सेट करें,
जिसमें हर शब्द को उसके `channel_index` से टैग किया गया हो। यह मानक
सिंगल-चैनल रिस्पॉन्स के स्वरूप से मेल खाता है। इसके लिए टाइमस्टैम्प ज़रूरी हैं और यह वेबहुक
डिलीवरी के साथ उपलब्ध नहीं है।

#### स्पीकर ID कैसे असाइन होती हैं?

स्पीकर ID चैनल नंबर के आधार पर निर्धारित होती हैं: चैनल 0 speaker_0 बनता है, चैनल 1
speaker_1 बनता है, और इसी तरह आगे।

#### क्या चैनलों की भाषाएं अलग हो सकती हैं?

हां, हर चैनल को अलग से प्रोसेस किया जाता है और वह अलग भाषाएं पहचान सकता है। भाषा
पहचान हर चैनल पर होती है। `multichannel_output_style=combined` के साथ, टॉप-लेवल
`language_code` सबसे भरोसेमंद चैनल को दर्शाता है, जबकि हर शब्द में अब भी उसका
`channel_index` होता है।

## अगले चरण

#### [API रेफरेंस](/docs/hi/api-reference/speech-to-text)

स्पीच टू टेक्स्ट का पूरा API रेफरेंस और पैरामीटर।

#### [वेबहुक](/docs/hi/eleven-api/guides/how-to/speech-to-text/batch/webhooks)

वेबहुक के ज़रिए ट्रांसक्रिप्शन नतीजे असिंक्रोनस रूप से पाएं।