Skip to Content
Vatis TechAPI docs
Real-time transcription

Speakers and channels

Label each final and each word with its speaker, get the text before its speakers, or transcribe a stereo call with each side labelled.

Speakers in a session

With diarize=true:

  • Each final has a speaker (the speaker of most of its words), and each of its words has its own.
  • Each partial has a speaker and its words, even without timestamps=true. Speaker separation follows the audio about a second behind, so the newest words of a partial have "speaker": null until it has decided. It never changes what it decided.
  • When someone else starts talking in the middle of a segment, the words already said keep their speaker: you can show both voices before the final. At a change of speaker, the partial's own speaker may show the previous label for about a second.
  • A final waits up to 1.5 s for speaker separation to pass its last word. In vad mode the pause before the end of a segment usually covers the wait. If it is not done in time, the final goes out with the speakers known so far, and the other words have "speaker": null. To get the text without the wait: The text first, its speakers after.
  • Labels are speaker_0, speaker_1, ... in the order they first speak, kept for the whole session. A new session starts again at speaker_0.
  • num_speakers (1 to 8) helps when you know how many people speak; a session follows at most 8.

Without diarize, a final's speaker is null and a partial has no speaker. Speakers in a file: The transcript object.

A partial, with the newest word not decided yet, and its final with timestamps=true too, where each word has its times, its confidence and its speaker:

{"type": "partial", "segment_id": 1, "text": "bună ziua luați loc", "start": 0.12, "end": 1.92, "speaker": "speaker_0",
 "words": [{"text": "bună", "start": 0.12, "end": 0.4, "speaker": "speaker_0"}, ...,
           {"text": "loc", "start": 1.42, "end": 1.7, "speaker": null}]}
{"type": "final", "segment_id": 1, "text": "Bună ziua, luați loc.", "start": 0.12, "end": 1.7, "speaker": "speaker_0",
 "words": [{"text": "Bună", "start": 0.12, "end": 0.4, "confidence": 0.98, "speaker": "speaker_0"}, ...]}

The text first, its speakers after

With diarize=true, a final waits until speaker separation has passed its last word, about a second behind the audio. Add speaker_updates=true and the final comes as soon as its text is done; its speakers follow in a final.speakers message.

  • The final comes at once. Its text, times and words are complete and never change. Its speaker and each word's are those known so far: null for about the last second of words, as in a partial.
  • Then exactly one final.speakers per final, also when no label changed: always after its final, in the order of the finals, and before session.ended or an error that ends the session (service_restart too). It changes speakers only, never text or times.
  • Its speaker is the segment's, the speaker of most of its words. Its words, only with timestamps=true, are the final's words again, in order, each with its speaker.
  • Find its final by segment_id, and set the speaker of that segment and of each of its words.
  • session.started has "speaker_updates": true in its config (the key is absent without it). Without the parameter nothing changes. Sent without diarize=true, the session is refused: invalid_parameter, param speaker_updates.

A final whose last words were the other person's, then its speakers:

{"type": "final", "segment_id": 3, "text": "Vă mulțumesc pentru timp. Cu plăcere.", "start": 4.1, "end": 6.2, "speaker": "speaker_1",
 "words": [{"text": "Vă", "start": 4.1, "end": 4.3, "confidence": 0.98, "speaker": "speaker_1"}, ...,
           {"text": "plăcere.", "start": 5.7, "end": 6.2, "confidence": 0.95, "speaker": null}]}
{"type": "final.speakers", "segment_id": 3, "speaker": "speaker_1",
 "words": [{"text": "Vă", "start": 4.1, "end": 4.3, "confidence": 0.98, "speaker": "speaker_1"}, ...,
           {"text": "plăcere.", "start": 5.7, "end": 6.2, "confidence": 0.95, "speaker": "speaker_0"}]}

When it helps: after a commit, and in vad mode with a short vad_silence_s, where the text is ready and would wait for its speakers. A final after a commit takes about 0.76 s with speakers and 0.32 s without; with speaker_updates=true the text comes at the faster time and the speakers a moment later. A voice agent that answers as soon as the person stops gains the most.

When it does not: with the default pause of 1.5 s, the pause already covers the wait, so the text comes no sooner. With two channels a final never waits: each channel is its speaker.

Show the text at once, and its speakers when they come:

const finals = new Map(); // a final's text until its speakers come

// in ws.onmessage
if (message.type === "final") {
  // the text at once; who said it comes in final.speakers
  finals.set(message.segment_id, message.text);
  console.log(message.text);
} else if (message.type === "final.speakers") {
  console.log(`${message.speaker}: ${finals.get(message.segment_id)}`);
  finals.delete(message.segment_id);
}

Two-channel calls

A call recorded in stereo, one side on each channel, can be transcribed live with each side labelled: multichannel=true.

  • Audio: two channels, interleaved sample by sample (left, right, left, ...: the order of a stereo WAV), in the declared encoding (pcm_s16le, mulaw or alaw) and sample_rate. The frame limits are of the two-channel frame: 100 ms of 16 kHz PCM is 6,400 bytes, of 8 kHz mu-law or A-law 1,600 bytes, and at most 1 s.
  • Messages: each channel is transcribed on its own, and its messages go out as they come, so the two channels' messages interleave in the order the text is ready. Every partial and final carries "channel": 0 | 1 and "speaker": "channel_0" | "channel_1"; with timestamps each word carries both too. A channel's partial replaces only that channel's previous partial: show one line being spoken per channel.
  • segment_id is unique in the session, one counter for both channels. Ids grow per channel, but the finals of the two channels can arrive out of id order (a long turn on one channel ends after a short one on the other).
  • commit ends the current segment of both channels (a channel with nothing said gives its empty final). end gives both channels' last finals, then one session.ended, whose duration_s is the recording's length, once.
  • Not with diarize: invalid_parameter, param diarize. Each channel already is one speaker; speakers within a channel are not separated.
  • It counts as 2 live sessions of your workspace's limit, and needs both free (Limits and free credit). Its usage counts once, with the recording's length.
  • punctuation, numbers, remove_fillers, commit, vad_silence_s, timestamps and store apply to both channels.
{"type": "partial", "segment_id": 2, "text": "aș vrea să", "start": 1.6, "end": 2.56, "speaker": "channel_1", "channel": 1,
 "words": [{"text": "aș", "start": 1.6, "end": 1.74, "speaker": "channel_1", "channel": 1}, ...]}
{"type": "final", "segment_id": 1, "text": "Bună ziua, cu ce vă pot ajuta?", "start": 0.12, "end": 1.9,
 "speaker": "channel_0", "channel": 0,
 "words": [{"text": "Bună", "start": 0.12, "end": 0.4, "confidence": 0.98, "speaker": "channel_0", "channel": 0}, ...]}

When your phone system delivers each side as its own stream, open one mono session per side and label them yourself instead. That also counts as 2 sessions, and each session has its own segment_id and times.

On this page