Class: NativeTtsAdapter
Defined in: src/batteries/tts/native/adapter.ts:65
TTS adapter that shells out to the OS's own speech binary. Reusable: construct once, call NativeTtsAdapter.synthesize as many times as needed.
Remarks
A zero-config new NativeTtsAdapter() is valid — it auto-detects the platform from process.platform at synthesize time and resolves the default executor / fs / scratch-path seams lazily.
Constructors
Constructor
new NativeTtsAdapter(options?: unknown): NativeTtsAdapter;Defined in: src/batteries/tts/native/adapter.ts:86
Parameters
| Parameter | Type | Description |
|---|---|---|
options | unknown | Constructor options. All optional; validated eagerly against @nhtio/adk/batteries/tts/native!nativeTtsOptionsSchema. Pass undefined for zero-config. |
Returns
NativeTtsAdapter
Throws
@nhtio/adk/batteries/tts/native!E_INVALID_NATIVE_TTS_OPTIONS when invalid.
Methods
isAvailable()
isAvailable(): boolean;Defined in: src/batteries/tts/native/adapter.ts:91
Instance availability probe (honours an injected isAvailable).
Returns
boolean
preload()
preload(): Promise<void>;Defined in: src/batteries/tts/native/adapter.ts:96
No-op. The native engine has nothing to preload — the binary is invoked fresh per call.
Returns
Promise<void>
reset()
reset(): void;Defined in: src/batteries/tts/native/adapter.ts:101
No-op. The native engine holds no state between calls to reset.
Returns
void
synthesize()
synthesize(text: string, opts?: NativeSynthesizeOptions): Promise<GeneratedMediaOutput>;Defined in: src/batteries/tts/native/adapter.ts:204
Synthesizes text into a WAV audio clip.
Parameters
| Parameter | Type | Description |
|---|---|---|
text | string | The text to speak. Passed verbatim as the final positional arg / PowerShell literal. |
opts? | NativeSynthesizeOptions | Per-call options; each field overrides the constructor default of the same name. |
Returns
Promise<GeneratedMediaOutput>
A GeneratedMediaOutput descriptor with kind: 'audio', mimeType: 'audio/wav', the WAV bytes, and filename: 'speech.wav'.
Remarks
Resolves the platform (constructor platform or process.platform), the effective voice/rate/pitch (per-call overrides ctor), the words-per-minute (for say/espeak-ng) and the -10..10 PowerShell rate (for win32), then shells out via the executor, reads the scratch WAV back, hard-validates the RIFF/WAVE magic, and unlinks the scratch file in a finally.
Throws
@nhtio/adk/batteries/tts/native!E_NATIVE_TTS_UNSUPPORTED_PLATFORM when the resolved platform is not darwin/linux/win32.
Throws
@nhtio/adk/batteries/tts/native!E_NATIVE_TTS_TIMEOUT when the binary is aborted for exceeding timeoutMs (default 60_000 ms).
Throws
@nhtio/adk/batteries/tts/native!E_NATIVE_TTS_ENGINE_ERROR when the binary fails, produces no output, or yields bytes that are not a RIFF/WAVE file.
isAvailable()
static isAvailable(): boolean;Defined in: src/batteries/tts/native/adapter.ts:73
Whether this battery is available. true whenever a Node process is present on a supported NativeTtsPlatform — the engine itself is the platform's own binary, so there is no peer dependency to probe.
Returns
boolean