import { type OrtRuntime } from "./models/ort-runtime.js"; import type { DiarizationResult } from "./types.js"; export interface PipelineConfig { ort: OrtRuntime; segmentationModel: string | ArrayBufferLike | Uint8Array; embeddingModel: string | ArrayBufferLike | Uint8Array; /** Parsed plda-params-vbx.json. */ pldaParamsJson: unknown; /** * Per-session execution provider list, e.g. `["webgpu", "wasm"]` in browser, * `["cpu"]` in Node. Omitted = runtime default chain (which on * `onnxruntime-web/webgpu` is already `[webgpu, wasm]`). */ executionProviders?: ReadonlyArray; segmentationStep?: number; windowSec?: number; sampleRate?: number; embeddingExcludeOverlap?: boolean; ahcThreshold?: number; vbxFa?: number; vbxFb?: number; vbxMaxIters?: number; minDurationOff?: number; minDurationOn?: number; /** Minimum number of fbank frames required to compute an embedding. */ minFbankFrames?: number; /** Batch size for embedding inference. */ embeddingBatchSize?: number; /** Batch size for segmentation inference. */ segmentationBatchSize?: number; /** * Sleep N ms between consecutive ONNX batches (segmentation + embedding). * Trades total wall time for cooler CPU/GPU; useful for sustained-load * scenarios on hot laptops. 0 = no throttling. */ batchYieldMs?: number; } export type PipelineStep = "segmentation" | "embedding" | "clustering" | "reconstruction"; export interface PipelineProgress { step: PipelineStep; current: number; total: number; fraction: number; } export interface PipelineRunOptions { onProgress?: (p: PipelineProgress) => void; } export interface PipelineStreamOptions extends PipelineRunOptions { /** * Called after each chunk's embeddings + re-clustering. Lets the UI * paint segments progressively. The final call has `isFinal = true` and * the partial result equals the final return value. */ onPartial?: (partial: { result: DiarizationResult; metrics: PipelineMetrics; isFinal: boolean; }) => void; /** * Re-cluster + emit a partial every N chunks. Lower = smoother UI, more * clustering work; higher = chunkier updates, less overhead. Default 4. */ emitEveryNChunks?: number; } export interface PipelineMetrics { audioDurationSec: number; totalProcessingMs: number; segmentationMs: number; fbankMs: number; embeddingMs: number; clusteringMs: number; reconstructionMs: number; numChunks: number; numEmbeddings: number; numActiveEmbeddings: number; numAhcClusters: number; numVbxClusters: number; rtf: number; } export declare class DiarizationPipeline { private readonly segmentation; private readonly embedding; private readonly plda; private readonly cfg; private constructor(); static create(config: PipelineConfig): Promise; run(waveform: Float32Array, sourceSampleRate: number, options?: PipelineRunOptions): Promise<{ result: DiarizationResult; metrics: PipelineMetrics; }>; /** * Streaming variant: same final result as run(), but emits partial * diarizations after each chunk (or group of chunks) is processed. UI can * paint segments progressively to give a "live" feel. Total wall time is * comparable to (or slightly slower than) batch — the win is in * time-to-first-segment, not throughput. * * Internally: * 1. Run full segmentation upfront (it's only ~10% of total time). * 2. Group the per-(chunk, local-speaker) embedding requests by chunk. * 3. For each group of `emitEveryNChunks` chunks: extract embeddings for * those chunks, accumulate into the running set, re-cluster everything * so far, reconstruct, emit a partial. * * Re-clustering on every emit gives stable globally-consistent labels (at * the cost of redoing work). For typical playground material (< 50 active * embeddings) AHC + VBx are sub-100 ms so the overhead is negligible. */ runStream(waveform: Float32Array, sourceSampleRate: number, options?: PipelineStreamOptions): Promise<{ result: DiarizationResult; metrics: PipelineMetrics; }>; /** * Shared cluster + reconstruct path for the streaming pipeline. Mirrors * the tail of run() but accepts pre-computed timing slabs and an optional * crop horizon (so streaming partials don't claim "no speaker" on audio * that simply hasn't been processed yet). */ private clusterAndReconstruct; } //# sourceMappingURL=pipeline.d.ts.map