Skip to content
3 min read · 699 words

Interface: TransformersJsTtsAdapterOptions ​

Defined in: src/batteries/tts/transformers_js/types.ts:106

Constructor options for the transformers.js TTS adapter.

Remarks ​

model is required — no default, since TTS models are multi-hundred-megabyte downloads and this battery never triggers one silently (the loud-config rule shared with every on-device battery). Extends the shared BaseTtsAdapterOptions (voice/rate) — see that base for the normalization semantics.

Extends ​

Properties ​

PropertyTypeDescriptionInherited fromDefined in
createPipeline?CreateTransformersJsTtsPipelineOverride the pipeline factory. Default: pipeline('text-to-speech', …) via dynamic import.-src/batteries/tts/transformers_js/types.ts:116
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/tts/transformers_js/types.ts:118
dtype?| "auto" | "fp32" | "fp16" | "q8" | "int8" | "uint8" | "q4" | "bnb4" | "q4f16" | "q2" | "q2f16" | "q1" | "q1f16"Quantization/precision dtype forwarded to pipeline().-src/batteries/tts/transformers_js/types.ts:120
isAvailable?() => booleanOverride the availability probe. Default: true whenever the peer is importable (env-neutral).-src/batteries/tts/transformers_js/types.ts:137
modelstringThe TTS model id, e.g. Xenova/mms-tts-eng (MMS-VITS) or Xenova/speecht5_tts (SpeechT5, which additionally requires speakerEmbeddings). Required.-src/batteries/tts/transformers_js/types.ts:112
modelSource?TransformersJsTtsModelSourceCustom 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 TransformersJsTtsModelSource.-src/batteries/tts/transformers_js/types.ts:133
numInferenceSteps?numberDefault denoising step count for models that support it, applied when a call omits its own.-src/batteries/tts/transformers_js/types.ts:127
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:95
onComplete?BatteryLifecycleCallbackAfter the turn's output is parsed + persisted, before ack (fires per turn).BatteryLifecycleHooks.onCompletesrc/batteries/llm/chat_common/lifecycle.ts:105
onError?BatteryLifecycleCallbackA load or generation failure (paired with nack).BatteryLifecycleHooks.onErrorsrc/batteries/llm/chat_common/lifecycle.ts:107
onGenerating?BatteryLifecycleCallbackThe generate call is in progress (fires per turn). Fires once immediately before the provider call for most engines; engines that stream per-step generation progress (e.g. a diffusion denoise loop) fire it REPEATEDLY during generation, each carrying a progress in 0..1.BatteryLifecycleHooks.onGeneratingsrc/batteries/llm/chat_common/lifecycle.ts:103
onInitProgress?ProgressCallbackCalled with model-load progress reports while weights download/compile.-src/batteries/tts/transformers_js/types.ts:135
onLifecycle?BatteryLifecycleCallbackFires on EVERY phase transition (the firehose).BatteryLifecycleHooks.onLifecyclesrc/batteries/llm/chat_common/lifecycle.ts:86
onLoading?BatteryLifecycleCallbackWeights/runtime loading — may fire repeatedly with progress as the provider reports it.BatteryLifecycleHooks.onLoadingsrc/batteries/llm/chat_common/lifecycle.ts:88
onReady?BatteryLifecycleCallbackEngine/pipeline resolved and cached, before the first generation.BatteryLifecycleHooks.onReadysrc/batteries/llm/chat_common/lifecycle.ts:97
pipeline?TextToAudioPipelineA pre-built pipeline. When provided, the battery uses it directly and skips lazy creation.-src/batteries/tts/transformers_js/types.ts:114
rate?numberDefault speaking-rate multiplier (1 = engine-normal), applied when a synthesize call omits its own rate. Per-engine mapping (see the module remarks). Unset → engine-normal rate.BaseTtsAdapterOptions.ratesrc/batteries/tts/_shared/index.ts:61
speakerEmbeddings?TransformersJsTtsSpeakerEmbeddingsDefault speaker-embedding reference, applied when a synthesize call omits its own. Required by SpeechT5-family models; ignored by models that do not use speaker embeddings (e.g. MMS-VITS).-src/batteries/tts/transformers_js/types.ts:125
voice?stringDefault voice, applied when a synthesize call omits its own voice. Per-engine semantics (see the module remarks). Unset → the engine/model default voice.BaseTtsAdapterOptions.voicesrc/batteries/tts/_shared/index.ts:56