-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-onnx-job.cjs
More file actions
30 lines (21 loc) · 990 Bytes
/
test-onnx-job.cjs
File metadata and controls
30 lines (21 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const dcp = require('dcp-client').initSync();
const fs = require("fs")
const test_work_function = fs.readFileSync(__dirname+"/dist/workfunction.js", "utf-8")
const wavFile = fs.readFileSync(__dirname+"/jfk.wav")
async function main() {
const job = dcp.compute.for([
1,
], test_work_function, [new Uint8Array(wavFile)])
job.requirements.environment = { webgpu: true }
job.requires('onnxruntime-dcp/dcp-wasm.js');
job.requires('onnxruntime-dcp/dcp-ort.js');
job.on('readystatechange', state => console.log(`State: ${state}`))
job.on('accepted', accepted => console.log(` Job ID: ${job.id}\n Job accepted, awaiting results...`))
job.on('result', result => console.log(` ✓ result: ${result.sliceNumber}`))
job.on('error', error => console.log(JSON.stringify(error, null,4)))
job.on('console', ev => console.dir(ev, {depth:Infinity}))
const results = await job.exec();
console.log(results)
console.log('done')
}
main()