Skip to content

configureSTTFromMetadata

Auto-configures an STT provider's audio format settings from input metadata.

function configureSTTFromMetadata(stt, metadata): void;

Defined in: src/core/pipeline/configureSTTFromMetadata.ts:176

Auto-configures an STT provider’s audio format settings from input metadata.

Parameters

ParameterTypeDescription
sttBaseProviderThe STT provider to auto-configure. Must have a public config property (all SDK STT providers expose this).
metadataAudioMetadataAudio metadata from the input provider’s getMetadata() method.

Returns

void

Remarks

This function bridges the gap between the input provider (which knows what audio format it produces) and the stt provider (which needs to know what format to expect). It identifies the STT provider by class name and fills in any unset audio format fields.

Detection: Uses provider.constructor.name to identify supported providers. This is reliable because the SDK is published as ES modules and class names are never minified.

Rules:

  • Only sets fields that are currently undefined — never overwrites user-specified values.
  • Fallback chains are unwrapped so every member is configured.
  • Providers exposing configureInputFormat receive the metadata verbatim.
  • NativeSTT and unknown providers are no-ops.

Example

import { configureSTTFromMetadata } from 'composite-voice';
import type { AudioMetadata } from 'composite-voice';

// Input provider reports its audio format
const metadata: AudioMetadata = {
  sampleRate: 16000,
  encoding: 'linear16',
  channels: 1,
  bitDepth: 16,
};

// DeepgramSTT with no explicit encoding/sampleRate/channels
const deepgramSTT = new DeepgramSTT({ apiKey: 'dg_...' });
configureSTTFromMetadata(deepgramSTT, metadata);
// deepgramSTT.config.options is now { encoding: 'linear16', sampleRate: 16000, channels: 1 }

// AssemblyAISTT with no explicit sampleRate
const assemblySTT = new AssemblyAISTT({ apiKey: 'aai_...' });
configureSTTFromMetadata(assemblySTT, metadata);
// assemblySTT.config.sampleRate is now 16000

// NativeSTT — no-op (browser manages its own audio)
const nativeSTT = new NativeSTT();
configureSTTFromMetadata(nativeSTT, metadata);
// No changes made

See

© 2026 CompositeVoice. All rights reserved.

Font size
Contrast
Motion
Transparency