Skip to content
3 min read · 563 words

Interface: TransformersJsSttAdapterOptions

Defined in: src/batteries/specialists/stt/transformers_js/types.ts:105

Constructor options for the transformers.js STT adapter.

Remarks

model is required — no default, since Whisper-family models are multi-hundred-megabyte downloads and this battery never triggers one silently (the loud-config rule shared with every on-device battery).

Extends

Properties

PropertyTypeDescriptionInherited fromDefined in
chunkLengthS?numberThe length of audio chunks to process, in seconds, forwarded to the pipeline call. Default 30.-src/batteries/specialists/stt/transformers_js/types.ts:120
createPipeline?CreateTransformersJsSttPipelineOverride the pipeline factory. Default: pipeline('automatic-speech-recognition', …) via dynamic import.-src/batteries/specialists/stt/transformers_js/types.ts:114
decodeAudio?DecodeAudioFnOverride the audio-decode step (encoded container bytes → mono PCM). Default: @nhtio/adk/batteries/specialists/_shared!defaultDecodeAudio.-src/batteries/specialists/stt/transformers_js/types.ts:125
device?| "auto" | "gpu" | "cpu" | "wasm" | "webgpu" | "cuda" | "dml" | "coreml" | "webnn" | "webnn-npu" | "webnn-gpu" | "webnn-cpu"Inference device forwarded to pipeline(). Default: transformers.js environment default.-src/batteries/specialists/stt/transformers_js/types.ts:116
dtype?| "auto" | "fp32" | "fp16" | "q8" | "int8" | "uint8" | "q4" | "bnb4" | "q4f16" | "q2" | "q2f16" | "q1" | "q1f16"Quantization/precision dtype forwarded to pipeline().-src/batteries/specialists/stt/transformers_js/types.ts:118
isAvailable?() => booleanOverride the availability probe. Default: true whenever the peer is importable (env-neutral).-src/batteries/specialists/stt/transformers_js/types.ts:135
modelstringThe Whisper (or compatible) ASR model id, e.g. onnx-community/whisper-base. Required.-src/batteries/specialists/stt/transformers_js/types.ts:107
modelSource?TransformersJsSttModelSourceCustom model-source resolver (OPFS / separate source / bundled bytes). When set, model files load through it behind the global-env mutex; otherwise straight from HF (unchanged). See TransformersJsSttModelSource.-src/batteries/specialists/stt/transformers_js/types.ts:131
onCompiling?BatteryLifecycleCallbackEngine/graph/shader compilation after download, before the first token. A COARSE marker: the on-device runtimes (LiteRT Engine.create, transformers.js from_pretrained) expose the boundary — download done, opaque WebGPU/WASM graph build about to run — but NOT a progress stream, so progress is usually absent. Often the slowest part of a cold start; without this it was invisible.BatteryLifecycleHooks.onCompilingsrc/batteries/llm/chat_common/lifecycle.ts:89
onComplete?BatteryLifecycleCallbackAfter the turn's output is parsed + persisted, before ack (fires per turn).BatteryLifecycleHooks.onCompletesrc/batteries/llm/chat_common/lifecycle.ts:95
onError?BatteryLifecycleCallbackA load or generation failure (paired with nack).BatteryLifecycleHooks.onErrorsrc/batteries/llm/chat_common/lifecycle.ts:97
onGenerating?BatteryLifecycleCallbackImmediately before the provider generate call (fires per turn).BatteryLifecycleHooks.onGeneratingsrc/batteries/llm/chat_common/lifecycle.ts:93
onInitProgress?ProgressCallbackCalled with model-load progress reports while weights download/compile.-src/batteries/specialists/stt/transformers_js/types.ts:133
onLifecycle?BatteryLifecycleCallbackFires on EVERY phase transition (the firehose).BatteryLifecycleHooks.onLifecyclesrc/batteries/llm/chat_common/lifecycle.ts:80
onLoading?BatteryLifecycleCallbackWeights/runtime loading — may fire repeatedly with progress as the provider reports it.BatteryLifecycleHooks.onLoadingsrc/batteries/llm/chat_common/lifecycle.ts:82
onReady?BatteryLifecycleCallbackEngine/pipeline resolved and cached, before the first generation.BatteryLifecycleHooks.onReadysrc/batteries/llm/chat_common/lifecycle.ts:91
pipeline?AutomaticSpeechRecognitionPipelineA pre-built pipeline. When provided, the battery uses it directly and skips lazy creation.-src/batteries/specialists/stt/transformers_js/types.ts:109