computeWordTimestamps() function

Estimates word-level timestamps by mapping words to acoustic energy regions (pauses/silences) in the synthesized waveform, falling back to character-proportional spacing within each phrase.

Signature:

export declare function computeWordTimestamps(text: string, samples: Float32Array, sampleRateHz: number, startOffsetSec?: number): WordTimestamp[];

Parameters

Parameter Type Description
text string The input text corresponding to the synthesized audio samples.
samples Float32Array Mono PCM audio samples in the range [-1.0, 1.0].
sampleRateHz number Sample rate of the audio samples in Hz.
startOffsetSec number Optional time offset in seconds to add to all computed timestamps (defaults to 0).

Returns:

WordTimestamp[]