@bevyra/avatar 0.0.0-stage → 0.1.0
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/dist/assets/bevyra-core-Bskcl7l_.js +195 -0
- package/dist/assets/clientOnlyAvatarWorker-C6wTIDwp.js +2119 -0
- package/dist/assets/clientOnlySourceWorker-CNVdGzNy.js +7347 -0
- package/dist/assets/ort.wasm.min-BcBtKW3v.js +1400 -0
- package/dist/assets/ort.webgpu.min-BqBLsdhU.js +1856 -0
- package/dist/assets/rustAvatarWorker-vggdUXxI.js +1702 -0
- package/dist/assets/teacherCorrectorWorker-Deu0CCPs.js +1406 -0
- package/dist/assets/workerHelpers-BkWezgrb.js +31 -0
- package/dist/bevyra-avatar-sdk.js +3367 -0
- package/dist/ort/ort-wasm-simd-threaded.jsep.mjs +136 -0
- package/dist/ort/ort-wasm-simd-threaded.jsep.wasm +0 -0
- package/dist/ort/ort-wasm-simd-threaded.mjs +68 -0
- package/dist/ort/ort-wasm-simd-threaded.wasm +0 -0
- package/dist/runtime/bevyra-core.js +1515 -0
- package/dist/runtime/bevyra-core.wasm +0 -0
- package/dist/runtime/closure_router.onnx +0 -0
- package/dist/runtime/runtime-manifest.json +27 -0
- package/dist/sdk-manifest.json +70 -0
- package/index.d.ts +25 -0
- package/index.js +108 -0
- package/package.json +10 -4
- package/README.md +0 -3
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema": "bevyra-rust-browser-core-v1",
|
|
3
|
+
"bundleFormats": [
|
|
4
|
+
"portable-ort-v2"
|
|
5
|
+
],
|
|
6
|
+
"planner": "self-supervised-whole-sequence-v1",
|
|
7
|
+
"audioFrontend": "clause-encoder-v1",
|
|
8
|
+
"vadQuietFrames": 25,
|
|
9
|
+
"renderer": "m1-aligned-student-v3-feathertalk-crop",
|
|
10
|
+
"predictorContext": "minus4-through-plus4",
|
|
11
|
+
"corrector": "student-corrector-v3",
|
|
12
|
+
"simd128": true,
|
|
13
|
+
"files": {
|
|
14
|
+
"bevyra-core.js": {
|
|
15
|
+
"bytes": 57805,
|
|
16
|
+
"sha256": "244cd722ad3f78958058af8f7d808aa52f7804a2d89dd4ea93e8fd9b35eeb4c6"
|
|
17
|
+
},
|
|
18
|
+
"bevyra-core.wasm": {
|
|
19
|
+
"bytes": 532975,
|
|
20
|
+
"sha256": "ac5b1fed3868650f0a8a94e559c794969a4236586e569b1d2e5669c72a3ac7ec"
|
|
21
|
+
},
|
|
22
|
+
"closure_router.onnx": {
|
|
23
|
+
"bytes": 1469967,
|
|
24
|
+
"sha256": "22ed9153b4f0146f3582ecc31d0f4dc53ce7c3db1d59259b12a3c0139353ca00"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema": "bevyra-browser-sdk-v1",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"entrypoint": "bevyra-avatar-sdk.js",
|
|
5
|
+
"runtime": {
|
|
6
|
+
"bundleFormat": "portable-ort-v2",
|
|
7
|
+
"engine": "rust-wasm-generic-v2",
|
|
8
|
+
"planner": "self-supervised-whole-sequence-v1",
|
|
9
|
+
"modes": [
|
|
10
|
+
"generate",
|
|
11
|
+
"stream"
|
|
12
|
+
],
|
|
13
|
+
"referenceBundleFormat": "portable-ort-v1",
|
|
14
|
+
"ortBridge": "onnxruntime-web-wasm-shape-adapter-v1"
|
|
15
|
+
},
|
|
16
|
+
"files": {
|
|
17
|
+
"assets/bevyra-core-Bskcl7l_.js": {
|
|
18
|
+
"bytes": 716813,
|
|
19
|
+
"sha256": "848eaae8b353583332a7ec27c0c8dbb3cb55abe0ac80c919c841b5f30379cbf6"
|
|
20
|
+
},
|
|
21
|
+
"assets/clientOnlyAvatarWorker-C6wTIDwp.js": {
|
|
22
|
+
"bytes": 91982,
|
|
23
|
+
"sha256": "b5d0d6c26fc36d5d7d594f5d63236b14422f27635b00dd071195941f93a68914"
|
|
24
|
+
},
|
|
25
|
+
"assets/clientOnlySourceWorker-CNVdGzNy.js": {
|
|
26
|
+
"bytes": 282410,
|
|
27
|
+
"sha256": "9f8bb394c2b193cd1a78f95c0bd0e489fa997d0a0134ce52708404dad5f5b820"
|
|
28
|
+
},
|
|
29
|
+
"assets/ort.wasm.min-BcBtKW3v.js": {
|
|
30
|
+
"bytes": 66300,
|
|
31
|
+
"sha256": "1f624450056baaf79753fdfc17db880720ca3d0057457b549ab985fd0c3d800e"
|
|
32
|
+
},
|
|
33
|
+
"assets/ort.webgpu.min-BqBLsdhU.js": {
|
|
34
|
+
"bytes": 87888,
|
|
35
|
+
"sha256": "b6e2626840e43d1b61acaefc8cefc6cf4d25f94fb9e9d6daf9d73ca0e6302c66"
|
|
36
|
+
},
|
|
37
|
+
"assets/rustAvatarWorker-vggdUXxI.js": {
|
|
38
|
+
"bytes": 769783,
|
|
39
|
+
"sha256": "5a138634a176dda3e95fa362faef4b02eee924fbfbb8b7bc633aecf0b2b7ae98"
|
|
40
|
+
},
|
|
41
|
+
"assets/teacherCorrectorWorker-Deu0CCPs.js": {
|
|
42
|
+
"bytes": 66781,
|
|
43
|
+
"sha256": "b74157e983f31fe44726c2d920bece91edb0d89282fdb089b781a4c306b9d4c8"
|
|
44
|
+
},
|
|
45
|
+
"assets/workerHelpers-BkWezgrb.js": {
|
|
46
|
+
"bytes": 948,
|
|
47
|
+
"sha256": "ffaef65e20af7a2db96a19a7c8b405614a70ffcbcdfb73593970c2a62d1152b3"
|
|
48
|
+
},
|
|
49
|
+
"bevyra-avatar-sdk.js": {
|
|
50
|
+
"bytes": 158355,
|
|
51
|
+
"sha256": "6910234b9a31abce935b3e1de17927dabd6e4978ee15604204a92b609bce04bc"
|
|
52
|
+
},
|
|
53
|
+
"ort/ort-wasm-simd-threaded.jsep.mjs": {
|
|
54
|
+
"bytes": 49998,
|
|
55
|
+
"sha256": "c7b70c8003f077c62849e15275d0b1f1d1cf1a6dfc63b967400567c7224bfdbe"
|
|
56
|
+
},
|
|
57
|
+
"ort/ort-wasm-simd-threaded.jsep.wasm": {
|
|
58
|
+
"bytes": 23824254,
|
|
59
|
+
"sha256": "ac0d8f1cfbf2732420ad78a86072b8507253c63885a61c3fd640b3055256d31d"
|
|
60
|
+
},
|
|
61
|
+
"ort/ort-wasm-simd-threaded.mjs": {
|
|
62
|
+
"bytes": 20321,
|
|
63
|
+
"sha256": "90a557d15c02bac4504d95b67f431d8594635ed2a0a62a7f2cd83d090ff91d3e"
|
|
64
|
+
},
|
|
65
|
+
"ort/ort-wasm-simd-threaded.wasm": {
|
|
66
|
+
"bytes": 11905541,
|
|
67
|
+
"sha256": "45eaee27761ad883742a8d4b8fce1538d60ce43b51adf1726fafccc59b8c1a15"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface AvatarOptions {
|
|
2
|
+
avatarId: string;
|
|
3
|
+
canvas: HTMLCanvasElement;
|
|
4
|
+
/** URL to the complete portable_v2 bundle directory in the developer app. */
|
|
5
|
+
bundleBaseUrl: string;
|
|
6
|
+
/** URL to this package's dist directory, copied to the developer's public assets. */
|
|
7
|
+
assetsBaseUrl: string;
|
|
8
|
+
mode?: "stream" | "generate";
|
|
9
|
+
background?: string | Blob | ImageBitmap | HTMLImageElement | null;
|
|
10
|
+
resolution?: "source" | "portrait" | "landscape" | "square" | {width: number; height: number};
|
|
11
|
+
body?: "full" | "half";
|
|
12
|
+
onStage?: (stage: string) => void;
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
}
|
|
15
|
+
export declare class BevyraAvatar {
|
|
16
|
+
static mount(options: AvatarOptions): Promise<BevyraAvatar>;
|
|
17
|
+
writeAudio(pcm: Int16Array, sampleRate: number): Promise<void>;
|
|
18
|
+
endUtterance(): Promise<void>;
|
|
19
|
+
interrupt(): void;
|
|
20
|
+
onSpeechStart(listener: () => void): () => void;
|
|
21
|
+
onSpeechEnd(listener: () => void): () => void;
|
|
22
|
+
speechClock(): { response: number; complete: boolean; receivedSeconds: number; heardSeconds: number } | null;
|
|
23
|
+
close(): void;
|
|
24
|
+
}
|
|
25
|
+
export declare function loadLocalAssets(options: Pick<AvatarOptions, "avatarId" | "bundleBaseUrl" | "assetsBaseUrl" | "signal">): Promise<{bundle: unknown; runtime: unknown}>;
|
package/index.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
const REQUIRED = [
|
|
2
|
+
"manifest.json", "portable-manifest.json", "model.json", "p0.bin", "p1.bin",
|
|
3
|
+
"p2.bin", "p4.bin", "p5.bin", "p6.bin", "p9.bin", "p10.bin",
|
|
4
|
+
"p11.bin", "p12.bin", "p21.bin",
|
|
5
|
+
];
|
|
6
|
+
|
|
7
|
+
function directory(url) {
|
|
8
|
+
return new URL(url.endsWith("/") ? url : `${url}/`, globalThis.location?.href);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async function digest(bytes) {
|
|
12
|
+
return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256", bytes)),
|
|
13
|
+
(value) => value.toString(16).padStart(2, "0")).join("");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function download(url, expected, signal) {
|
|
17
|
+
const response = await fetch(url, { signal });
|
|
18
|
+
if (!response.ok) throw new Error(`Avatar asset request failed (${response.status}): ${url}`);
|
|
19
|
+
const bytes = await response.arrayBuffer();
|
|
20
|
+
if (expected && (bytes.byteLength !== expected.bytes || await digest(bytes) !== expected.sha256.toLowerCase()))
|
|
21
|
+
throw new Error(`Avatar asset integrity check failed: ${url}`);
|
|
22
|
+
return bytes;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function parse(bytes) { return JSON.parse(new TextDecoder().decode(bytes)); }
|
|
26
|
+
|
|
27
|
+
/** Loads a developer-served bundle and verifies every model against its checksum manifest. */
|
|
28
|
+
export async function loadLocalAssets({ avatarId, bundleBaseUrl, assetsBaseUrl, signal }) {
|
|
29
|
+
if (!avatarId || !bundleBaseUrl || !assetsBaseUrl)
|
|
30
|
+
throw new Error("avatarId, bundleBaseUrl and assetsBaseUrl are required");
|
|
31
|
+
const bundleRoot = directory(bundleBaseUrl), assetsRoot = directory(assetsBaseUrl);
|
|
32
|
+
const index = parse(await download(new URL("web-bundle.json", bundleRoot), undefined, signal));
|
|
33
|
+
if (index.format !== "portable-ort-v2" || index.checksums !== "checksums.json")
|
|
34
|
+
throw new Error("Unsupported downloadable avatar bundle");
|
|
35
|
+
const checksumsBytes = await download(new URL("checksums.json", bundleRoot), undefined, signal);
|
|
36
|
+
const checksums = parse(checksumsBytes);
|
|
37
|
+
const files = new Map(), manifests = { "web-bundle.json": index };
|
|
38
|
+
for (const name of REQUIRED) {
|
|
39
|
+
if (!checksums[name]) throw new Error(`Avatar bundle checksum missing: ${name}`);
|
|
40
|
+
const bytes = await download(new URL(name, bundleRoot), checksums[name], signal);
|
|
41
|
+
files.set(name, bytes);
|
|
42
|
+
if (name.endsWith(".json")) manifests[name] = parse(bytes);
|
|
43
|
+
}
|
|
44
|
+
const portable = manifests["portable-manifest.json"];
|
|
45
|
+
for (const [name, required] of [
|
|
46
|
+
["p22.bin", portable?.motionPlannerV2Version === 2],
|
|
47
|
+
["p24.bin", portable?.visualPlannerDescriptorUrl === "p24.bin"],
|
|
48
|
+
["p23.bin", portable?.teacherCorrectorUrl === "p23.bin"],
|
|
49
|
+
]) if (required) {
|
|
50
|
+
if (!checksums[name]) throw new Error(`Avatar bundle checksum missing: ${name}`);
|
|
51
|
+
files.set(name, await download(new URL(name, bundleRoot), checksums[name], signal));
|
|
52
|
+
}
|
|
53
|
+
const runtimeManifest = parse(await download(new URL("runtime/runtime-manifest.json", assetsRoot), undefined, signal));
|
|
54
|
+
if (runtimeManifest.schema !== "bevyra-rust-browser-core-v1") throw new Error("Unsupported avatar runtime");
|
|
55
|
+
const runtimeFiles = {};
|
|
56
|
+
for (const [name, entry] of Object.entries(runtimeManifest.files))
|
|
57
|
+
runtimeFiles[name] = { ...entry, url: new URL(`runtime/${name}`, assetsRoot).href };
|
|
58
|
+
if (!runtimeFiles["bevyra-core.wasm"] || !runtimeFiles["closure_router.onnx"])
|
|
59
|
+
throw new Error("Avatar runtime is incomplete");
|
|
60
|
+
const [coreWasm, closureRouter] = await Promise.all([
|
|
61
|
+
download(runtimeFiles["bevyra-core.wasm"].url, runtimeFiles["bevyra-core.wasm"], signal),
|
|
62
|
+
download(runtimeFiles["closure_router.onnx"].url, runtimeFiles["closure_router.onnx"], signal),
|
|
63
|
+
]);
|
|
64
|
+
const bundleFiles = {};
|
|
65
|
+
for (const [name, entry] of Object.entries(checksums))
|
|
66
|
+
bundleFiles[name] = { ...entry, url: new URL(name, bundleRoot).href };
|
|
67
|
+
const bundleId = await digest(checksumsBytes);
|
|
68
|
+
return {
|
|
69
|
+
bundle: {
|
|
70
|
+
contract: { bundleId, avatarId, format: "portable-ort-v2", expiresAt: "9999-12-31T00:00:00Z",
|
|
71
|
+
entrypoint: "web-bundle.json", files: bundleFiles },
|
|
72
|
+
files, manifests, cache: "miss", bytes: Array.from(files.values()).reduce((n, x) => n + x.byteLength, 0),
|
|
73
|
+
downloadMs: 0, bundleSha256: bundleId,
|
|
74
|
+
},
|
|
75
|
+
runtime: {
|
|
76
|
+
contract: { runtimeId: runtimeManifest.files["bevyra-core.wasm"].sha256, schema: runtimeManifest.schema,
|
|
77
|
+
expiresAt: "9999-12-31T00:00:00Z", capabilities: {
|
|
78
|
+
bundleFormats: runtimeManifest.bundleFormats, planner: runtimeManifest.planner,
|
|
79
|
+
audioFrontend: runtimeManifest.audioFrontend, simd128: runtimeManifest.simd128,
|
|
80
|
+
}, files: runtimeFiles },
|
|
81
|
+
coreWasm, closureRouter, cache: "miss", bytes: coreWasm.byteLength + closureRouter.byteLength, downloadMs: 0,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** A small public facade around the compiled browser renderer. */
|
|
87
|
+
export class BevyraAvatar {
|
|
88
|
+
constructor(sdk) { this.sdk = sdk; }
|
|
89
|
+
static async mount(options) {
|
|
90
|
+
const { BeVyraAvatarSdk } = await import("./dist/bevyra-avatar-sdk.js");
|
|
91
|
+
const sdk = await BeVyraAvatarSdk.create({
|
|
92
|
+
avatarId: options.avatarId, canvas: options.canvas, mode: options.mode || "stream",
|
|
93
|
+
background: options.background, resolution: options.resolution, body: options.body,
|
|
94
|
+
onStage: options.onStage, signal: options.signal, renderer: "device",
|
|
95
|
+
ortWasmPaths: new URL("ort/", directory(options.assetsBaseUrl)).href,
|
|
96
|
+
assetProvider: () => loadLocalAssets(options),
|
|
97
|
+
});
|
|
98
|
+
await sdk.enableAudio();
|
|
99
|
+
return new BevyraAvatar(sdk);
|
|
100
|
+
}
|
|
101
|
+
writeAudio(pcm, sampleRate) { return this.sdk.pushAudio({ pcm, sampleRate }); }
|
|
102
|
+
endUtterance() { return this.sdk.completeTurn(); }
|
|
103
|
+
interrupt() { this.sdk.interrupt(); }
|
|
104
|
+
onSpeechStart(listener) { return this.sdk.onSpeechStart(listener); }
|
|
105
|
+
onSpeechEnd(listener) { return this.sdk.onSpeechEnd(listener); }
|
|
106
|
+
speechClock() { return this.sdk.speechClock(); }
|
|
107
|
+
close() { this.sdk.close(); }
|
|
108
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bevyra/avatar",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
}
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Downloadable on-device BeVyra avatar player for browser applications",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {".": {"types": "./index.d.ts", "default": "./index.js"}},
|
|
7
|
+
"files": ["index.js", "index.d.ts", "dist"],
|
|
8
|
+
"scripts": {"build": "node build.mjs", "test": "node --test test/*.test.mjs", "pack:check": "npm pack --dry-run --json"},
|
|
9
|
+
"engines": {"node": ">=20"},
|
|
10
|
+
"license": "Proprietary",
|
|
11
|
+
"publishConfig": {"access": "public"}
|
|
12
|
+
}
|
package/README.md
DELETED