import type { InferenceSession, Tensor } from "onnxruntime-common"; import { type Plan, type PlannedSection } from "./plan.ts"; import { type LoadBytes } from "@yomiscript/core"; export type { LoadBytes }; /** the parts of onnxruntime this engine uses (onnxruntime-web and onnxruntime-node both have them) */ export interface Ort { InferenceSession: { create(model: Uint8Array | ArrayBuffer, options?: InferenceSession.SessionOptions): Promise; }; Tensor: new (type: "float32" | "int64", data: Float32Array | BigInt64Array, dims: readonly number[]) => Tensor; } export interface EngineOptions { /** model file suffix per part: {} = fp32 (identical to the original Kokoro), W16 = fp16 weights */ suffix?: Partial>; executionProviders?: string[]; } export declare const FP32: {}, W16: { enc: string; f0n: string; dec: string; }; /** pitch: "values" renders the YomiScript's values; "engine" keeps Kokoro's own F0 (the original's audio) */ export type PitchMode = "values" | "engine"; export interface Prediction { ref: Tensor; dur: number[]; t_en: Tensor; f0: Float32Array; N: Tensor; } export interface Synthesis { audio: Float32Array; plan: Plan; } export declare class Engine { private V; private enc; private f0n; private dec; private ort; private load; constructor(ort: Ort, load: LoadBytes); init(opts?: EngineOptions): Promise; voice(name: string): Promise; predict(sec: PlannedSection, durations?: number[]): Promise; synthSection(sec: PlannedSection, pitch?: PitchMode, durations?: number[]): Promise<{ audio: Float32Array; f0: Float32Array; f0new: Float32Array; dur: number[]; }>; /** the F0 the decoder gets: the YomiScript's values put into the engine's own (Japanese: render_ja.ts, D28) */ private pitch; synth(ys: string, pitch?: PitchMode): Promise; }