Skip to content

BaseSTTProvider

Abstract base class shared by every STT provider in CompositeVoice.

Defined in: src/providers/base/BaseSTTProvider.ts:62

Abstract base class shared by every STT provider in CompositeVoice.

Remarks

BaseSTTProvider sits between BaseProvider and the two transport- specific bases (LiveSTTProvider and RestSTTProvider). It adds the transcription callback mechanism that all STT providers use to deliver results back to the SDK core:

  1. The SDK (or consumer) registers a listener via onTranscription.
  2. Subclasses call emitTranscription whenever a transcription result is available (interim or final).

Inheritance hierarchy:

BaseProvider
 +-- BaseSTTProvider          <-- you are here
      +-- LiveSTTProvider     (WebSocket real-time STT)
      +-- RestSTTProvider     (REST file-based STT)

You typically do not extend BaseSTTProvider directly. Instead, extend LiveSTTProvider for streaming/WebSocket providers or RestSTTProvider for batch/file-based providers.

Example

import { BaseSTTProvider } from 'composite-voice';
import type { STTProviderConfig, TranscriptionResult } from 'composite-voice';

class CustomSTTProvider extends BaseSTTProvider {
  constructor(config: STTProviderConfig) {
    super('rest', config);
  }

  protected async onInitialize(): Promise<void> { }
  protected async onDispose(): Promise<void> { }

  async transcribe(audio: Blob): Promise<void> {
    const text = await myCustomEngine.recognize(audio);
    this.emitTranscription({ text, isFinal: true, confidence: 1.0 });
  }
}

See

  • LiveSTTProvider for WebSocket-based real-time STT
  • RestSTTProvider for REST/file-based STT
  • BaseProvider for the root provider lifecycle

Extends

Constructors

Constructor

new BaseSTTProvider(
   type, 
   config, 
   logger?): BaseSTTProvider;

Defined in: src/providers/base/BaseSTTProvider.ts:82

Create a new STT provider.

Parameters

ParameterTypeDescription
type"rest" | "websocket"Transport type ('rest' or 'websocket').
configSTTProviderConfigSTT provider configuration.
logger?LoggerOptional parent logger; a child will be derived.

Returns

BaseSTTProvider

Overrides

BaseProviderClass.constructor

Properties

PropertyModifierTypeDefault valueDescriptionOverridesInherited fromDefined in
configpublicSTTProviderConfigundefinedSTT-specific provider configuration.BaseProviderClass.config-src/providers/base/BaseSTTProvider.ts:67
initializedprotectedbooleanfalseTracks whether initialize has completed successfully.-BaseProviderClass.initializedsrc/providers/base/BaseProvider.ts:97
loggerprotectedLoggerundefinedScoped logger instance for this provider.-BaseProviderClass.loggersrc/providers/base/BaseProvider.ts:94
rolesreadonlyreadonly ProviderRole[]undefinedSTT providers cover the 'stt' pipeline role by default.BaseProviderClass.roles-src/providers/base/BaseSTTProvider.ts:64
transcriptionCallback?protected(result) => voidundefinedCallback registered by the SDK or consumer to receive transcription results. Set via onTranscription.--src/providers/base/BaseSTTProvider.ts:73
typereadonlyProviderTypeundefinedCommunication transport this provider uses ('rest' or 'websocket').-BaseProviderClass.typesrc/providers/base/BaseProvider.ts:74

Methods

assertReady()

protected assertReady(): void;

Defined in: src/providers/base/BaseProvider.ts:255

Guard that throws if the provider has not been initialized.

Returns

void

Remarks

Call at the start of any method that requires the provider to be ready.

Throws

Error Thrown with a descriptive message when initialized is false.

Inherited from

BaseProviderClass.assertReady


dispose()

dispose(): Promise<void>;

Defined in: src/providers/base/BaseProvider.ts:154

Clean up resources and dispose of the provider.

Returns

Promise<void>

Remarks

Delegates to the subclass hook onDispose and resets the initialized flag. If the provider is not initialized, the call is a no-op.

Throws

Re-throws any error raised by onDispose.

Inherited from

BaseProviderClass.dispose


emitTranscription()

protected emitTranscription(result): void;

Defined in: src/providers/base/BaseSTTProvider.ts:113

Emit a transcription result to the registered callback.

Parameters

ParameterTypeDescription
resultTranscriptionResultThe transcription result to emit.

Returns

void

Remarks

Subclasses call this method whenever transcribed text is available. If no callback has been registered via onTranscription, the result is logged as a warning and dropped.


getConfig()

getConfig(): STTProviderConfig;

Defined in: src/providers/base/BaseSTTProvider.ts:132

Get a shallow copy of the current STT configuration.

Returns

STTProviderConfig

A new STTProviderConfig object.

Overrides

BaseProviderClass.getConfig


initialize()

initialize(): Promise<void>;

Defined in: src/providers/base/BaseProvider.ts:127

Initialize the provider, making it ready for use.

Returns

Promise<void>

Remarks

Calls the subclass hook onInitialize. If the provider has already been initialized the call is a no-op.

Throws

ProviderInitializationError Thrown when onInitialize rejects. The original error is wrapped with the provider class name for diagnostics.

Inherited from

BaseProviderClass.initialize


isReady()

isReady(): boolean;

Defined in: src/providers/base/BaseProvider.ts:178

Check whether the provider has been initialized and is ready.

Returns

boolean

true when initialize has completed successfully and dispose has not yet been called.

Inherited from

BaseProviderClass.isReady


onConfigUpdate()

protected onConfigUpdate(_config): void;

Defined in: src/providers/base/BaseProvider.ts:242

Hook called after updateConfig merges new values.

Parameters

ParameterTypeDescription
_configPartial<BaseProviderConfig>The partial configuration that was merged.

Returns

void

Remarks

The default implementation is a no-op. Override in subclasses to react to runtime configuration changes (e.g. reconnect with a new API key).

Inherited from

BaseProviderClass.onConfigUpdate


onDispose()

abstract protected onDispose(): Promise<void>;

Defined in: src/providers/base/BaseProvider.ts:229

Provider-specific disposal logic.

Returns

Promise<void>

Remarks

Subclasses must implement this method to release any resources acquired during onInitialize (e.g. close connections, free memory).

Inherited from

BaseProviderClass.onDispose


onInitialize()

abstract protected onInitialize(): Promise<void>;

Defined in: src/providers/base/BaseProvider.ts:217

Provider-specific initialization logic.

Returns

Promise<void>

Remarks

Subclasses must implement this method to perform any setup required before the provider can be used (e.g. validate credentials, open connections, load models).

Inherited from

BaseProviderClass.onInitialize


onTranscription()

onTranscription(callback): void;

Defined in: src/providers/base/BaseSTTProvider.ts:98

Register a callback to receive transcription results.

Parameters

ParameterTypeDescription
callback(result) => voidFunction invoked with each TranscriptionResult.

Returns

void

Remarks

All STT providers — regardless of transport — deliver text through this callback. CompositeVoice registers it during pipeline setup so that transcription results flow into the conversation manager and, ultimately, the LLM provider.


updateConfig()

updateConfig(config): void;

Defined in: src/providers/base/BaseProvider.ts:201

Merge partial configuration updates into the current config.

Parameters

ParameterTypeDescription
configPartial<BaseProviderConfig>A partial configuration object whose keys will overwrite existing values.

Returns

void

Remarks

After merging, the subclass hook onConfigUpdate is called so providers can react to changed values at runtime.

Inherited from

BaseProviderClass.updateConfig

© 2026 CompositeVoice. All rights reserved.

Font size
Contrast
Motion
Transparency