VoiceRouter

router/voice-router

Voice Router SDK - Core API / router/voice-router

router/voice-router

Classes

VoiceRouter

VoiceRouter - Main class for provider-agnostic transcription

Provides a unified interface across multiple Speech-to-Text providers (Gladia, AssemblyAI, Deepgram, etc.). Automatically handles provider selection, adapter management, and response normalization.

Examples

import { VoiceRouter, GladiaAdapter } from '@meeting-baas/sdk';

const router = new VoiceRouter({
  providers: {
    gladia: { apiKey: process.env.GLADIA_API_KEY }
  },
  defaultProvider: 'gladia'
});

router.registerAdapter(new GladiaAdapter());

const result = await router.transcribe({
  type: 'url',
  url: 'https://example.com/audio.mp3'
});

console.log(result.data.text);
const router = new VoiceRouter({
  providers: {
    gladia: { apiKey: process.env.GLADIA_API_KEY },
    assemblyai: { apiKey: process.env.ASSEMBLYAI_API_KEY }
  },
  selectionStrategy: 'round-robin'
});

router.registerAdapter(new GladiaAdapter());
router.registerAdapter(new AssemblyAIAdapter());

// Automatically alternates between providers
await router.transcribe(audio1); // Uses Gladia
await router.transcribe(audio2); // Uses AssemblyAI
await router.transcribe(audio3); // Uses Gladia again

Constructors

Constructor

new VoiceRouter(config): VoiceRouter

Parameters
ParameterType
configVoiceRouterConfig
Returns

VoiceRouter

Methods

deleteTranscript()

deleteTranscript(transcriptId, provider): Promise<{ success: boolean; }>

Delete a transcription Not all providers support this operation

Parameters
ParameterType
transcriptIdstring
providerTranscriptionProvider
Returns

Promise<{ success: boolean; }>

getAdapter()

getAdapter(provider): TranscriptionAdapter

Get an adapter by provider name

Parameters
ParameterType
providerTranscriptionProvider
Returns

TranscriptionAdapter

getProviderCapabilities()

getProviderCapabilities(provider): ProviderCapabilities

Get capabilities for a specific provider

Parameters
ParameterType
providerTranscriptionProvider
Returns

ProviderCapabilities

getRawProviderClient()

getRawProviderClient(provider): unknown

Get raw provider client for advanced usage

Parameters
ParameterType
providerTranscriptionProvider
Returns

unknown

getRegisteredProviders()

getRegisteredProviders(): TranscriptionProvider[]

Get all registered providers

Returns

TranscriptionProvider[]

getTranscript()

getTranscript(transcriptId, provider): Promise<UnifiedTranscriptResponse<TranscriptionProvider>>

Get transcription result by ID Provider must be specified since IDs are provider-specific

Parameters
ParameterType
transcriptIdstring
providerTranscriptionProvider
Returns

Promise<UnifiedTranscriptResponse<TranscriptionProvider>>

listTranscripts()

listTranscripts(provider, options?): Promise<{ transcripts: UnifiedTranscriptResponse<TranscriptionProvider>[]; hasMore?: boolean; total?: number; }>

List recent transcriptions with filtering

Supports date/time filtering, status filtering, and pagination. Not all providers support this operation.

Parameters
ParameterType
providerTranscriptionProvider
options?ListTranscriptsOptions
Returns

Promise<{ transcripts: UnifiedTranscriptResponse<TranscriptionProvider>[]; hasMore?: boolean; total?: number; }>

Example
const { transcripts } = await router.listTranscripts('assemblyai', {
  afterDate: '2026-01-01',
  beforeDate: '2026-01-31',
  status: 'completed',
  limit: 50
})
registerAdapter()

registerAdapter(adapter): void

Register an adapter for a provider

Call this method for each provider you want to use. The adapter will be initialized with the configuration provided in the constructor.

Parameters
ParameterTypeDescription
adapterTranscriptionAdapterProvider adapter instance to register
Returns

void

Throws

If no configuration found for the provider

Example
const router = new VoiceRouter({
  providers: {
    gladia: { apiKey: 'YOUR_KEY' }
  }
});

router.registerAdapter(new GladiaAdapter());
selectProvider()

private selectProvider(preferredProvider?): TranscriptionProvider

Select provider based on configured strategy

Parameters
ParameterType
preferredProvider?TranscriptionProvider
Returns

TranscriptionProvider

transcribe()

transcribe(audio, options?): Promise<UnifiedTranscriptResponse<TranscriptionProvider>>

Transcribe audio using a specific provider or the default

Submit audio for transcription. The provider will be selected based on your configuration strategy (explicit, default, or round-robin).

Parameters
ParameterTypeDescription
audioAudioInputAudio input (URL, file buffer, or stream)
options?TranscribeOptions & objectTranscription options (language, diarization, etc.)
Returns

Promise<UnifiedTranscriptResponse<TranscriptionProvider>>

Unified transcription response with normalized format

Throws

If provider not registered or selection fails

Examples
const result = await router.transcribe({
  type: 'url',
  url: 'https://example.com/audio.mp3'
}, {
  language: 'en',
  diarization: true,
  summarization: true
});

if (result.success) {
  console.log('Transcript:', result.data.text);
  console.log('Speakers:', result.data.speakers);
  console.log('Summary:', result.data.summary);
}
const result = await router.transcribe(audio, {
  provider: 'gladia',  // Force use of Gladia
  language: 'en'
});
transcribeStream()
Call Signature

transcribeStream(options, callbacks?): Promise<StreamingSession>

Stream audio for real-time transcription with Gladia

Parameters
ParameterTypeDescription
optionsGladiaStreamingOptions & objectGladia-specific streaming options (type-safe from OpenAPI spec)
callbacks?StreamingCallbacksEvent callbacks for transcription results
Returns

Promise<StreamingSession>

Promise that resolves with a StreamingSession

Example
const session = await router.transcribeStream({
  provider: 'gladia',
  encoding: 'wav/pcm',  // ✅ Only Gladia encodings allowed
  sampleRate: 16000,    // ✅ Only 8000, 16000, 32000, 44100, 48000
  channels: 1
}, {
  onTranscript: (event) => console.log(event.text),
  onError: (error) => console.error(error)
});
Call Signature

transcribeStream(options, callbacks?): Promise<StreamingSession>

Stream audio for real-time transcription with Deepgram

Parameters
ParameterTypeDescription
optionsDeepgramStreamingOptions & objectDeepgram-specific streaming options (type-safe from OpenAPI spec)
callbacks?StreamingCallbacksEvent callbacks for transcription results
Returns

Promise<StreamingSession>

Promise that resolves with a StreamingSession

Example
const session = await router.transcribeStream({
  provider: 'deepgram',
  encoding: 'linear16',  // ✅ Only Deepgram encodings allowed
  sampleRate: 16000,
  language: 'en',
  diarization: true
}, {
  onTranscript: (event) => console.log(event.text)
});
Call Signature

transcribeStream(options, callbacks?): Promise<StreamingSession>

Stream audio for real-time transcription with AssemblyAI

Parameters
ParameterTypeDescription
optionsAssemblyAIStreamingOptions & objectAssemblyAI-specific streaming options (type-safe from OpenAPI spec)
callbacks?StreamingCallbacksEvent callbacks for transcription results
Returns

Promise<StreamingSession>

Promise that resolves with a StreamingSession

Example
const session = await router.transcribeStream({
  provider: 'assemblyai',
  sampleRate: 16000  // ✅ Only supported sample rates
}, {
  onTranscript: (event) => console.log(event.text)
});
Call Signature

transcribeStream(options?, callbacks?): Promise<StreamingSession>

Stream audio for real-time transcription (uses default provider)

Parameters
ParameterTypeDescription
options?StreamingOptionsGeneric streaming options
callbacks?StreamingCallbacksEvent callbacks for transcription results
Returns

Promise<StreamingSession>

Promise that resolves with a StreamingSession

Properties

adapters

private adapters: Map<TranscriptionProvider, TranscriptionAdapter>

config

private config: VoiceRouterConfig

roundRobinIndex

private roundRobinIndex: number = 0

Functions

createVoiceRouter()

createVoiceRouter(config, adapters?): VoiceRouter

Factory function to create a VoiceRouter with auto-registered adapters

Parameters

ParameterType
configVoiceRouterConfig
adapters?TranscriptionAdapter[]

Returns

VoiceRouter

Interfaces

VoiceRouterConfig

Configuration for VoiceRouter

Properties

providers

providers: Partial<Record<TranscriptionProvider, ProviderConfig>>

Provider configurations Key: provider name, Value: provider config

defaultProvider?

optional defaultProvider: TranscriptionProvider

Default provider to use when not specified

selectionStrategy?

optional selectionStrategy: "default" | "explicit" | "round-robin"

Strategy for provider selection when multiple providers are configured

  • 'explicit': Always require provider to be specified (throws error if not)
  • 'default': Use defaultProvider if not specified
  • 'round-robin': Rotate between providers for load balancing
  • 'fastest': Choose provider with lowest current queue (future feature)

On this page