File size: 1,069 Bytes
3ec6b9e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// 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[] };