# Multichannel and stereo call recordings

Last updated: 2026-11-19

**The problem.** A contact center records the agent and the customer on two channels of one stereo file; a phone
platform gives you each leg of the call apart. Mixing them to mono and asking diarization who spoke throws away the one
fact you already had, and two people talking at once become one garbled utterance.

**What the API does.** Gladia's speech-to-text API transcribes each channel on its own, live or from a file: every
utterance carries its `channel` (from `0`), so channel 0 is always the same party, and parties talking over each
other each keep their words.

## At a glance

| | |
|---|---|
| Live API | `channels` |
| Pre-recorded (batch) | A multichannel file: each channel is transcribed ([Transcribe a file](/pre-recorded/transcribe-a-file/)) |
| Live models | `solaria-3`, `trantoria-1` (every live model) |
| Languages | Every language of the model ([supported languages](/languages/supported-languages/)) |
| Channels | `1` or `2` in a live session, samples interleaved ([audio formats](/live/audio-formats/)) |
| Result | `channel` on every utterance; live utterance ids start with it (`01_00000004`) |
| Pre-recorded billing | Every channel counted: a 10 min stereo file is 20 min of `billing_time` |

## Step by step

### 1. Say how many channels you send

```json
{ "encoding": "wav/pcm", "sample_rate": 16000, "bit_depth": 16, "channels": 2, "model": "solaria-3" }
```

Every channel has the same encoding, sample rate and bit depth.

### 2. Interleave the channels

Send one sample of channel 0, then one of channel 1, and so on: `L R L R …` for stereo. A stereo WAV file is already
laid out that way; send its samples as they are, without the header.

### 3. Read who spoke from `channel`

The programs below turn a mono recording into a two-party call, the first half said by the customer on channel 0
and the second half by the agent on channel 1, stream it and print each utterance with its party. Put your API key
in the `GLADIA_API_KEY` environment variable, then run `python stereo_call.py call.wav`.

**Python SDK**

```python title="stereo_call.py"
# pip install -U "gladiaio-sdk>=2.2"
import os
import sys
import threading
import wave
from array import array

from gladiaio_sdk import GladiaClient

API_URL = os.environ.get("GLADIA_API_URL", "https://eu1.api.gladia.io")
API_KEY = os.environ["GLADIA_API_KEY"]
PARTIES = {0: "Customer", 1: "Agent"}  # who is on each channel

with wave.open(sys.argv[1]) as wav:  # a 16-bit PCM WAV file, mono
    rate, frames = wav.getframerate(), wav.readframes(wav.getnframes())
samples = array("h", frames)
half = len(samples) // 2
# Channel 0 says the first half then is silent, channel 1 is silent then says the second half.
stereo = array("h", bytes(4 * len(samples)))  # interleaved: channel 0, channel 1, channel 0…
stereo[0 : 2 * half : 2] = samples[:half]
stereo[2 * half + 1 :: 2] = samples[half:]
stereo = stereo.tobytes()

config = {"encoding": "wav/pcm", "sample_rate": rate, "bit_depth": 16, "channels": 2, "model": "solaria-3"}
client = GladiaClient(api_key=API_KEY, api_url=API_URL)
session = client.live_v2().start_session(config)
ended, errors = threading.Event(), []

@session.on("message")
def on_message(message):
    if message.type == "transcript" and message.data.is_final:
        utterance = message.data.utterance
        print(f"{PARTIES[utterance.channel]}: {utterance.text}")

session.on("error", errors.append)
session.once("ended", lambda _: ended.set())

# Stream once the socket is open: a stop sent while it opens can pass the audio queued until then.
connected = threading.Event()
session.once("connected", lambda _: connected.set())
session.once("ended", lambda _: connected.set())  # a session that never connects ends
session.on("error", lambda _: connected.set())
if session.status == "connected":  # it opened before the listener above
    connected.set()
if not connected.wait(timeout=30) or errors or ended.is_set():
    sys.exit(1)  # no open session to stream to

step = rate * 2 * 2 // 10  # 100 ms of 2 channels of 16-bit audio
for start in range(0, len(stereo), step):
    session.send_audio(stereo[start : start + step])  # live audio: send each chunk as it is captured
session.stop_recording()

ended.wait(timeout=60)
sys.exit(1 if errors or not ended.is_set() else 0)
```

**JavaScript SDK**

```js title="stereo_call.mjs"
// npm install @gladiaio/sdk
import { readFileSync } from "node:fs";
import { GladiaClient } from "@gladiaio/sdk";

const PARTIES = { 0: "Customer", 1: "Agent" }; // who is on each channel
const { sampleRate, pcm } = readWav(process.argv[2]); // a 16-bit PCM WAV file, mono

const samples = new Int16Array(pcm.buffer, pcm.byteOffset, pcm.length / 2);
const half = Math.floor(samples.length / 2);
// Channel 0 says the first half then is silent, channel 1 is silent then says the second half.
const stereo = new Int16Array(samples.length * 2); // interleaved: channel 0, channel 1, channel 0…
for (let i = 0; i < samples.length; i += 1) stereo[2 * i + (i < half ? 0 : 1)] = samples[i];
const bytes = Buffer.from(stereo.buffer);

const client = new GladiaClient({
  apiKey: process.env.GLADIA_API_KEY,
  apiUrl: process.env.GLADIA_API_URL ?? "https://eu1.api.gladia.io",
});
const session = client.liveV2().startSession({
  encoding: "wav/pcm",
  sample_rate: sampleRate,
  bit_depth: 16,
  channels: 2,
  model: "solaria-3",
});

session.on("message", (message) => {
  if (message.type === "transcript" && message.data.is_final) {
    const { channel, text } = message.data.utterance;
    console.log(`${PARTIES[channel]}: ${text}`);
  }
});
session.on("error", (error) => {
  console.error(error);
  process.exitCode = 1;
});
session.once("ended", () => process.exit());

const step = (sampleRate * 2 * 2) / 10; // 100 ms of 2 channels of 16-bit audio
for (let start = 0; start < bytes.length; start += step) {
  session.sendAudio(bytes.subarray(start, start + step)); // live audio: send each chunk as it is captured
}
session.stopRecording();

function readWav(path) {
  const file = readFileSync(path);
  let fmt, pcm;
  for (let pos = 12; pos < file.length; ) {
    const id = file.toString("ascii", pos, pos + 4);
    const size = file.readUInt32LE(pos + 4);
    if (id === "fmt ") fmt = { sampleRate: file.readUInt32LE(pos + 12) };
    if (id === "data") pcm = file.subarray(pos + 8, pos + 8 + size);
    pos += 8 + size + (size % 2);
  }
  return { ...fmt, pcm };
}
```

**HTTP**

Create the session, then stream its audio to the returned `url` ([Live WebSocket](/api-reference/v2/live/websocket/)):

```bash
curl -X POST https://eu1.api.gladia.io/v2/live \
  -H "x-gladia-key: $GLADIA_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "encoding": "wav/pcm",
    "sample_rate": 16000,
    "bit_depth": 16,
    "channels": 2,
    "model": "solaria-3"
  }'
```

### A recorded call

Upload the stereo file as it is and start a pre-recorded job ([Transcribe a file](/pre-recorded/transcribe-a-file/)):
each channel is transcribed, and each utterance of `result.transcription.utterances` carries its `channel`.

## Limits and gotchas

- **Two channels** in a live session: a session asking for more is refused when it starts. More parties than that
  (a meeting with a track per participant): one session per pair of tracks, or mix the extra tracks down.
- **Interleave samples, not chunks.** `L R L R`, sample by sample (byte by byte for 8-bit μ-law and A-law). Sending
  100 ms of channel 0 then 100 ms of channel 1 is read as noise on both.
- **Silence is fine.** A channel nobody speaks on gives no utterance. Send its silence anyway: the channels must
  stay in step.
- **One party per channel.** A channel with several speakers on it (a conference phone) needs
  [speaker diarization](/features/speaker-diarization/) as well.
- **A pre-recorded file is billed per channel**: `billing_time` counts each channel's audio
  ([how long it took](/pre-recorded/transcribe-a-file/#how-long-it-took)). Mix to mono first when you do not need to
  know who spoke.

## Related pages

- [Transcribing phone calls (8 kHz, μ-law, Twilio, SIP)](/live/telephony/)
- [Speaker diarization](/features/speaker-diarization/)
- [Live audio formats and sample rates](/live/audio-formats/)
