---
url: >-
  https://adk.nht.io/api/@nhtio/adk/batteries/tts/transformers_js/adapter/classes/TransformersJsTtsAdapter.md
description: TTS adapter for transformers.js's text-to-speech (TextToAudio) pipeline.
---

# Class: TransformersJsTtsAdapter

Defined in: [src/batteries/tts/transformers\_js/adapter.ts:59](https://github.com/NHTIO/ADK/blob/v1.20260718.0/src/src/batteries/tts/transformers_js/adapter.ts#L59)

TTS adapter for transformers.js's text-to-speech (TextToAudio) pipeline.

## Remarks

Reusable: construct once, call [TransformersJsTtsAdapter.synthesize](#synthesize) as many times as needed.
The pipeline is resolved lazily on first use (or via [preload](#preload)) and cached with single-flight
semantics so concurrent calls share one load.

## Constructors

### Constructor

```ts
new TransformersJsTtsAdapter(options: unknown): TransformersJsTtsAdapter;
```

Defined in: [src/batteries/tts/transformers\_js/adapter.ts:76](https://github.com/NHTIO/ADK/blob/v1.20260718.0/src/src/batteries/tts/transformers_js/adapter.ts#L76)

#### Parameters

| Parameter | Type      | Description                             |
| --------- | --------- | --------------------------------------- |
| `options` | `unknown` | Constructor options. Validated eagerly. |

#### Returns

`TransformersJsTtsAdapter`

#### Throws

[@nhtio/adk/batteries!E\_INVALID\_TRANSFORMERS\_JS\_TTS\_OPTIONS](../../exceptions/variables/E_INVALID_TRANSFORMERS_JS_TTS_OPTIONS.md) when invalid.

## Methods

### dispose()

```ts
dispose(): Promise<void>;
```

Defined in: [src/batteries/tts/transformers\_js/adapter.ts:106](https://github.com/NHTIO/ADK/blob/v1.20260718.0/src/src/batteries/tts/transformers_js/adapter.ts#L106)

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. `TextToAudioPipeline` 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()

```ts
isAvailable(): boolean;
```

Defined in: [src/batteries/tts/transformers\_js/adapter.ts:82](https://github.com/NHTIO/ADK/blob/v1.20260718.0/src/src/batteries/tts/transformers_js/adapter.ts#L82)

Instance availability probe (honours an injected `isAvailable`).

#### Returns

`boolean`

***

### preload()

```ts
preload(): Promise<void>;
```

Defined in: [src/batteries/tts/transformers\_js/adapter.ts:87](https://github.com/NHTIO/ADK/blob/v1.20260718.0/src/src/batteries/tts/transformers_js/adapter.ts#L87)

Eagerly loads (and caches) the pipeline so the first `synthesize` call is fast. Idempotent.

#### Returns

`Promise`<`void`>

***

### reset()

```ts
reset(): void;
```

Defined in: [src/batteries/tts/transformers\_js/adapter.ts:92](https://github.com/NHTIO/ADK/blob/v1.20260718.0/src/src/batteries/tts/transformers_js/adapter.ts#L92)

Drops the cached pipeline and in-flight load so the next call reloads.

#### Returns

`void`

***

### synthesize()

```ts
synthesize(text: string, opts?: TransformersJsSynthesizeOptions): Promise<GeneratedMediaOutput>;
```

Defined in: [src/batteries/tts/transformers\_js/adapter.ts:180](https://github.com/NHTIO/ADK/blob/v1.20260718.0/src/src/batteries/tts/transformers_js/adapter.ts#L180)

Synthesizes text into a WAV audio clip.

#### Parameters

| Parameter | Type                                                                                           | Description                                                                      |
| --------- | ---------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| `text`    | `string`                                                                                       | The text to speak. Passed verbatim to the pipeline.                              |
| `opts?`   | [`TransformersJsSynthesizeOptions`](../../types/interfaces/TransformersJsSynthesizeOptions.md) | Per-call options; each field overrides the constructor default of the same name. |

#### Returns

`Promise`<[`GeneratedMediaOutput`](../../../../interfaces/GeneratedMediaOutput.md)>

A [GeneratedMediaOutput](../../../../interfaces/GeneratedMediaOutput.md) descriptor with `kind: 'audio'`, `mimeType: 'audio/wav'`,
and the WAV bytes.

#### Throws

[@nhtio/adk/batteries!E\_TRANSFORMERS\_JS\_TTS\_ENGINE\_ERROR](../../exceptions/variables/E_TRANSFORMERS_JS_TTS_ENGINE_ERROR.md) when the pipeline fails to
load, the synthesis call throws, or the returned audio lacks `toBlob()`.

***

### isAvailable()

```ts
static isAvailable(): boolean;
```

Defined in: [src/batteries/tts/transformers\_js/adapter.ts:68](https://github.com/NHTIO/ADK/blob/v1.20260718.0/src/src/batteries/tts/transformers_js/adapter.ts#L68)

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`
