@hackbuild/speak 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,129 @@
1
+ /**
2
+ * The speaker: takes a reply as it streams, cuts it into segments, runs
3
+ * them through the first engine that works, plays PCM gapless on one
4
+ * player, and reports progress as offsets in the caller's text when the
5
+ * voice reaches them. Segment N+1 is synthesized while N plays. A
6
+ * watchdog moves to the next engine when one goes quiet. A bounded cache
7
+ * of recent clips makes a replay instant.
8
+ */
9
+ import { GaplessPlayer, type AnalyserLike, type AudioContextLike, type PlayerOptions } from "./player.js";
10
+ import { type CutterOptions, type Segment, type SpeakableOptions } from "./text.js";
11
+ import { type RenderedSpeech } from "./render.js";
12
+ import type { Engine, EngineStatus, VoiceConfig } from "./types.js";
13
+ export interface Progress {
14
+ utterance: number;
15
+ /** Offset in the utterance's input text. */
16
+ offset: number;
17
+ kind: "segment" | "word" | "end";
18
+ /** Word times guessed from text length, not reported by the engine. */
19
+ estimated: boolean;
20
+ }
21
+ /** A word or phoneme placed on the audio clock, for lip sync. */
22
+ export interface TimedEvent {
23
+ utterance: number;
24
+ kind: "word" | "phoneme";
25
+ start: number;
26
+ end: number;
27
+ /** AudioContext times; for a native engine the boundary time with no end known (t1 = t0). */
28
+ t0: number;
29
+ t1: number;
30
+ phoneme?: string;
31
+ estimated: boolean;
32
+ }
33
+ export interface Timers {
34
+ setTimeout(fn: () => void, ms: number): unknown;
35
+ clearTimeout(h: unknown): void;
36
+ }
37
+ export interface SpeakerOptions {
38
+ ctx: AudioContextLike;
39
+ /** Tried in order; a failed engine is skipped until resetEngines(). */
40
+ engines: Engine[];
41
+ voice?: VoiceConfig;
42
+ /** Per voice settings by engine id, merged over `voice`. */
43
+ voices?: Record<string, VoiceConfig>;
44
+ /** No audio from an engine for this long moves to the next engine. Default 45000 ms. */
45
+ watchdogMs?: number;
46
+ cutter?: CutterOptions;
47
+ speakable?: SpeakableOptions;
48
+ player?: PlayerOptions;
49
+ /** Cache size in samples. Default 3 minutes at 24 kHz. 0 turns it off. */
50
+ cacheSamples?: number;
51
+ timers?: Timers;
52
+ /** Call tick() every this many ms. Default 25; 0 means the caller calls tick() (per frame or in tests). */
53
+ tickMs?: number;
54
+ onProgress?(p: Progress): void;
55
+ onTimed?(t: TimedEvent): void;
56
+ /** A segment starts on an engine; `cached` is true when its audio is a replay from the PCM cache. */
57
+ onSegment?(s: Segment & {
58
+ utterance: number;
59
+ engine: string;
60
+ cached: boolean;
61
+ }): void;
62
+ onSpeaking?(speaking: boolean): void;
63
+ onStatus?(s: EngineStatus): void;
64
+ }
65
+ export declare class Speaker {
66
+ readonly player: GaplessPlayer;
67
+ private readonly o;
68
+ private readonly timers;
69
+ private readonly cutter;
70
+ private readonly failed;
71
+ private readonly loaded;
72
+ private queue;
73
+ private cues;
74
+ private utt;
75
+ private uttText;
76
+ private uttFinal;
77
+ private abort;
78
+ private pumping;
79
+ private nativeBusy;
80
+ private speakingNow;
81
+ private waiters;
82
+ private nativeLevelUntil;
83
+ private interval;
84
+ private readonly cache;
85
+ private cacheN;
86
+ private current;
87
+ constructor(o: SpeakerOptions);
88
+ /** The single analyser every PCM engine plays through. */
89
+ get analyser(): AnalyserLike;
90
+ get speaking(): boolean;
91
+ /** The engine that spoke last. */
92
+ get engine(): string | null;
93
+ get utterance(): number;
94
+ /** Feed the visible reply so far. After `final`, the next feed starts a new utterance. */
95
+ feed(textSoFar: string, final?: boolean): number;
96
+ /** Speak a whole text; resolves when its audio has played or it was stopped. */
97
+ say(text: string): Promise<void>;
98
+ /** Resolves when nothing is queued, synthesizing or playing. */
99
+ done(): Promise<void>;
100
+ stop(): void;
101
+ /**
102
+ * Render a whole text offline on the speaker's engine chain, with its
103
+ * voice settings, for "save wav". Engines marked failed are skipped;
104
+ * native engines are skipped since they give no samples.
105
+ */
106
+ render(text: string, signal?: AbortSignal): Promise<RenderedSpeech>;
107
+ /** Clear failure marks so every engine is tried again. */
108
+ resetEngines(): void;
109
+ /** Output level for lip sync: analyser RMS for PCM engines, a boundary pulse for a native one (estimated). */
110
+ level(): number;
111
+ /** Fire cues whose time has come and settle the speaking state. Runs on a timer unless tickMs is 0. */
112
+ tick(): void;
113
+ dispose(): void;
114
+ private busy;
115
+ private flushWaiters;
116
+ private setSpeaking;
117
+ private startTicker;
118
+ private cfg;
119
+ private ensure;
120
+ private fail;
121
+ private pump;
122
+ private progress;
123
+ private chunksOf;
124
+ private runPcm;
125
+ private placeTimed;
126
+ private cue;
127
+ private runNative;
128
+ }
129
+ export declare function createSpeaker(o: SpeakerOptions): Speaker;
@@ -0,0 +1,414 @@
1
+ /**
2
+ * The speaker: takes a reply as it streams, cuts it into segments, runs
3
+ * them through the first engine that works, plays PCM gapless on one
4
+ * player, and reports progress as offsets in the caller's text when the
5
+ * voice reaches them. Segment N+1 is synthesized while N plays. A
6
+ * watchdog moves to the next engine when one goes quiet. A bounded cache
7
+ * of recent clips makes a replay instant.
8
+ */
9
+ import { GaplessPlayer } from "./player.js";
10
+ import { estimateWordTimes, SegmentCutter, speakable } from "./text.js";
11
+ import { renderSpeech } from "./render.js";
12
+ const defaultTimers = { setTimeout: (fn, ms) => setTimeout(fn, ms), clearTimeout: (h) => clearTimeout(h) };
13
+ class Watchdog extends Error {
14
+ }
15
+ export class Speaker {
16
+ player;
17
+ o;
18
+ timers;
19
+ cutter;
20
+ failed = new Set();
21
+ loaded = new Set();
22
+ queue = [];
23
+ cues = [];
24
+ utt = 0;
25
+ uttText = "";
26
+ uttFinal = true;
27
+ abort = new AbortController();
28
+ pumping = false;
29
+ nativeBusy = false;
30
+ speakingNow = false;
31
+ waiters = [];
32
+ nativeLevelUntil = 0;
33
+ interval = null;
34
+ cache = new Map();
35
+ cacheN = 0;
36
+ current = null;
37
+ constructor(o) {
38
+ this.o = o;
39
+ this.timers = o.timers ?? defaultTimers;
40
+ this.player = new GaplessPlayer(o.ctx, o.player);
41
+ this.cutter = new SegmentCutter(o.cutter);
42
+ }
43
+ /** The single analyser every PCM engine plays through. */
44
+ get analyser() {
45
+ return this.player.analyser;
46
+ }
47
+ get speaking() {
48
+ return this.speakingNow;
49
+ }
50
+ /** The engine that spoke last. */
51
+ get engine() {
52
+ return this.current;
53
+ }
54
+ get utterance() {
55
+ return this.utt;
56
+ }
57
+ /** Feed the visible reply so far. After `final`, the next feed starts a new utterance. */
58
+ feed(textSoFar, final = false) {
59
+ if (this.uttFinal) {
60
+ this.utt++;
61
+ this.cutter.reset();
62
+ this.uttFinal = false;
63
+ }
64
+ this.uttText = textSoFar;
65
+ for (const seg of this.cutter.take(textSoFar, final))
66
+ this.queue.push({ seg, utt: this.utt, input: textSoFar });
67
+ if (final)
68
+ this.uttFinal = true;
69
+ void this.pump();
70
+ return this.utt;
71
+ }
72
+ /** Speak a whole text; resolves when its audio has played or it was stopped. */
73
+ say(text) {
74
+ if (!this.uttFinal)
75
+ this.feed(this.uttText, true);
76
+ this.feed(text, true);
77
+ return this.done();
78
+ }
79
+ /** Resolves when nothing is queued, synthesizing or playing. */
80
+ done() {
81
+ if (!this.busy())
82
+ return Promise.resolve();
83
+ return new Promise((r) => this.waiters.push(r));
84
+ }
85
+ stop() {
86
+ this.abort.abort();
87
+ this.abort = new AbortController();
88
+ this.queue = [];
89
+ this.cues = [];
90
+ this.player.stop();
91
+ for (const e of this.o.engines)
92
+ if (e.kind === "native")
93
+ e.stop();
94
+ this.uttFinal = true;
95
+ this.setSpeaking(false);
96
+ this.flushWaiters();
97
+ }
98
+ /**
99
+ * Render a whole text offline on the speaker's engine chain, with its
100
+ * voice settings, for "save wav". Engines marked failed are skipped;
101
+ * native engines are skipped since they give no samples.
102
+ */
103
+ render(text, signal) {
104
+ const o = this.o;
105
+ return renderSpeech(o.engines.filter((e) => !this.failed.has(e.id)), text, {
106
+ ...(o.voice ? { voice: o.voice } : {}),
107
+ ...(o.voices ? { voices: o.voices } : {}),
108
+ ...(o.speakable ? { speakable: o.speakable } : {}),
109
+ ...(o.cutter ? { cutter: o.cutter } : {}),
110
+ ...(signal ? { signal } : {}),
111
+ onSkip: (engine, reason) => o.onStatus?.({ engine, kind: "failed", text: `${engine}: ${reason}` }),
112
+ });
113
+ }
114
+ /** Clear failure marks so every engine is tried again. */
115
+ resetEngines() {
116
+ this.failed.clear();
117
+ }
118
+ /** Output level for lip sync: analyser RMS for PCM engines, a boundary pulse for a native one (estimated). */
119
+ level() {
120
+ if (this.nativeBusy)
121
+ return this.o.ctx.currentTime < this.nativeLevelUntil ? 0.3 : 0.05;
122
+ return this.player.level();
123
+ }
124
+ /** Fire cues whose time has come and settle the speaking state. Runs on a timer unless tickMs is 0. */
125
+ tick() {
126
+ const now = this.o.ctx.currentTime;
127
+ if (this.cues.length) {
128
+ const due = this.cues.filter((c) => c.time <= now);
129
+ if (due.length) {
130
+ this.cues = this.cues.filter((c) => c.time > now);
131
+ for (const c of due)
132
+ c.fire();
133
+ }
134
+ }
135
+ if (this.speakingNow && !this.busy()) {
136
+ this.setSpeaking(false);
137
+ this.flushWaiters();
138
+ }
139
+ else if (!this.busy())
140
+ this.flushWaiters();
141
+ }
142
+ dispose() {
143
+ this.stop();
144
+ if (this.interval !== null)
145
+ this.timers.clearTimeout(this.interval);
146
+ this.interval = null;
147
+ }
148
+ busy() {
149
+ return this.pumping || this.nativeBusy || this.queue.length > 0 || this.cues.length > 0 || this.o.ctx.currentTime < this.player.endTime;
150
+ }
151
+ flushWaiters() {
152
+ const w = this.waiters;
153
+ this.waiters = [];
154
+ for (const r of w)
155
+ r();
156
+ }
157
+ setSpeaking(b) {
158
+ if (b === this.speakingNow)
159
+ return;
160
+ this.speakingNow = b;
161
+ this.o.onSpeaking?.(b);
162
+ if (b)
163
+ this.startTicker();
164
+ }
165
+ startTicker() {
166
+ const ms = this.o.tickMs ?? 25;
167
+ if (ms <= 0 || this.interval !== null)
168
+ return;
169
+ const loop = () => {
170
+ this.interval = null;
171
+ this.tick();
172
+ if (this.busy())
173
+ this.interval = this.timers.setTimeout(loop, ms);
174
+ };
175
+ this.interval = this.timers.setTimeout(loop, ms);
176
+ }
177
+ cfg(id) {
178
+ return { ...(this.o.voice ?? {}), ...(this.o.voices?.[id] ?? {}) };
179
+ }
180
+ async ensure(e) {
181
+ if (this.failed.has(e.id))
182
+ return false;
183
+ if (this.loaded.has(e.id))
184
+ return true;
185
+ try {
186
+ this.o.onStatus?.({ engine: e.id, kind: "loading", text: `loading ${e.id}` });
187
+ await e.load({ signal: this.abort.signal, onStatus: (s) => this.o.onStatus?.(s) });
188
+ this.loaded.add(e.id);
189
+ return true;
190
+ }
191
+ catch (err) {
192
+ this.fail(e, err);
193
+ return false;
194
+ }
195
+ }
196
+ fail(e, err) {
197
+ this.failed.add(e.id);
198
+ const kind = err instanceof Watchdog ? "watchdog" : "failed";
199
+ this.o.onStatus?.({ engine: e.id, kind, text: `${e.id}: ${err instanceof Error ? err.message : String(err)}` });
200
+ }
201
+ async pump() {
202
+ if (this.pumping)
203
+ return;
204
+ this.pumping = true;
205
+ try {
206
+ while (this.queue.length) {
207
+ const job = this.queue.shift();
208
+ const signal = this.abort.signal;
209
+ let spoken = false;
210
+ for (const e of this.o.engines) {
211
+ if (signal.aborted)
212
+ break;
213
+ if (!(await this.ensure(e)))
214
+ continue;
215
+ try {
216
+ if (e.kind === "pcm")
217
+ await this.runPcm(e, job.seg, job.utt, signal);
218
+ else
219
+ await this.runNative(e, job.seg, job.utt, signal);
220
+ spoken = true;
221
+ break;
222
+ }
223
+ catch (err) {
224
+ if (signal.aborted)
225
+ break;
226
+ this.fail(e, err);
227
+ }
228
+ }
229
+ if (!spoken && !signal.aborted)
230
+ this.o.onStatus?.({ engine: "none", kind: "failed", text: "no voice engine could speak this segment" });
231
+ }
232
+ }
233
+ finally {
234
+ this.pumping = false;
235
+ if (this.o.tickMs === 0 || this.interval === null)
236
+ this.tick();
237
+ }
238
+ }
239
+ progress(p) {
240
+ this.o.onProgress?.(p);
241
+ }
242
+ async *chunksOf(e, text, cfg, signal, info) {
243
+ const key = `${e.id}|${cfg.voice ?? ""}|${cfg.rate ?? 1}|${text}`;
244
+ const hit = this.cache.get(key);
245
+ info.cached = !!hit;
246
+ if (hit) {
247
+ this.cache.delete(key);
248
+ this.cache.set(key, hit);
249
+ yield* hit.chunks;
250
+ return;
251
+ }
252
+ const engineAbort = new AbortController();
253
+ const onAbort = () => engineAbort.abort();
254
+ // a listener added to an already aborted signal never fires
255
+ if (signal.aborted)
256
+ engineAbort.abort();
257
+ else
258
+ signal.addEventListener("abort", onAbort, { once: true });
259
+ const it = e.synth(text, cfg, engineAbort.signal)[Symbol.asyncIterator]();
260
+ const got = [];
261
+ let n = 0;
262
+ const ms = this.o.watchdogMs ?? 45000;
263
+ try {
264
+ for (;;) {
265
+ let h;
266
+ const timeout = new Promise((_, rej) => {
267
+ h = this.timers.setTimeout(() => rej(new Watchdog(`no audio for ${ms / 1000} s`)), ms);
268
+ });
269
+ let r;
270
+ try {
271
+ r = await Promise.race([it.next(), timeout]);
272
+ }
273
+ catch (err) {
274
+ engineAbort.abort();
275
+ throw err;
276
+ }
277
+ finally {
278
+ this.timers.clearTimeout(h);
279
+ }
280
+ if (r.done)
281
+ break;
282
+ got.push(r.value);
283
+ n += r.value.samples.length;
284
+ yield r.value;
285
+ }
286
+ }
287
+ finally {
288
+ signal.removeEventListener("abort", onAbort);
289
+ }
290
+ const cap = this.o.cacheSamples ?? 3 * 60 * 24000;
291
+ if (cap > 0 && n <= cap && !signal.aborted) {
292
+ this.cache.set(key, { chunks: got, n });
293
+ this.cacheN += n;
294
+ for (const [k, v] of this.cache) {
295
+ if (this.cacheN <= cap)
296
+ break;
297
+ this.cache.delete(k);
298
+ this.cacheN -= v.n;
299
+ }
300
+ }
301
+ }
302
+ async runPcm(e, seg, utt, signal) {
303
+ const sp = speakable(seg.text, this.o.speakable);
304
+ if (!sp.text)
305
+ return;
306
+ const at = (i) => seg.start + sp.map[Math.min(i, sp.map.length - 1)];
307
+ const cfg = this.cfg(e.id);
308
+ let segStart = -1;
309
+ let segEnd = -1;
310
+ let reported = false;
311
+ let first = true;
312
+ let pending = null;
313
+ const info = { cached: false };
314
+ const place = (c, last) => {
315
+ const span = this.player.schedule(c.samples, c.sampleRate, { in: first, out: last });
316
+ if (first) {
317
+ segStart = span.start;
318
+ this.current = e.id;
319
+ this.o.onSegment?.({ ...seg, utterance: utt, engine: e.id, cached: info.cached });
320
+ // speaking starts when the audio clock reaches the chunk, not when it is scheduled
321
+ this.cue(span.start, () => {
322
+ this.progress({ utterance: utt, offset: seg.start, kind: "segment", estimated: false });
323
+ this.setSpeaking(true);
324
+ });
325
+ this.startTicker();
326
+ }
327
+ first = false;
328
+ segEnd = span.end;
329
+ for (const [kind, list] of [["word", c.words], ["phoneme", c.phonemes]]) {
330
+ for (const w of list ?? []) {
331
+ reported ||= kind === "word";
332
+ this.placeTimed(utt, kind, w, span.start, at, false);
333
+ }
334
+ }
335
+ };
336
+ // hold one chunk back so the last one gets its fade out
337
+ for await (const c of this.chunksOf(e, sp.text, cfg, signal, info)) {
338
+ if (signal.aborted)
339
+ return;
340
+ if (pending)
341
+ place(pending, false);
342
+ pending = c;
343
+ }
344
+ if (signal.aborted)
345
+ return;
346
+ if (pending)
347
+ place(pending, true);
348
+ if (segStart < 0)
349
+ return;
350
+ if (!reported)
351
+ for (const w of estimateWordTimes(sp.text, segEnd - segStart))
352
+ this.placeTimed(utt, "word", w, segStart, at, true);
353
+ this.cue(segEnd, () => this.progress({ utterance: utt, offset: seg.end, kind: "end", estimated: false }));
354
+ }
355
+ placeTimed(utt, kind, w, base, at, estimated) {
356
+ const ev = { utterance: utt, kind, start: at(w.start), end: at(w.end), t0: base + w.t0, t1: base + w.t1, estimated };
357
+ if (w.phoneme !== undefined)
358
+ ev.phoneme = w.phoneme;
359
+ this.o.onTimed?.(ev);
360
+ if (kind === "word")
361
+ this.cue(ev.t0, () => this.progress({ utterance: utt, offset: ev.start, kind: "word", estimated }));
362
+ }
363
+ cue(time, fire) {
364
+ this.cues.push({ time, fire });
365
+ this.cues.sort((a, b) => a.time - b.time);
366
+ }
367
+ async runNative(e, seg, utt, signal) {
368
+ // let queued PCM audio finish first
369
+ while (!signal.aborted && this.o.ctx.currentTime < this.player.endTime) {
370
+ await new Promise((r) => this.timers.setTimeout(r, Math.max(10, (this.player.endTime - this.o.ctx.currentTime) * 1000)));
371
+ this.tick();
372
+ }
373
+ if (signal.aborted)
374
+ return;
375
+ const sp = speakable(seg.text, this.o.speakable);
376
+ if (!sp.text)
377
+ return;
378
+ const at = (i) => seg.start + sp.map[Math.min(i, sp.map.length - 1)];
379
+ this.nativeBusy = true;
380
+ this.current = e.id;
381
+ this.o.onSegment?.({ ...seg, utterance: utt, engine: e.id, cached: false });
382
+ // speaking starts when the platform reports audio (onstart, or the first word boundary);
383
+ // a native engine that reports neither never sets it, so its time to first audio is unknown
384
+ let started = false;
385
+ const start = () => {
386
+ if (started)
387
+ return;
388
+ started = true;
389
+ this.setSpeaking(true);
390
+ };
391
+ this.progress({ utterance: utt, offset: seg.start, kind: "segment", estimated: false });
392
+ try {
393
+ await e.speak(sp.text, this.cfg(e.id), {
394
+ onStart: start,
395
+ onBoundary: (ci, len) => {
396
+ start();
397
+ const t = this.o.ctx.currentTime;
398
+ this.nativeLevelUntil = t + 0.15;
399
+ const end = len !== undefined ? ci + len : (/[\p{L}\p{N}'’]+/u.exec(sp.text.slice(ci))?.[0].length ?? 0) + ci;
400
+ this.o.onTimed?.({ utterance: utt, kind: "word", start: at(ci), end: at(end), t0: t, t1: t, estimated: false });
401
+ this.progress({ utterance: utt, offset: at(ci), kind: "word", estimated: false });
402
+ },
403
+ }, signal);
404
+ if (!signal.aborted)
405
+ this.progress({ utterance: utt, offset: seg.end, kind: "end", estimated: false });
406
+ }
407
+ finally {
408
+ this.nativeBusy = false;
409
+ }
410
+ }
411
+ }
412
+ export function createSpeaker(o) {
413
+ return new Speaker(o);
414
+ }
package/dist/text.d.ts ADDED
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Text for a voice: what to say and where each spoken character came
3
+ * from. Offsets are kept in the caller's text (the visible reply, with
4
+ * action tags already removed), so lip sync and action cues share one
5
+ * coordinate space with the tag parser in @hackbuild/structured.
6
+ */
7
+ export interface Speakable {
8
+ /** Text to send to an engine. */
9
+ text: string;
10
+ /** map[i] is the offset in the input of output character i; map[text.length] is the input length. */
11
+ map: Int32Array;
12
+ }
13
+ export interface SpeakableOptions {
14
+ /** Whole word replacements, e.g. { "hack.build": "hack dot build", AuDHD: "A U D H D" }. */
15
+ lexicon?: Record<string, string>;
16
+ /** Word read in place of a bare URL. Default "link". */
17
+ url?: string;
18
+ }
19
+ /**
20
+ * Strip what should not be read aloud: think blocks (closed or still
21
+ * open), code fences, markdown marks, link targets, emoji and variation
22
+ * selectors; read bare URLs as one word; apply the lexicon; collapse
23
+ * whitespace. Returns the text and an offset map back into the input.
24
+ */
25
+ export declare function speakable(input: string, o?: SpeakableOptions): Speakable;
26
+ export interface Segment {
27
+ index: number;
28
+ /** The input text of this segment. */
29
+ text: string;
30
+ /** Offsets in the input text. */
31
+ start: number;
32
+ end: number;
33
+ }
34
+ export interface CutterOptions {
35
+ /** The first segment may end at a clause boundary once this long. Default 24. */
36
+ firstClause?: number;
37
+ /** Later segments wait for a sentence end unless longer than this. Default 160. */
38
+ maxChars?: number;
39
+ }
40
+ /**
41
+ * Cuts a growing reply into segments for a voice. The first segment ends
42
+ * at a clause once it is 24 characters long so speech starts early; later
43
+ * segments end at sentences, or at the last clause or space before 160
44
+ * characters. `take(full, final)` returns the segments completed since the
45
+ * last call.
46
+ */
47
+ export declare class SegmentCutter {
48
+ private pos;
49
+ private n;
50
+ private readonly first;
51
+ private readonly max;
52
+ constructor(o?: CutterOptions);
53
+ reset(): void;
54
+ take(full: string, final: boolean): Segment[];
55
+ private findCut;
56
+ }
57
+ /** Word spans in a text: [start, end) character offsets. */
58
+ export declare function wordSpans(text: string): {
59
+ start: number;
60
+ end: number;
61
+ }[];
62
+ /**
63
+ * Estimated word times for an engine that gives none: each word gets a
64
+ * share of the duration by its character count plus one for the gap.
65
+ * Marked estimated wherever it is reported.
66
+ */
67
+ export declare function estimateWordTimes(text: string, duration: number): {
68
+ start: number;
69
+ end: number;
70
+ t0: number;
71
+ t1: number;
72
+ }[];