On this page

Capabilities

What each capability flag means, how a pipeline combines them, and what happens when one is false.

Providers differ in what they can do. session.capabilities tells you which features the session you opened supports. Each flag is a boolean, and it describes this session: its provider or providers, and the options you opened it with.

The flags

FlagMeaningWhen it is false
streamingSttlisten returns partial transcripts while the caller is still talking.listen returns only final transcripts, after each utterance ends.
streamingTtsspeak returns audio chunks while the rest is still being made.speak still works, but the audio arrives as one chunk after the whole text is synthesized.
speechToSpeechOne provider connection hears and answers, as with openai().Speech is recognized and synthesized in separate steps. The API is the same.
wordTimingsResults include words with startMs, endMs and confidence.words is empty.
diarizationTranscripts carry a speaker label.speaker is not set.
interruptionsThe session stops speaking when the caller talks over it, and fires interrupt.Replies play to the end. session.interrupt() still stops speech when you call it.
voicesThe provider has a voice catalog: listVoices works and you can pick a voice.listVoices and the voice option fail with unsupported.

Check flags at runtime

Read the flags after createSession and pick a code path. One code base then works across providers.

TypeScript
import { createSession } from "voiceai-sdk";
import { deepgram } from "voiceai-sdk/deepgram";
import { elevenlabs } from "voiceai-sdk/elevenlabs";

await using session = await createSession({ stt: deepgram(), tts: elevenlabs() });
const caps = session.capabilities;

if (!caps.interruptions) {
  console.warn("Replies will play to the end, even if the caller talks.");
}

for await (const t of session.listen(Bun.file("meeting.pcm").stream())) {
  if (t.type !== "final") continue;
  const who = caps.diarization ? t.speaker : "speaker";
  console.log(`${who}: ${t.text}`);
}

Pipelines

A pipeline takes each flag from the provider that does that half of the work:

FlagComes from
streamingStt, wordTimings, diarizationThe stt provider
streamingTts, voicesThe tts provider
interruptionsBoth. It is true only when streamingStt and streamingTts are both true.
speechToSpeechAlways false in a pipeline

Barge-in needs both directions to stream. The session has to hear the caller while it is still speaking, and stop audio that is already on its way. If either half can't stream, interruptions is false.

So { stt: deepgram(), tts: elevenlabs() } takes diarization from Deepgram and voices from ElevenLabs, whatever the other provider supports.

unsupported errors

The SDK never quietly ignores what you ask for. When a session can't do something, you get a VoiceError with code unsupported at the point where you asked:

  • At createSession, for an option the provider can't honour, such as a sampleRate, encoding or voice it doesn't offer.
  • At the call, for listVoices on a provider without voices, and for session.pause() and session.resume() where the provider can't pause.

pause() and resume() have no flag. If your app runs on more than one provider, call them in a try block.

TypeScript
import { createSession, VoiceError } from "voiceai-sdk";
import { deepgram } from "voiceai-sdk/deepgram";

try {
  // Throws if this provider can't use opus at 48 kHz.
  await using session = await createSession(deepgram(), { encoding: "opus", sampleRate: 48000 });
} catch (err) {
  if (!(err instanceof VoiceError && err.code === "unsupported")) throw err;
  console.error(err.provider, err.message);
}

Per-provider values

This page explains what the flags mean, not which providers set them. For that, see Compare providers. Some values also depend on the language: a provider may label speakers in one language and not in another, so check the flags on the session rather than assuming them.

Was this page helpful?

Esc

Loading…

↑↓ navigate openCtrl J preview