@nhtio/adk/batteries/tts/native/adapter
OS-native TTS (text-to-speech) adapter battery — shells out to the platform's own speech binary.
Remarks
Node-only. This adapter synthesizes by shelling out to the operating system's own speech binary — macOS say, Linux espeak-ng, or Windows PowerShell System.Speech — and reading back the WAV file it writes. It is model-less: it extends the shared BaseTtsAdapterOptions (voice/rate) but adds NO model field. Every node:* import is a LAZY dynamic import inside a method, so constructing and validating the adapter never touches node builtins and unit tests stay hermetic (zero child_process, zero fs, zero real files).
The shell-out and filesystem access are fully injectable: NativeTtsAdapterOptions.executor (default: a lazy node:child_process execFile wrapper with an AbortController enforcing the timeout), NativeTtsAdapterOptions.fs (default: node:fs/promises), plus NativeTtsAdapterOptions.tmpdir / NativeTtsAdapterOptions.randomName seams for the scratch output path. The flow mirrors the media domain's soffice engine — build args, exec, read the output file, finally clean up — but this engine controls its own output path directly (it does NOT depend on the media domain's ScratchWorkspace).
Result classification is from the executor's FLAGS, never inferred from exit code or stderr (a timeout, a signal kill, and a non-zero CLI exit are indistinguishable from those signals alone): result.timedOut → E_NATIVE_TTS_TIMEOUT (504); else result.failed → E_NATIVE_TTS_ENGINE_ERROR (502). The read-back WAV is hard-validated against the RIFF/WAVE magic — a payload missing that magic throws E_NATIVE_TTS_ENGINE_ERROR.
Classes
| Class | Description |
|---|---|
| NativeTtsAdapter | TTS adapter that shells out to the OS's own speech binary. Reusable: construct once, call NativeTtsAdapter.synthesize as many times as needed. |