Registry of TTS adapters and related utilities.
Classes
Methods
(async, static) buildAuth(cfg) → {Promise.<{authHeaders: Object.<string, string>, authQuery: Object.<string, string>}>}
Build Authorization header (via jwtGet) and optional apiKey query.
| Name | Type | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cfg | Object | Properties
|
- Type:
- Promise.<{authHeaders: Object.<string, string>, authQuery: Object.<string, string>}>
(static) defaultBuildRequest(input, cfg) → {Object}
Default request builder (HeadTTS-like JSON payload).
| Name | Type | Description |
|---|---|---|
input | Object | |
cfg | Object |
- Type:
- Object
(async, static) defaultParseResponse(res, input, _cfg) → {Promise.<*>}
Default response parser: expects JSON with base64 "audioContent" (or raw audio) and optional timings.
| Name | Type | Description |
|---|---|---|
res | Response | |
input | Object | |
_cfg | Object |
Resolves with adapter output (see contracts: TTSAdapterOutput).
- Type:
- Promise.<*>
(async, static) safeFetch(input, initopt) → {Promise.<Response>}
Wrap fetch with AbortSignal support and uniform errors.
| Name | Type | Attributes | Description |
|---|---|---|---|
input | RequestInfo | ||
init | RequestInit | <optional> | Fetch options. May include an |
When aborted via
init.signal.- Type
- TTSAbortError
- Type:
- Promise.<Response>
Type Definitions
TTSAdapter
Minimal TTS adapter interface.
- Object
| Name | Type | Description |
|---|---|---|
synthesize | function |
TTSAdapterInput
TTS adapter input. Plain text only (no SSML). Words array is optional but recommended if you want 1:1 word timings. The adapter should respect AbortSignal for cancellation.
- Object
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
text | string | plain text to synthesize (no SSML) | ||
ssml | string | <optional> | optional SSML; if provided, adapter should prefer it over plain text | |
words | Array.<string> | <optional> | words array (if provided, adapter should return 1:1 timings) | |
voice | string | | <optional> | string or provider-specific voice object | |
rate | number | <optional> | normalized speed, adapter maps to provider scale | |
pitch | number | <optional> | semitones or provider scale | |
volume | number | <optional> | dB or provider scale | |
timeUnit | 'ms' | | <optional> | 'ms' | time unit for words timings if provided |
batchMode | 'sentence' | | <optional> | 'sentence' | how to batch input text |
adapterConfig | any | <optional> | endpoint, headers, keys, etc. | |
signal | AbortSignal | <optional> | optional signal to support cancellation |
TTSAdapterOutput
TTS adapter output. If provider does not support timings — return only audio. If you provide word-level timings use fields: words, wtimes, wduration. If you provide visemes — use fields: visemes, vtimes, vduration.
NOTE: timeUnit defaults to 'ms' unless explicitly set to 's'.
- Object
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
audio | ArrayBuffer | <optional> | raw audio data (e.g., WAV, MP3, OGG) | |
timeUnit | 'ms' | | <optional> | 'ms' | time unit for all timings below |
words | Array.<string> | <optional> | words as returned by provider or echoed from input | |
wtimes | Array.<number> | <optional> | start times of words | |
wduration | Array.<number> | <optional> | durations of words | |
visemes | Array.<string> | <optional> | visemes (e.g., "AI", "E", "U", "O", "CDGKNRSThYZ", "L", "MBP", "FV", "WQ", "rest") | |
vtimes | Array.<number> | <optional> | center times of visemes | |
vduration | Array.<number> | <optional> | durations of visemes |