@try-works/tool-mode-runtime-onnx 0.0.0-stage → 0.1.1
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.
- package/README.md +64 -2
- package/lib/clear-dsp.d.ts +235 -0
- package/lib/clear-dsp.d.ts.map +1 -0
- package/lib/clear-dsp.js +487 -0
- package/lib/clear-processor.d.ts +30 -0
- package/lib/clear-processor.d.ts.map +1 -0
- package/lib/clear-processor.js +172 -0
- package/lib/errors.d.ts +14 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +29 -0
- package/lib/fft.d.ts +86 -0
- package/lib/fft.d.ts.map +1 -0
- package/lib/fft.js +231 -0
- package/lib/frames.d.ts +99 -0
- package/lib/frames.d.ts.map +1 -0
- package/lib/frames.js +284 -0
- package/lib/index.d.ts +27 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +27 -0
- package/lib/processor.d.ts +74 -0
- package/lib/processor.d.ts.map +1 -0
- package/lib/processor.js +82 -0
- package/lib/provider-factory.d.ts +47 -0
- package/lib/provider-factory.d.ts.map +1 -0
- package/lib/provider-factory.js +276 -0
- package/lib/runtime.d.ts +122 -0
- package/lib/runtime.d.ts.map +1 -0
- package/lib/runtime.js +175 -0
- package/lib/uhm-processor.d.ts +23 -0
- package/lib/uhm-processor.d.ts.map +1 -0
- package/lib/uhm-processor.js +126 -0
- package/lib/wav.d.ts +97 -0
- package/lib/wav.d.ts.map +1 -0
- package/lib/wav.js +196 -0
- package/package.json +48 -4
package/lib/frames.js
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Frames, spans and coverage (PHASE3 processor uhm/waveform-v1, steps 3-5).
|
|
3
|
+
*
|
|
4
|
+
* The model emits one probability row per 20 ms frame. Turning 1499 rows per window into
|
|
5
|
+
* spans that a caller can cut a recording with is where the honest-timeline decisions live:
|
|
6
|
+
*
|
|
7
|
+
* - **Every absolute frame is decided ONCE.** Windows overlap by a second, so the last
|
|
8
|
+
* 1450 frames of one window are the first frames of the next. A frame is a FILLER if
|
|
9
|
+
* either window calls it one at or above the threshold — the overlap exists so a word
|
|
10
|
+
* seen at a window edge by one window is not vetoed by the other — and between two
|
|
11
|
+
* filler calls the higher probability wins; an exact tie keeps the earlier window.
|
|
12
|
+
* Averaging instead would invent a confidence neither window produced.
|
|
13
|
+
* - **A filler frame is `class != 0 && probability >= 0.5`.** Class 0 is `not_filler`,
|
|
14
|
+
* and a filler word that the model is not sure about is not worth cutting out.
|
|
15
|
+
* - **One frame gap is tolerated.** A single non-filler frame between two filler frames of
|
|
16
|
+
* the same class is a boundary artefact, not two separate fillers.
|
|
17
|
+
* - **Spans are clipped to the audio length.** The final window is zero padded to 30 s, so
|
|
18
|
+
* frames past the real audio carry no evidence and are dropped; a frame that straddles
|
|
19
|
+
* the end is clipped.
|
|
20
|
+
*
|
|
21
|
+
* @module frames
|
|
22
|
+
*/
|
|
23
|
+
/*
|
|
24
|
+
* `parseUhmLabels` IS the validation boundary for the package's hand-editable labels.json:
|
|
25
|
+
* taking `unknown`, proving each field at run time and naming what is wrong is its job. The
|
|
26
|
+
* generic anti-slop rules assume a caller that already has a typed document, so they are
|
|
27
|
+
* disabled for this boundary only.
|
|
28
|
+
*/
|
|
29
|
+
/* oxlint-disable anti-slop/no-unknown-parameters, anti-slop/no-unsafe-dictionary-type, anti-slop/no-runtime-typeof */
|
|
30
|
+
import { UHM_FRAME_SAMPLES, UHM_SAMPLE_RATE } from "./wav.js";
|
|
31
|
+
/** The labels file the pinned asset set carries next to the model. */
|
|
32
|
+
export const UHM_LABELS_FILE = 'labels.json';
|
|
33
|
+
/** The number of classes the pinned model head emits. */
|
|
34
|
+
export const UHM_CLASS_COUNT = 6;
|
|
35
|
+
/** A frame is a filler only at or above this probability. */
|
|
36
|
+
export const UHM_FILLER_THRESHOLD = 0.5;
|
|
37
|
+
/** The filler classes the output contract can name (class 0 is not a filler). */
|
|
38
|
+
export const UHM_FILLER_TYPES = ['uh', 'um', 'hmm', 'and', 'other'];
|
|
39
|
+
/** Whether a value is a plain JSON object. */
|
|
40
|
+
function isPlainObject(value) {
|
|
41
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
42
|
+
return false;
|
|
43
|
+
const prototype = Object.getPrototypeOf(value);
|
|
44
|
+
return prototype === Object.prototype || prototype === null;
|
|
45
|
+
}
|
|
46
|
+
/** Read the label array out of either accepted document shape. */
|
|
47
|
+
function readLabelArray(raw) {
|
|
48
|
+
if (Array.isArray(raw)) {
|
|
49
|
+
const labels = [];
|
|
50
|
+
for (const [index, value] of raw.entries()) {
|
|
51
|
+
if (typeof value !== 'string' || value.length === 0) {
|
|
52
|
+
return { ok: false, reason: `label ${String(index)} must be a non-empty string` };
|
|
53
|
+
}
|
|
54
|
+
labels.push(value);
|
|
55
|
+
}
|
|
56
|
+
return { ok: true, labels };
|
|
57
|
+
}
|
|
58
|
+
if (!isPlainObject(raw)) {
|
|
59
|
+
return { ok: false, reason: 'the labels document must be a JSON object with an id2label table, or an array of labels' };
|
|
60
|
+
}
|
|
61
|
+
const table = raw['id2label'];
|
|
62
|
+
if (!isPlainObject(table)) {
|
|
63
|
+
return { ok: false, reason: 'the labels document has no id2label table' };
|
|
64
|
+
}
|
|
65
|
+
const labels = [];
|
|
66
|
+
for (let index = 0; index < UHM_CLASS_COUNT; index += 1) {
|
|
67
|
+
const value = table[String(index)];
|
|
68
|
+
if (typeof value !== 'string' || value.length === 0) {
|
|
69
|
+
return {
|
|
70
|
+
ok: false,
|
|
71
|
+
reason: `the id2label table must name exactly six classes; class ${String(index)} is missing or not a string`,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
labels.push(value);
|
|
75
|
+
}
|
|
76
|
+
const extra = Object.keys(table).filter((key) => !/^\d+$/.test(key) || Number(key) >= UHM_CLASS_COUNT);
|
|
77
|
+
if (extra.length > 0) {
|
|
78
|
+
return {
|
|
79
|
+
ok: false,
|
|
80
|
+
reason: `the id2label table names classes beyond the six the model emits: ${extra.join(', ')}`,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return { ok: true, labels };
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Parse the pinned `labels.json` into the class order the head emits.
|
|
87
|
+
*
|
|
88
|
+
* The ORDER is the contract, not any name lookup: frame class 1 must be `uh` because the
|
|
89
|
+
* head was trained that way. The names are validated too, because the output contract can
|
|
90
|
+
* only name the five filler classes — a drifted labels file must fail loudly rather than
|
|
91
|
+
* emit a `type` the schema does not allow.
|
|
92
|
+
*
|
|
93
|
+
* @param raw - the parsed JSON document
|
|
94
|
+
* @returns the labels in class order, or the reason they cannot be used
|
|
95
|
+
*/
|
|
96
|
+
export function parseUhmLabels(raw) {
|
|
97
|
+
const read = readLabelArray(raw);
|
|
98
|
+
if (!read.ok)
|
|
99
|
+
return read;
|
|
100
|
+
const labels = [...read.labels];
|
|
101
|
+
if (labels.length !== UHM_CLASS_COUNT) {
|
|
102
|
+
return {
|
|
103
|
+
ok: false,
|
|
104
|
+
reason: `the labels table must name exactly six classes; it names ${String(labels.length)}`,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
if (labels[0] !== 'not_filler') {
|
|
108
|
+
return { ok: false, reason: `the first class must be not_filler; it is ${JSON.stringify(labels[0])}` };
|
|
109
|
+
}
|
|
110
|
+
const seen = new Set();
|
|
111
|
+
for (const [index, label] of labels.entries()) {
|
|
112
|
+
if (seen.has(label)) {
|
|
113
|
+
return { ok: false, reason: `the labels table repeats the class ${JSON.stringify(label)}` };
|
|
114
|
+
}
|
|
115
|
+
seen.add(label);
|
|
116
|
+
if (index === 0)
|
|
117
|
+
continue;
|
|
118
|
+
if (!isFillerType(label)) {
|
|
119
|
+
return {
|
|
120
|
+
ok: false,
|
|
121
|
+
reason: `class ${String(index)} is ${JSON.stringify(label)}, which the filler output contract cannot name; allowed: ${UHM_FILLER_TYPES.join(', ')}`,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return { ok: true, labels };
|
|
126
|
+
}
|
|
127
|
+
/** Whether a label is one of the five filler classes. */
|
|
128
|
+
function isFillerType(label) {
|
|
129
|
+
return UHM_FILLER_TYPES.some((candidate) => candidate === label);
|
|
130
|
+
}
|
|
131
|
+
/** Return the label as a filler type, or throw if it is not one. */
|
|
132
|
+
function fillerType(label) {
|
|
133
|
+
for (const candidate of UHM_FILLER_TYPES) {
|
|
134
|
+
if (candidate === label)
|
|
135
|
+
return candidate;
|
|
136
|
+
}
|
|
137
|
+
throw new Error(`the label ${JSON.stringify(label)} is not a filler type`);
|
|
138
|
+
}
|
|
139
|
+
/** Read and validate an output tensor's geometry. */
|
|
140
|
+
function readGeometry(dims, dataLength) {
|
|
141
|
+
let frames;
|
|
142
|
+
let classes;
|
|
143
|
+
if (dims.length === 3 && dims[0] === 1) {
|
|
144
|
+
frames = dims[1];
|
|
145
|
+
classes = dims[2];
|
|
146
|
+
}
|
|
147
|
+
else if (dims.length === 2) {
|
|
148
|
+
frames = dims[0];
|
|
149
|
+
classes = dims[1];
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
throw new Error(`the model output shape ${JSON.stringify(dims)} is neither (1, frames, classes) nor (frames, classes)`);
|
|
153
|
+
}
|
|
154
|
+
if (frames === undefined
|
|
155
|
+
|| classes === undefined
|
|
156
|
+
|| !Number.isInteger(frames)
|
|
157
|
+
|| !Number.isInteger(classes)
|
|
158
|
+
|| frames <= 0
|
|
159
|
+
|| classes <= 0) {
|
|
160
|
+
throw new Error(`the model output shape ${JSON.stringify(dims)} is not a positive integer geometry`);
|
|
161
|
+
}
|
|
162
|
+
if (frames * classes !== dataLength) {
|
|
163
|
+
throw new Error(`the model output data length is ${String(dataLength)} but the shape ${JSON.stringify(dims)} needs ${String(frames * classes)}`);
|
|
164
|
+
}
|
|
165
|
+
return { frames, classes };
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Rank two predictions of the same absolute frame.
|
|
169
|
+
*
|
|
170
|
+
* A qualifying filler call outranks any non-filler call, so a window that saw a filler is
|
|
171
|
+
* not vetoed by the other window's `not_filler`. Within the same kind, the higher
|
|
172
|
+
* probability wins; equal ranks keep the earlier window.
|
|
173
|
+
*/
|
|
174
|
+
function rankCandidate(classIndex, probability) {
|
|
175
|
+
const isFiller = classIndex !== 0 && probability >= UHM_FILLER_THRESHOLD;
|
|
176
|
+
return isFiller ? 1 + probability : probability;
|
|
177
|
+
}
|
|
178
|
+
/** Clamp a confidence into the contract's range. */
|
|
179
|
+
function clampUnit(value) {
|
|
180
|
+
return Math.max(0, Math.min(1, value));
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Turn window outputs into merged filler spans and honest coverage.
|
|
184
|
+
*
|
|
185
|
+
* `totalSamples` is the REAL audio length, so zero padded frames are dropped and spans are
|
|
186
|
+
* clipped; it is never the padded window length.
|
|
187
|
+
*
|
|
188
|
+
* @param input - the window runs, the real sample count and the class order
|
|
189
|
+
* @returns the filler spans and coverage
|
|
190
|
+
* @throws Error when the model output is malformed (the provider maps this to InferenceFailed)
|
|
191
|
+
*/
|
|
192
|
+
export function uhmResultFromWindows(input) {
|
|
193
|
+
const { runs, totalSamples, labels } = input;
|
|
194
|
+
if (!Number.isInteger(totalSamples) || totalSamples < 0) {
|
|
195
|
+
throw new Error('the total sample count must be a non-negative integer');
|
|
196
|
+
}
|
|
197
|
+
if (labels.length !== UHM_CLASS_COUNT) {
|
|
198
|
+
throw new Error(`the label table names ${String(labels.length)} classes but the model emits ${String(UHM_CLASS_COUNT)}`);
|
|
199
|
+
}
|
|
200
|
+
const byFrame = new Map();
|
|
201
|
+
for (const run of runs) {
|
|
202
|
+
const { frames, classes } = readGeometry(run.dims, run.data.length);
|
|
203
|
+
if (classes !== labels.length) {
|
|
204
|
+
throw new Error(`the model emitted ${String(classes)} classes but the label table names ${String(labels.length)}`);
|
|
205
|
+
}
|
|
206
|
+
for (let frame = 0; frame < frames; frame += 1) {
|
|
207
|
+
const frameStartSample = run.window.startSample + frame * UHM_FRAME_SAMPLES;
|
|
208
|
+
// A frame that starts past the audio is entirely padding: there is nothing to report.
|
|
209
|
+
if (frameStartSample >= totalSamples)
|
|
210
|
+
continue;
|
|
211
|
+
const base = frame * classes;
|
|
212
|
+
let bestClass = 0;
|
|
213
|
+
let bestProbability = Number.NEGATIVE_INFINITY;
|
|
214
|
+
for (let column = 0; column < classes; column += 1) {
|
|
215
|
+
const probability = run.data[base + column];
|
|
216
|
+
if (probability === undefined || !Number.isFinite(probability)) {
|
|
217
|
+
throw new Error(`the model output contains a non-finite probability at frame ${String(frame)}`);
|
|
218
|
+
}
|
|
219
|
+
if (probability > bestProbability) {
|
|
220
|
+
bestProbability = probability;
|
|
221
|
+
bestClass = column;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
const frameIndex = Math.round(frameStartSample / UHM_FRAME_SAMPLES);
|
|
225
|
+
const startMs = Math.floor(frameStartSample / (UHM_SAMPLE_RATE / 1000));
|
|
226
|
+
const endSample = Math.min(frameStartSample + UHM_FRAME_SAMPLES, totalSamples);
|
|
227
|
+
const endMs = Math.floor(endSample / (UHM_SAMPLE_RATE / 1000));
|
|
228
|
+
if (endMs <= startMs)
|
|
229
|
+
continue;
|
|
230
|
+
const existing = byFrame.get(frameIndex);
|
|
231
|
+
if (existing === undefined
|
|
232
|
+
|| rankCandidate(bestClass, bestProbability) > rankCandidate(existing.classIndex, existing.probability)) {
|
|
233
|
+
byFrame.set(frameIndex, { frameIndex, classIndex: bestClass, probability: bestProbability, startMs, endMs });
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
const candidates = [...byFrame.values()]
|
|
238
|
+
.filter((candidate) => candidate.classIndex !== 0 && candidate.probability >= UHM_FILLER_THRESHOLD)
|
|
239
|
+
.sort((left, right) => left.frameIndex - right.frameIndex);
|
|
240
|
+
const fillers = [];
|
|
241
|
+
let current;
|
|
242
|
+
let currentType = 'uh';
|
|
243
|
+
const flush = () => {
|
|
244
|
+
if (current === undefined)
|
|
245
|
+
return;
|
|
246
|
+
fillers.push({
|
|
247
|
+
startMs: current.startMs,
|
|
248
|
+
endMs: current.endMs,
|
|
249
|
+
type: currentType,
|
|
250
|
+
confidence: clampUnit(current.total / current.count),
|
|
251
|
+
});
|
|
252
|
+
current = undefined;
|
|
253
|
+
};
|
|
254
|
+
for (const candidate of candidates) {
|
|
255
|
+
const continues = current !== undefined
|
|
256
|
+
&& current.classIndex === candidate.classIndex
|
|
257
|
+
&& candidate.frameIndex - current.lastFrameIndex <= 2;
|
|
258
|
+
if (continues && current !== undefined) {
|
|
259
|
+
current.lastFrameIndex = candidate.frameIndex;
|
|
260
|
+
current.endMs = candidate.endMs;
|
|
261
|
+
current.total += candidate.probability;
|
|
262
|
+
current.count += 1;
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
flush();
|
|
266
|
+
const label = labels[candidate.classIndex];
|
|
267
|
+
if (label === undefined) {
|
|
268
|
+
throw new Error(`the model emitted class ${String(candidate.classIndex)} but the label table has no such class`);
|
|
269
|
+
}
|
|
270
|
+
currentType = fillerType(label);
|
|
271
|
+
current = {
|
|
272
|
+
classIndex: candidate.classIndex,
|
|
273
|
+
lastFrameIndex: candidate.frameIndex,
|
|
274
|
+
startMs: candidate.startMs,
|
|
275
|
+
endMs: candidate.endMs,
|
|
276
|
+
total: candidate.probability,
|
|
277
|
+
count: 1,
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
flush();
|
|
281
|
+
const totalSeconds = totalSamples / UHM_SAMPLE_RATE;
|
|
282
|
+
return { fillers, coverage: { complete: true, processedSeconds: totalSeconds, totalSeconds } };
|
|
283
|
+
}
|
|
284
|
+
//# sourceMappingURL=frames.js.map
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@try-works/tool-mode-runtime-onnx` — the ONNX Runtime engine for the local model
|
|
3
|
+
* runtime (Phase 3).
|
|
4
|
+
*
|
|
5
|
+
* Public surface:
|
|
6
|
+
* - `OnnxSession` / `onnxLayer` / `createNodeOnnxLoader` — the Effect service over one
|
|
7
|
+
* onnxruntime-node session, with execution-provider negotiation.
|
|
8
|
+
* - `createProviderFromRecipe` — the factory a code-free model recipe names. This build
|
|
9
|
+
* implements two processors:
|
|
10
|
+
* - `uhm/waveform-v1`: filler-word detection (WAV in, filler spans out);
|
|
11
|
+
* - `clear/stft-v1`: DeepFilterNet3 enhancement (WAV in, enhanced base64 WAV out, bound
|
|
12
|
+
* by the host result budget).
|
|
13
|
+
* - the uhm and clear building blocks the processors are made of, exported so a later
|
|
14
|
+
* processor can reuse them (the clear DSP is a published contract, not an internal).
|
|
15
|
+
* - `InferenceFailed` / `InvalidInput` / `RuntimeUnavailable` — the typed failures.
|
|
16
|
+
*
|
|
17
|
+
* @module @try-works/tool-mode-runtime-onnx
|
|
18
|
+
*/
|
|
19
|
+
export { InferenceFailed, InvalidInput, RuntimeUnavailable, describeCause } from './errors.ts';
|
|
20
|
+
export { CLEAR_STFT_PROCESSOR, type ClearBinding } from './clear-processor.ts';
|
|
21
|
+
export { CLEAR_CHUNK_FRAMES, CLEAR_ERB_WIDTHS, CLEAR_FFT_SIZE, CLEAR_HOP_SIZE, CLEAR_LOOKAHEAD, CLEAR_MAX_GAIN_DB, CLEAR_N_DF, CLEAR_N_ERB, CLEAR_N_FREQ, CLEAR_NORM_ALPHA, CLEAR_OUTPUT_ENVELOPE_BYTES, CLEAR_PEAK_CEILING_DBTP, CLEAR_SAMPLE_RATE, CLEAR_TARGET_LUFS, CLEAR_WAV_HEADER_BYTES, ClearStft, clearChunkInputs, clearFeatures, encodePcm16Wav, integratedLufs, limitInPlace, maxSamplesForResultBudget, normalizeLoudnessInPlace, scatterEnhanced, vorbisWindow, type ClearChunkInputRequest, type ClearChunkInputs, type ClearFeatures, type ClearLoudnessOptions, type ClearScatterRequest, type ClearSpectrum, } from './clear-dsp.ts';
|
|
22
|
+
export { UHM_CLASS_COUNT, UHM_FILLER_THRESHOLD, UHM_FILLER_TYPES, UHM_LABELS_FILE, parseUhmLabels, uhmResultFromWindows, type UhmCoverage, type UhmFillerType, type UhmLabelsParseResult, type UhmResult, type UhmResultInput, type UhmSpan, type UhmWindowRun, } from './frames.ts';
|
|
23
|
+
export { createProviderFromRecipe, type ProviderFactoryOptions } from './provider-factory.ts';
|
|
24
|
+
export { OnnxSession, createNodeOnnxLoader, onnxLayer, selectExecutionProvider, type OnnxBackend, type OnnxExecutionProvider, type OnnxFeed, type OnnxLayerOptions, type OnnxLoadOptions, type OnnxLoadedSession, type OnnxOutputData, type OnnxSessionApi, type OnnxSessionLoader, type OnnxTensor, type ProviderSelection, } from './runtime.ts';
|
|
25
|
+
export { UHM_WAVEFORM_PROCESSOR, type UhmBinding } from './uhm-processor.ts';
|
|
26
|
+
export { UHM_FRAME_MS, UHM_FRAME_SAMPLES, UHM_HOP_SAMPLES, UHM_OVERLAP_SAMPLES, UHM_SAMPLE_RATE, UHM_WINDOW_SAMPLES, decodeWav, resampleLinear, windowsOf, type AudioWindow, type WavAudio, type WavDecodeResult, type WindowGeometry, } from './wav.ts';
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC9F,OAAO,EAAE,oBAAoB,EAAE,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAC9E,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,UAAU,EACV,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,2BAA2B,EAC3B,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,cAAc,EACd,YAAY,EACZ,yBAAyB,EACzB,wBAAwB,EACxB,eAAe,EACf,YAAY,EACZ,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,aAAa,GACnB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,OAAO,EACZ,KAAK,YAAY,GAClB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,wBAAwB,EAAE,KAAK,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAC7F,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,SAAS,EACT,uBAAuB,EACvB,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAC1B,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,iBAAiB,GACvB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,sBAAsB,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC5E,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,SAAS,EACT,cAAc,EACd,SAAS,EACT,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,cAAc,GACpB,MAAM,UAAU,CAAA"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@try-works/tool-mode-runtime-onnx` — the ONNX Runtime engine for the local model
|
|
3
|
+
* runtime (Phase 3).
|
|
4
|
+
*
|
|
5
|
+
* Public surface:
|
|
6
|
+
* - `OnnxSession` / `onnxLayer` / `createNodeOnnxLoader` — the Effect service over one
|
|
7
|
+
* onnxruntime-node session, with execution-provider negotiation.
|
|
8
|
+
* - `createProviderFromRecipe` — the factory a code-free model recipe names. This build
|
|
9
|
+
* implements two processors:
|
|
10
|
+
* - `uhm/waveform-v1`: filler-word detection (WAV in, filler spans out);
|
|
11
|
+
* - `clear/stft-v1`: DeepFilterNet3 enhancement (WAV in, enhanced base64 WAV out, bound
|
|
12
|
+
* by the host result budget).
|
|
13
|
+
* - the uhm and clear building blocks the processors are made of, exported so a later
|
|
14
|
+
* processor can reuse them (the clear DSP is a published contract, not an internal).
|
|
15
|
+
* - `InferenceFailed` / `InvalidInput` / `RuntimeUnavailable` — the typed failures.
|
|
16
|
+
*
|
|
17
|
+
* @module @try-works/tool-mode-runtime-onnx
|
|
18
|
+
*/
|
|
19
|
+
export { InferenceFailed, InvalidInput, RuntimeUnavailable, describeCause } from "./errors.js";
|
|
20
|
+
export { CLEAR_STFT_PROCESSOR } from "./clear-processor.js";
|
|
21
|
+
export { CLEAR_CHUNK_FRAMES, CLEAR_ERB_WIDTHS, CLEAR_FFT_SIZE, CLEAR_HOP_SIZE, CLEAR_LOOKAHEAD, CLEAR_MAX_GAIN_DB, CLEAR_N_DF, CLEAR_N_ERB, CLEAR_N_FREQ, CLEAR_NORM_ALPHA, CLEAR_OUTPUT_ENVELOPE_BYTES, CLEAR_PEAK_CEILING_DBTP, CLEAR_SAMPLE_RATE, CLEAR_TARGET_LUFS, CLEAR_WAV_HEADER_BYTES, ClearStft, clearChunkInputs, clearFeatures, encodePcm16Wav, integratedLufs, limitInPlace, maxSamplesForResultBudget, normalizeLoudnessInPlace, scatterEnhanced, vorbisWindow, } from "./clear-dsp.js";
|
|
22
|
+
export { UHM_CLASS_COUNT, UHM_FILLER_THRESHOLD, UHM_FILLER_TYPES, UHM_LABELS_FILE, parseUhmLabels, uhmResultFromWindows, } from "./frames.js";
|
|
23
|
+
export { createProviderFromRecipe } from "./provider-factory.js";
|
|
24
|
+
export { OnnxSession, createNodeOnnxLoader, onnxLayer, selectExecutionProvider, } from "./runtime.js";
|
|
25
|
+
export { UHM_WAVEFORM_PROCESSOR } from "./uhm-processor.js";
|
|
26
|
+
export { UHM_FRAME_MS, UHM_FRAME_SAMPLES, UHM_HOP_SAMPLES, UHM_OVERLAP_SAMPLES, UHM_SAMPLE_RATE, UHM_WINDOW_SAMPLES, decodeWav, resampleLinear, windowsOf, } from "./wav.js";
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The processor seam between the shared provider lifecycle and one model's pipeline.
|
|
3
|
+
*
|
|
4
|
+
* A provider is the same machine for every model: resolve the artifact, build the session,
|
|
5
|
+
* validate the graph, relay abort/timeout, and dispose. What differs is the DESCRIPTOR and
|
|
6
|
+
* the pipeline. That difference is a `ProcessorDefinition`: a typed sidecar (uhm's labels,
|
|
7
|
+
* nothing for clear), a graph binding, a sample rate, and one invoke effect.
|
|
8
|
+
*
|
|
9
|
+
* Keeping the shared half here is what makes the second processor a pipeline rather than a
|
|
10
|
+
* second copy of the lifecycle.
|
|
11
|
+
*
|
|
12
|
+
* @module processor
|
|
13
|
+
*/
|
|
14
|
+
import { Effect } from 'effect';
|
|
15
|
+
import type { InvocationContextV1, JsonObject } from '@try-works/tool-mode-extension-sdk';
|
|
16
|
+
import type { ModelRuntimeRecipe } from '@try-works/tool-mode-runtime-recipes';
|
|
17
|
+
import { InvalidInput, type InferenceFailed } from './errors.ts';
|
|
18
|
+
import type { OnnxSessionApi } from './runtime.ts';
|
|
19
|
+
/** The decoded audio handed to a processor. */
|
|
20
|
+
export interface ProcessorAudio {
|
|
21
|
+
/** Mono samples at the processor's sample rate. */
|
|
22
|
+
readonly samples: Float32Array;
|
|
23
|
+
/** Duration of the ORIGINAL file in seconds, before resampling. */
|
|
24
|
+
readonly sourceDurationSeconds: number;
|
|
25
|
+
}
|
|
26
|
+
/** Everything one processor invocation needs. */
|
|
27
|
+
export interface ProcessorInvokeRequest<Sidecar, Binding> {
|
|
28
|
+
/** The loaded engine session. */
|
|
29
|
+
readonly engine: OnnxSessionApi;
|
|
30
|
+
/** The sidecar documents loaded beside the artifact. */
|
|
31
|
+
readonly sidecar: Sidecar;
|
|
32
|
+
/** The graph binding proved at load time. */
|
|
33
|
+
readonly binding: Binding;
|
|
34
|
+
readonly recipe: ModelRuntimeRecipe;
|
|
35
|
+
readonly input: Readonly<JsonObject>;
|
|
36
|
+
readonly context: InvocationContextV1;
|
|
37
|
+
readonly audio: ProcessorAudio;
|
|
38
|
+
}
|
|
39
|
+
/** What a processor contributes to the shared provider. */
|
|
40
|
+
export interface ProcessorDefinition<Sidecar, Binding> {
|
|
41
|
+
/** The recipe's `processor.id` this definition implements. */
|
|
42
|
+
readonly id: string;
|
|
43
|
+
/** The rate the shared pipeline resamples the input to. */
|
|
44
|
+
readonly sampleRate: number;
|
|
45
|
+
/** Load the processor's sidecar documents from the prepared asset directory. */
|
|
46
|
+
loadSidecar: (directory: string) => Promise<Sidecar>;
|
|
47
|
+
/** Prove the loaded graph exposes the tensors the processor needs. */
|
|
48
|
+
bindGraph: (names: {
|
|
49
|
+
readonly inputs: readonly string[];
|
|
50
|
+
readonly outputs: readonly string[];
|
|
51
|
+
}) => {
|
|
52
|
+
readonly ok: true;
|
|
53
|
+
readonly value: Binding;
|
|
54
|
+
} | {
|
|
55
|
+
readonly ok: false;
|
|
56
|
+
readonly reason: string;
|
|
57
|
+
};
|
|
58
|
+
/** Run one invocation. */
|
|
59
|
+
invoke: (request: ProcessorInvokeRequest<Sidecar, Binding>) => Effect.Effect<JsonObject, InvalidInput | InferenceFailed>;
|
|
60
|
+
}
|
|
61
|
+
/** Read the recipe's audio descriptor: a closed key set and a non-empty path. */
|
|
62
|
+
export declare function parseAudioPath(input: Readonly<JsonObject>, recipe: ModelRuntimeRecipe): Effect.Effect<string, InvalidInput>;
|
|
63
|
+
/** Resolve the caller-supplied path against the invocation grants. */
|
|
64
|
+
export declare function resolveAudioPath(context: InvocationContextV1, candidate: string): Effect.Effect<string, InvalidInput>;
|
|
65
|
+
/** Read the audio bytes from the resolved path. */
|
|
66
|
+
export declare function readAudioBytes(audioPath: string): Effect.Effect<Uint8Array, InvalidInput>;
|
|
67
|
+
/**
|
|
68
|
+
* Decode a WAV, down-mix and resample it to the processor's rate.
|
|
69
|
+
*
|
|
70
|
+
* The source duration is carried separately because coverage reports the ORIGINAL file
|
|
71
|
+
* length, not the resampled sample count (which differs by a rounding sample).
|
|
72
|
+
*/
|
|
73
|
+
export declare function prepareSamples(bytes: Uint8Array, sampleRate: number): Effect.Effect<ProcessorAudio, InvalidInput>;
|
|
74
|
+
//# sourceMappingURL=processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processor.d.ts","sourceRoot":"","sources":["../src/processor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAYH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAA;AACzF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAA;AAE9E,OAAO,EAAE,YAAY,EAAE,KAAK,eAAe,EAAiB,MAAM,aAAa,CAAA;AAC/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAMlD,+CAA+C;AAC/C,MAAM,WAAW,cAAc;IAC7B,mDAAmD;IACnD,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAA;IAC9B,mEAAmE;IACnE,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAA;CACvC;AAED,iDAAiD;AACjD,MAAM,WAAW,sBAAsB,CAAC,OAAO,EAAE,OAAO;IACtD,iCAAiC;IACjC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAA;IAC/B,wDAAwD;IACxD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,6CAA6C;IAC7C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAA;IACnC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAA;IACpC,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAA;IACrC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAA;CAC/B;AAED,2DAA2D;AAC3D,MAAM,WAAW,mBAAmB,CAAC,OAAO,EAAE,OAAO;IACnD,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,2DAA2D;IAC3D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,gFAAgF;IAChF,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;IACpD,sEAAsE;IACtE,SAAS,EAAE,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,KAC1F;QAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;KAAE,GAC9C;QAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;IACnD,0BAA0B;IAC1B,MAAM,EAAE,CAAC,OAAO,EAAE,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,YAAY,GAAG,eAAe,CAAC,CAAA;CACzH;AAED,iFAAiF;AACjF,wBAAgB,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAwB3H;AAED,sEAAsE;AACtE,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAMrH;AAED,mDAAmD;AACnD,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,CAMzF;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,YAAY,CAAC,CAcjH"}
|
package/lib/processor.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The processor seam between the shared provider lifecycle and one model's pipeline.
|
|
3
|
+
*
|
|
4
|
+
* A provider is the same machine for every model: resolve the artifact, build the session,
|
|
5
|
+
* validate the graph, relay abort/timeout, and dispose. What differs is the DESCRIPTOR and
|
|
6
|
+
* the pipeline. That difference is a `ProcessorDefinition`: a typed sidecar (uhm's labels,
|
|
7
|
+
* nothing for clear), a graph binding, a sample rate, and one invoke effect.
|
|
8
|
+
*
|
|
9
|
+
* Keeping the shared half here is what makes the second processor a pipeline rather than a
|
|
10
|
+
* second copy of the lifecycle.
|
|
11
|
+
*
|
|
12
|
+
* @module processor
|
|
13
|
+
*/
|
|
14
|
+
/*
|
|
15
|
+
* The descriptor arrives from the host as JSON (`Readonly<JsonObject>`) and its shape is
|
|
16
|
+
* proven at run time before any audio is touched. The generic anti-slop rules assume an
|
|
17
|
+
* already-typed caller, so the run-time narrowing is the implementation and is disabled
|
|
18
|
+
* for this boundary only.
|
|
19
|
+
*/
|
|
20
|
+
/* oxlint-disable anti-slop/no-runtime-typeof */
|
|
21
|
+
import { readFile } from 'node:fs/promises';
|
|
22
|
+
import { Effect } from 'effect';
|
|
23
|
+
import { InvalidInput, describeCause } from "./errors.js";
|
|
24
|
+
import { decodeWav, resampleLinear } from "./wav.js";
|
|
25
|
+
/** The only input key every processor accepts: a caller-granted path to a WAV file. */
|
|
26
|
+
const AUDIO_PATH_KEYS = new Set(['audio_path']);
|
|
27
|
+
/** Read the recipe's audio descriptor: a closed key set and a non-empty path. */
|
|
28
|
+
export function parseAudioPath(input, recipe) {
|
|
29
|
+
return Effect.suspend(() => {
|
|
30
|
+
const bytes = Buffer.byteLength(JSON.stringify(input) ?? '', 'utf8');
|
|
31
|
+
if (bytes > recipe.limits.maxInputBytes) {
|
|
32
|
+
return Effect.fail(new InvalidInput({
|
|
33
|
+
field: 'input',
|
|
34
|
+
message: 'the input is ' + String(bytes) + ' bytes, over the ' + String(recipe.limits.maxInputBytes) + '-byte input limit',
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
for (const key of Object.keys(input)) {
|
|
38
|
+
if (!AUDIO_PATH_KEYS.has(key)) {
|
|
39
|
+
return Effect.fail(new InvalidInput({ field: key, message: 'the input accepts only audio_path; received ' + JSON.stringify(key) }));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const audioPath = input['audio_path'];
|
|
43
|
+
if (typeof audioPath !== 'string' || audioPath.length === 0) {
|
|
44
|
+
return Effect.fail(new InvalidInput({ field: 'audio_path', message: 'audio_path must be a non-empty string' }));
|
|
45
|
+
}
|
|
46
|
+
return Effect.succeed(audioPath);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/** Resolve the caller-supplied path against the invocation grants. */
|
|
50
|
+
export function resolveAudioPath(context, candidate) {
|
|
51
|
+
return Effect.try({
|
|
52
|
+
try: () => context.resolvePath(candidate),
|
|
53
|
+
catch: (cause) => new InvalidInput({ field: 'audio_path', message: 'the audio path is not authorized: ' + describeCause(cause) }),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/** Read the audio bytes from the resolved path. */
|
|
57
|
+
export function readAudioBytes(audioPath) {
|
|
58
|
+
return Effect.tryPromise({
|
|
59
|
+
try: async () => new Uint8Array(await readFile(audioPath)),
|
|
60
|
+
catch: (cause) => new InvalidInput({ field: 'audio_path', message: 'the audio file cannot be read: ' + describeCause(cause) }),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Decode a WAV, down-mix and resample it to the processor's rate.
|
|
65
|
+
*
|
|
66
|
+
* The source duration is carried separately because coverage reports the ORIGINAL file
|
|
67
|
+
* length, not the resampled sample count (which differs by a rounding sample).
|
|
68
|
+
*/
|
|
69
|
+
export function prepareSamples(bytes, sampleRate) {
|
|
70
|
+
return Effect.suspend(() => {
|
|
71
|
+
const decoded = decodeWav(bytes);
|
|
72
|
+
if (!decoded.ok) {
|
|
73
|
+
return Effect.fail(new InvalidInput({ field: 'audio_path', message: 'the audio cannot be decoded: ' + decoded.reason }));
|
|
74
|
+
}
|
|
75
|
+
const samples = resampleLinear(decoded.audio.samples, decoded.audio.sampleRate, sampleRate);
|
|
76
|
+
return Effect.succeed({
|
|
77
|
+
samples,
|
|
78
|
+
sourceDurationSeconds: decoded.audio.samples.length / decoded.audio.sampleRate,
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=processor.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The declarative provider factory for ONNX (Phase 3).
|
|
3
|
+
*
|
|
4
|
+
* A code-free package names this engine in its recipe, and the host — which declares no
|
|
5
|
+
* engine dependency (AT-25) — calls the factory with the parsed recipe and the host-verified
|
|
6
|
+
* asset map. The factory owns the engine and the processor; the recipe supplies the
|
|
7
|
+
* artifact location, the limits and the tool schemas.
|
|
8
|
+
*
|
|
9
|
+
* ONE LIFECYCLE, TWO PIPELINES. The state machine below is shared by every processor:
|
|
10
|
+
* resolve the artifact, build one ManagedRuntime, force it so a broken deployment fails at
|
|
11
|
+
* load time, bind the graph's tensor names, then run one invoke per call under the
|
|
12
|
+
* recipe's timeout. Processors contribute only their descriptor, sidecar, graph binding and
|
|
13
|
+
* pipeline (`uhm/waveform-v1`, `clear/stft-v1`).
|
|
14
|
+
*
|
|
15
|
+
* THE SDK BOUNDARY IS PROMISE-BASED, THE ENGINE IS EFFECT-BASED. This module keeps that
|
|
16
|
+
* mismatch in one place.
|
|
17
|
+
*
|
|
18
|
+
* TYPED FAILURES: internally every failure is InvalidInput, RuntimeUnavailable or
|
|
19
|
+
* InferenceFailed. The SDK declares Promise methods, and a Schema.TaggedError carries an
|
|
20
|
+
* EMPTY Error.message, so the boundary throws a readable Error whose cause is the typed
|
|
21
|
+
* value. The typed error is still inspectable (error.cause) while a host log is not blank.
|
|
22
|
+
*
|
|
23
|
+
* @module provider-factory
|
|
24
|
+
*/
|
|
25
|
+
import type { ModelProviderV1, PreparedAssetMapV1 } from '@try-works/tool-mode-extension-sdk';
|
|
26
|
+
import type { ModelRuntimeRecipe } from '@try-works/tool-mode-runtime-recipes';
|
|
27
|
+
import { type OnnxSessionLoader } from './runtime.ts';
|
|
28
|
+
/** Test seams; production callers omit the options object. */
|
|
29
|
+
export interface ProviderFactoryOptions {
|
|
30
|
+
/** An injected engine loader, so the unit tests never load the native binding. */
|
|
31
|
+
readonly loader?: OnnxSessionLoader;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Build the SDK provider for one validated, code-free model-runtime recipe.
|
|
35
|
+
*
|
|
36
|
+
* Creation is lightweight (EXT-19): it validates what can be validated statically and reads
|
|
37
|
+
* nothing. Assets are resolved at load() time, preferring the map the SDK hands to load()
|
|
38
|
+
* over the map captured at creation, because the host may build the factory before a
|
|
39
|
+
* preparation completes.
|
|
40
|
+
*
|
|
41
|
+
* @param recipe - the parsed, frozen model-runtime recipe.
|
|
42
|
+
* @param assets - the host-verified asset map captured at creation.
|
|
43
|
+
* @param options - test seams (a fake engine loader); production callers omit it.
|
|
44
|
+
* @returns the SDK's Promise-based provider.
|
|
45
|
+
*/
|
|
46
|
+
export declare function createProviderFromRecipe(recipe: ModelRuntimeRecipe, assets: Readonly<PreparedAssetMapV1>, options?: ProviderFactoryOptions): ModelProviderV1;
|
|
47
|
+
//# sourceMappingURL=provider-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-factory.d.ts","sourceRoot":"","sources":["../src/provider-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAOH,OAAO,KAAK,EAGV,eAAe,EACf,kBAAkB,EAEnB,MAAM,oCAAoC,CAAA;AAC3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAA;AAK9E,OAAO,EAA+C,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAKlG,8DAA8D;AAC9D,MAAM,WAAW,sBAAsB;IACrC,kFAAkF;IAClF,QAAQ,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAA;CACpC;AAqPD;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,kBAAkB,EAC1B,MAAM,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EACpC,OAAO,GAAE,sBAA2B,GACnC,eAAe,CAkBjB"}
|