15 lines
514 B
JavaScript
15 lines
514 B
JavaScript
const assetRoot = '/static/piper-wasm-v1/onnx/';
|
|
|
|
export function createOnnxWasmPaths(origin) {
|
|
const absoluteAssetRoot = new URL(assetRoot, origin).href;
|
|
return absoluteAssetRoot;
|
|
}
|
|
|
|
export function configureOnnxRuntime(onnxRuntime) {
|
|
if (!onnxRuntime?.env?.wasm) throw new TypeError('ONNX Runtime WebAssembly settings are unavailable.');
|
|
// Piper already runs in a worker. Avoid a second worker pool on mobile Safari.
|
|
onnxRuntime.env.wasm.numThreads = 1;
|
|
onnxRuntime.env.wasm.initTimeout = 60000;
|
|
}
|
|
|