Function: buildNativeTtsInvocation()
ts
function buildNativeTtsInvocation(input: {
command?: string;
extraArgs?: string[];
outPath: string;
pitch?: number;
platform: NativeTtsPlatform;
rate?: number;
text: string;
voice?: string;
wordsPerMinute?: number;
}): {
args: string[];
cmd: string;
};Defined in: src/batteries/tts/native/helpers.ts:109
Build the { cmd, args } invocation for one native TTS synthesis call. Pure and side-effect-free.
Parameters
| Parameter | Type | Description |
|---|---|---|
input | { command?: string; extraArgs?: string[]; outPath: string; pitch?: number; platform: NativeTtsPlatform; rate?: number; text: string; voice?: string; wordsPerMinute?: number; } | - |
input.command? | string | Optional executable override (default: say/espeak-ng/powershell.exe). |
input.extraArgs? | string[] | Optional extra args inserted before the platform-specific flags. |
input.outPath | string | The scratch WAV output path the binary writes to. |
input.pitch? | number | Optional espeak-ng pitch (0–99). |
input.platform | NativeTtsPlatform | The target platform. |
input.rate? | number | Optional resolved -10..10 rate for PowerShell (win32 only). |
input.text | string | The text to synthesize. |
input.voice? | string | Optional voice name. |
input.wordsPerMinute? | number | Optional resolved wpm for say/espeak-ng. |
Returns
ts
{
args: string[];
cmd: string;
}The { cmd, args } pair to hand to the executor.
| Name | Type | Defined in |
|---|---|---|
args | string[] | src/batteries/tts/native/helpers.ts:119 |
cmd | string | src/batteries/tts/native/helpers.ts:119 |
Remarks
The caller (the adapter) resolves every policy decision BEFORE calling this:
wordsPerMinuteis the already-resolved wpm forsay/espeak-ng(the adapter computeswordsPerMinute ?? clamp(round(175 * (rate ?? 1)), 80, 500)).rateis the already-resolved-10..10integer for PowerShell'sSpeechSynthesizer.Rate(the adapter computesclamp(round(((rate ?? 1) - 1) * 10), -10, 10)). It is used ONLY on win32 and ignored on darwin/linux — the helper does NOT recompute it.pitchis the espeak-ng-pvalue (0–99); ignored on darwin/win32.
On every platform, command (when supplied) overrides only the executable; the platform's own argument/script shape is still built around it. extraArgs are inserted before the voice/rate/pitch/text flags on darwin/linux; they are IGNORED on win32, where the entire synthesis is expressed as a single -Command PowerShell script (there is no positional-flag slot to forward them into safely).