Skip to content

TranscribeSTT

Amazon Transcribe real-time STT provider using the streaming WebSocket API.

Defined in: src/providers/stt/transcribe/TranscribeSTT.ts:300

Amazon Transcribe real-time STT provider using the streaming WebSocket API.

Remarks

TranscribeSTT extends LiveSTTProvider and connects to Amazon Transcribe’s streaming endpoint over WebSocket. Authentication uses a SigV4-presigned URL (browsers cannot set headers on WebSocket handshakes), generated with the SDK’s built-in WebCrypto signer.

Audio is framed as binary application/vnd.amazon.eventstream AudioEvent messages; Transcribe answers with event-stream TranscriptEvent messages containing result segments:

  • Segments with IsPartial: true update continuously while the user speaks — emitted as interim results.
  • When Transcribe detects the end of a segment (natural pause), it sends the segment once more with IsPartial: false — emitted as a final result with utteranceComplete: true, triggering the next pipeline stage.

Key features:

  • Interim (partial) and final transcription results with word timing
  • Optional partial-results stabilization for lower interim latency
  • Optional speaker partitioning and automatic language identification
  • Custom vocabularies and vocabulary filters
  • Proxy mode via TranscribeSTTConfig.proxyUrl (recommended for production so AWS credentials stay server-side)

Transport: WebSocket (via WebSocketManager)

Browser support: All modern browsers. No peer dependencies — SigV4 presigning and event-stream framing are implemented in the SDK with WebCrypto.

Data flow:

Microphone -> AudioCapture -> sendAudio(chunk) -> AudioEvent frames -> Transcribe WS
                                                                           |
CompositeVoice <- onTranscription(result) <-- TranscriptEvent decode <-----+

Example

import { TranscribeSTT } from 'composite-voice';

const stt = new TranscribeSTT({
  proxyUrl: 'http://localhost:3001/api/proxy/transcribe',
  languageCode: 'en-US',
  enablePartialResultsStabilization: true,
  partialResultsStability: 'high',
});

await stt.initialize();

stt.onTranscription((result) => {
  if (result.isFinal) {
    console.log('Final:', result.text);
  } else {
    console.log('Interim:', result.text);
  }
});

await stt.connect();
// ... send 16 kHz pcm_s16le audio via stt.sendAudio(chunk) ...
await stt.disconnect();

See

  • LiveSTTProvider for the base WebSocket STT class
  • TranscribeSTTConfig for configuration options
  • PollyTTS for the matching AWS text-to-speech provider

Extends

  • LiveSTTProvider

Constructors

Constructor

new TranscribeSTT(config, logger?): TranscribeSTT;

Defined in: src/providers/stt/transcribe/TranscribeSTT.ts:325

Create a new TranscribeSTT provider.

Parameters

ParameterTypeDescription
configTranscribeSTTConfigTranscribe STT configuration. Must include either credentials + region or proxyUrl.
logger?LoggerOptional parent logger; a child will be derived.

Returns

TranscribeSTT

Example

const stt = new TranscribeSTT({
  credentials: { accessKeyId: '...', secretAccessKey: '...' },
  region: 'us-east-1',
  languageCode: 'en-US',
});

Overrides

LiveSTTProvider.constructor

Properties

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

Accessors

isProxyMode

Get Signature

get protected isProxyMode(): boolean;

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

Whether the provider is in proxy mode.

Returns

boolean

true when proxyUrl is set.

Inherited from

LiveSTTProvider.isProxyMode

Methods

assertAuth()

protected assertAuth(): void;

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

Validate that auth is configured (either apiKey or proxyUrl).

Returns

void

Remarks

Call this in onInitialize() for any provider that requires external authentication. Native providers (NativeSTT, NativeTTS) and in-browser providers (WebLLM) should NOT call this method.

Throws

ProviderInitializationError Thrown when neither apiKey nor proxyUrl is set.

Inherited from

LiveSTTProvider.assertAuth

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

LiveSTTProvider.assertReady

connect()

connect(): Promise<void>;

Defined in: src/providers/stt/transcribe/TranscribeSTT.ts:485

Open a WebSocket connection to Amazon Transcribe streaming.

Returns

Promise<void>

Remarks

In direct mode a fresh presigned URL is computed on every call (and on every call to an async credentials factory), so reconnects after the 5-minute presign window require a new connect(). The connection timeout defaults to config.timeout (10 000 ms).

Throws

ProviderConnectionError Thrown when the provider is not initialized or the connection fails.

Overrides

LiveSTTProvider.connect

disconnect()

disconnect(): Promise<void>;

Defined in: src/providers/stt/transcribe/TranscribeSTT.ts:751

Gracefully close the Transcribe WebSocket connection.

Returns

Promise<void>

Remarks

Sends an empty AudioEvent frame to signal end-of-stream (Transcribe finalizes pending segments and closes the session), then disconnects the underlying WebSocketManager.

Throws

Re-throws any unexpected error during disconnection.

Overrides

LiveSTTProvider.disconnect

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

LiveSTTProvider.dispose

emitConnectionLost()

protected emitConnectionLost(message): void;

Defined in: src/providers/base/LiveSTTProvider.ts:175

Emit the standardized “connection lost” error result.

Parameters

ParameterTypeDescription
messagestringHuman-readable description of why the connection died.

Returns

void

Remarks

Every live STT provider MUST call this when its streaming connection dies unexpectedly mid-session (server-initiated close, reconnection give-up, fatal transport error) and will not recover on its own. This error-shaped result is the liveness signal the pipeline’s error handling (transcription.error) and FallbackSTT’s mid-session failover depend on — a provider that only logs and flips an internal flag leaves the session silently dead.

Do NOT call this for closes the application requested via disconnect().

Inherited from

LiveSTTProvider.emitConnectionLost

emitTranscription()

protected emitTranscription(result): void;

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

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.

Inherited from

LiveSTTProvider.emitTranscription

getConfig()

getConfig(): STTProviderConfig;

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

Get a shallow copy of the current STT configuration.

Returns

STTProviderConfig

A new STTProviderConfig object.

Inherited from

LiveSTTProvider.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

LiveSTTProvider.initialize

isFinal()

isFinal(result): boolean;

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

Is this a final segment (but not necessarily utterance-complete)?

Parameters

ParameterTypeDescription
resultTranscriptionResultThe transcription result to check.

Returns

boolean

true when this is a final segment.

Remarks

A final segment represents committed text, but multi-segment providers (e.g., Deepgram) may emit several final segments for a single utterance. Only the last one will have isUtteranceComplete return true.

Inherited from

LiveSTTProvider.isFinal

isInterim()

isInterim(result): boolean;

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

Is this an interim (partial, non-final) result?

Parameters

ParameterTypeDescription
resultTranscriptionResultThe transcription result to check.

Returns

boolean

true when this is an interim result.

Remarks

Interim results update as the user speaks and are replaced by subsequent results. Useful for display but not for triggering downstream processing.

Inherited from

LiveSTTProvider.isInterim

isPreflight()

isPreflight(result): boolean;

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

Is this a preflight/eager end-of-turn signal?

Parameters

ParameterTypeDescription
resultTranscriptionResultThe transcription result to check.

Returns

boolean

true when this is a preflight signal.

Remarks

Used by the eager LLM pipeline for speculative generation. Only providers with preflight support (e.g., Deepgram Flux) need to override this.

Inherited from

LiveSTTProvider.isPreflight

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

LiveSTTProvider.isReady

isUtteranceComplete()

isUtteranceComplete(result): boolean;

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

Is this result a complete utterance ready for LLM processing?

Parameters

ParameterTypeDescription
resultTranscriptionResultThe transcription result to check.

Returns

boolean

true when the utterance is complete.

Remarks

The orchestrator calls this to decide when to send transcribed text to the LLM. Concrete providers override this when they have domain- specific endpointing logic (e.g., DeepgramSTT checks speech_final).

Inherited from

LiveSTTProvider.isUtteranceComplete

isWebSocketConnected()

isWebSocketConnected(): boolean;

Defined in: src/providers/stt/transcribe/TranscribeSTT.ts:806

Check whether the Transcribe WebSocket connection is currently open.

Returns

boolean

true when connected and ready to receive audio.


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

LiveSTTProvider.onConfigUpdate

onDispose()

protected onDispose(): Promise<void>;

Defined in: src/providers/stt/transcribe/TranscribeSTT.ts:367

Disconnect the WebSocket (if connected) and release the manager.

Returns

Promise<void>

Overrides

LiveSTTProvider.onDispose

onInitialize()

protected onInitialize(): Promise<void>;

Defined in: src/providers/stt/transcribe/TranscribeSTT.ts:342

Validate that either credentials + region or proxyUrl is configured.

Returns

Promise<void>

Throws

ProviderInitializationError Thrown when neither credentials nor proxyUrl is set, or when region is missing in direct mode.

Overrides

LiveSTTProvider.onInitialize

onTranscription()

onTranscription(callback): void;

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

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.

Inherited from

LiveSTTProvider.onTranscription

processAudio()

processAudio(chunk): void;

Defined in: src/providers/base/LiveSTTProvider.ts:140

Process a raw audio chunk by sending it over the WebSocket.

Parameters

ParameterTypeDescription
chunkArrayBufferRaw audio data as an ArrayBuffer.

Returns

void

Remarks

Legacy alias for sendAudio. Delegates to sendAudioToSocket.

Inherited from

LiveSTTProvider.processAudio

resolveApiKey()

protected resolveApiKey(): Promise<string>;

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

Resolve the API key, calling the factory if apiKey is a function.

Returns

Promise<string>

The resolved API key string, or 'proxy' in proxy mode.

Inherited from

LiveSTTProvider.resolveApiKey

resolveAuthHeader()

protected resolveAuthHeader(defaultAuthType?): Promise<string | undefined>;

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

Resolve Authorization header value for the configured auth type.

Parameters

ParameterTypeDefault valueDescription
defaultAuthType"token" | "bearer"'token'The default auth type for this provider.

Returns

Promise<string | undefined>

The Authorization header value, or undefined in proxy mode.

Remarks

If apiKey is a factory function it is called to get a fresh token. Returns the header value for REST or server-side WebSocket connections:

  • 'token''Token <apiKey>'
  • 'bearer''Bearer <apiKey>'

Returns undefined in proxy mode.

Inherited from

LiveSTTProvider.resolveAuthHeader

resolveBaseUrl()

protected resolveBaseUrl(defaultUrl?): string | undefined;

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

Resolve the base URL for this provider.

Parameters

ParameterTypeDescription
defaultUrl?stringThe provider’s default API URL. Pass undefined to let the underlying SDK use its own default.

Returns

string | undefined

The resolved URL, or undefined when all sources are unset.

Remarks

Priority: proxyUrl > endpoint > defaultUrl.

For WebSocket providers (this.type === 'websocket'), the proxy URL’s http(s) scheme is automatically converted to ws(s).

When no URL is configured and defaultUrl is undefined, the return value is undefined — this lets SDK-based providers (Anthropic, OpenAI) fall back to their own built-in defaults.

Inherited from

LiveSTTProvider.resolveBaseUrl

resolveWsProtocols()

protected resolveWsProtocols(defaultAuthType?): Promise<string[] | undefined>;

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

Resolve WebSocket subprotocol for authentication.

Parameters

ParameterTypeDefault valueDescription
defaultAuthType"token" | "bearer"'token'The default auth type for this provider.

Returns

Promise<string[] | undefined>

Subprotocol array for new WebSocket(url, protocols), or undefined.

Remarks

If apiKey is a factory function it is called to get a fresh token. Returns the subprotocol array for direct mode based on authType:

  • 'token'['token', apiKey] (Deepgram default)
  • 'bearer'['bearer', apiKey] (OAuth/Bearer tokens)

Returns undefined in proxy mode (no client-side auth needed).

Inherited from

LiveSTTProvider.resolveWsProtocols

sendAudio()

sendAudio(chunk): void;

Defined in: src/providers/base/LiveSTTProvider.ts:128

Send an audio chunk for real-time transcription.

Parameters

ParameterTypeDescription
chunkArrayBufferRaw audio data as an ArrayBuffer.

Returns

void

Remarks

This is the public method required by the ILiveSTTProvider interface. It delegates to sendAudioToSocket, which subclasses implement to forward audio data over the WebSocket connection. For providers that manage their own audio (e.g. NativeSTT), sendAudioToSocket is a no-op.

Inherited from

LiveSTTProvider.sendAudio

sendAudioToSocket()

protected sendAudioToSocket(chunk): void;

Defined in: src/providers/stt/transcribe/TranscribeSTT.ts:720

Send a raw audio chunk to Transcribe as an event-stream AudioEvent.

Parameters

ParameterTypeDescription
chunkArrayBufferRaw audio data captured from the microphone.

Returns

void

Remarks

The chunk is wrapped in a binary application/vnd.amazon.eventstream message with :message-type: 'event', :event-type: 'AudioEvent', and :content-type: 'application/octet-stream' headers. If the connection is not open, the chunk is silently dropped and a warning is logged.

Overrides

LiveSTTProvider.sendAudioToSocket

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

LiveSTTProvider.updateConfig

© 2026 CompositeVoice. All rights reserved.

Font size
Contrast
Motion
Transparency