// Messages between the page and the synthesis worker. import type { Voice } from './frontend.ts'; import type { WordTiming } from './engine.ts'; export type WorkerRequest = | { type: 'init'; baseUrl: string } | { type: 'cancel'; id: number } | { type: 'speak'; id: number; text: string; voice: Voice }; export type WorkerMessage = | { type: 'progress'; loaded: number; total: number } | { type: 'ready'; backend: string; fromCache: boolean; networkBytes: number; totalBytes: number; loadMs: number; initMs: number; words: number } | { type: 'fatal'; message: string } | { type: 'plan'; id: number; frames: number; normalized: string; words: WordTiming[]; symbols: string[]; tokenStart: Int32Array; durations: Int32Array; unknown: string[]; sampleRate: number; hop: number; } | { type: 'audio'; id: number; pcm: Float32Array; firstFrame: number } | { type: 'done'; id: number; seconds: number; computeMs: number; firstChunkMs: number | null } | { type: 'error'; id: number; message: string; user: boolean; characters?: string[] };