Run Parakeet TDT in the inference worker via parakeet.js on the shared onnxruntime-web
Adds parakeet.js 1.4.4 (MIT) as a devDependency bundled into the worker only; a build plugin keeps its own onnxruntime-web copy out of the bundle. Includes an opt-in real-model test (PARAKEET_REAL=1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c5a57cd33a
commit
708fae5778
10 files changed
+485
-7
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { join } from "node:path";
|
||||
import { ortAliasPlugin } from "../scripts/ortAlias";
|
||||
|
||||
// D-WS7a: the Parakeet path must not bring a second onnxruntime into the
|
||||
// inference worker. parakeet.js depends on its own onnxruntime-web (1.24.1);
|
||||
// the app runs the one Transformers.js pins. Unminified bundles carry a
|
||||
// `// node_modules/<path>` comment per bundled module, so count runtimes.
|
||||
|
||||
const WORKER = join(import.meta.dir, "../src/worker/inference.worker.ts");
|
||||
|
||||
async function bundledRuntimes(plugins: Bun.BunPlugin[]): Promise<string[]> {
|
||||
const build = await Bun.build({ entrypoints: [WORKER], target: "browser", format: "esm", plugins });
|
||||
expect(build.success).toBe(true);
|
||||
const code = await build.outputs[0]!.text();
|
||||
return [...code.matchAll(/^\/\/ (node_modules\/\S*onnxruntime-web\/dist\/\S+)$/gm)].map((m) => m[1]!);
|
||||
}
|
||||
|
||||
describe("inference worker bundle", () => {
|
||||
test("with the alias plugin it holds only the Transformers.js onnxruntime", async () => {
|
||||
expect(await bundledRuntimes([ortAliasPlugin])).toEqual([
|
||||
"node_modules/onnxruntime-web/dist/ort.webgpu.bundle.min.mjs",
|
||||
]);
|
||||
});
|
||||
|
||||
test("without it, parakeet.js's own runtime would be bundled too (the plugin is load-bearing)", async () => {
|
||||
const runtimes = await bundledRuntimes([]);
|
||||
expect(runtimes).toHaveLength(2);
|
||||
expect(runtimes.some((path) => path.includes("parakeet.js/node_modules/"))).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user