Class: TransformersJsSttAdapter
Defined in: src/batteries/specialists/stt/transformers_js/adapter.ts:76
STT adapter for transformers.js's automatic-speech-recognition (Whisper-family) pipeline.
Remarks
Reusable: construct once, call TransformersJsSttAdapter.transcribe as many times as needed. The pipeline is resolved lazily on first use (or via preload) and cached with single-flight semantics so concurrent calls share one load.
Constructors
Constructor
new TransformersJsSttAdapter(options: unknown): TransformersJsSttAdapter;Defined in: src/batteries/specialists/stt/transformers_js/adapter.ts:93
Parameters
| Parameter | Type | Description |
|---|---|---|
options | unknown | Constructor options. Validated eagerly. |
Returns
TransformersJsSttAdapter
Throws
@nhtio/adk/batteries!E_INVALID_TRANSFORMERS_JS_STT_OPTIONS when invalid.
Methods
dispose()
dispose(): Promise<void>;Defined in: src/batteries/specialists/stt/transformers_js/adapter.ts:123
Release the loaded model's ONNX sessions + GPU/wasm buffers, then drop the cached pipeline.
Returns
Promise<void>
Remarks
reset() only nulls the JS reference; the native ONNX Runtime sessions and WebGPU/wasm device memory stay alive until GC. AutomaticSpeechRecognitionPipeline extends Pipeline, which exposes dispose() — this awaits it so the memory is reclaimed between loads, swallows a disposal error (teardown must not throw), and finishes with reset(). Idempotent.
isAvailable()
isAvailable(): boolean;Defined in: src/batteries/specialists/stt/transformers_js/adapter.ts:99
Instance availability probe (honours an injected isAvailable).
Returns
boolean
preload()
preload(): Promise<void>;Defined in: src/batteries/specialists/stt/transformers_js/adapter.ts:104
Eagerly loads (and caches) the pipeline so the first transcribe call is fast. Idempotent.
Returns
Promise<void>
reset()
reset(): void;Defined in: src/batteries/specialists/stt/transformers_js/adapter.ts:109
Drops the cached pipeline and in-flight load so the next call reloads.
Returns
void
transcribe()
transcribe(input: SpecialistAudioInput, opts?: TranscribeOptions): Promise<TranscribeResult>;Defined in: src/batteries/specialists/stt/transformers_js/adapter.ts:222
Transcribes an audio clip.
Parameters
| Parameter | Type | Description |
|---|---|---|
input | SpecialistAudioInput | The audio input, in any @nhtio/adk/batteries/specialists/_shared!SpecialistAudioInput form (pre-decoded PCM or an encoded container). |
opts? | TranscribeOptions | Per-call transcription options (language / translate / timestamps). |
Returns
Promise<TranscribeResult>
The recognized text, plus per-segment timing when opts.timestamps was set.
Throws
@nhtio/adk/batteries!E_TRANSFORMERS_JS_STT_ENGINE_ERROR when the pipeline fails to load or the transcription call fails.
isAvailable()
static isAvailable(): boolean;Defined in: src/batteries/specialists/stt/transformers_js/adapter.ts:85
Whether this battery is available. transformers.js is environment-neutral (Node + browser), so this is true whenever the runtime can import the peer — there is no WebGPU requirement.
Returns
boolean