JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html>
<head>
<title>ONNX Runtime JavaScript examples: Quick Start - Web (using script tag)</title>
</head>
<body>
<!-- see also advanced usage of importing ONNX Runtime Web: -->
<!-- https://github.com/microsoft/onnxruntime-inference-examples/tree/main/js/importing_onnxruntime-web -->
<!-- import ONNXRuntime Web from CDN -->
<script src="https://cdn.jsdelivr.net/npm/onnxruntime-web@1.20.1/dist/ort.webgpu.min.js"></script>
<script>
// use an async context to call onnxruntime functions.
async function main() {
try {
// create a new session and load the specific model.
const url = 'https://huggingface.co/onnx-community/WavTokenizer-large-speech-75token_decode/resolve/main/onnx/model_quantized.onnx?download=true';
const session = await ort.InferenceSession.create(url, {
executionProviders: ['webgpu'],
});
const codes = new ort.Tensor(
'int64',
[1,2,3,4,5,6,7,8],
[1, 8],
)
// prepare feeds. use model input names as keys.
const feeds = { codes };
// feed inputs and run
const results = await session.run(feeds);
console.log(results)
} catch (e) {
document.write(`failed to inference ONNX model: ${e}.`);
}
}
main();
</script>
</body>
</html>