Files
bookorbit/workers/read-aloud/src/probe.ts
T
neon 992224f2e8 feat(books): add read-aloud generation
Generate a synced read-aloud EPUB from a book's EPUB and audiobook through an
optional STAlign worker (Docker on CPU, or native with MLX on Apple Silicon),
with review, re-sync, replace in place, restart recovery and live progress on
the Files tab. Book details also stack the ebook and audiobook covers when
both exist. See docs/READ_ALOUD.md.
2026-10-21 23:44:37 +00:00

22 lines
844 B
TypeScript

import { InferenceSession, Tensor } from "onnxruntime-node";
const [device, modelPath] = process.argv.slice(2);
if (!device || !modelPath) {
process.stderr.write("usage: probe.js <device> <model.onnx>\n");
process.exit(2);
}
try {
const session = await InferenceSession.create(modelPath, { executionProviders: [device] });
const input = new Tensor("float32", Float32Array.from([1.5]), [1]);
const output = await session.run({ x: input });
const value = (output["y"]?.data as Float32Array | undefined)?.[0];
await session.release();
if (value !== 1.5) throw new Error(`probe model returned ${String(value)} instead of 1.5`);
process.stdout.write("ok\n");
process.exit(0);
} catch (error) {
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`.replace(/\n(?=.)/g, " "));
process.exit(1);
}