Download runtimes/onnxruntime-node/test.mjs from KaleComputer/kale-tts-1-tiny: direct link, hf CLI and curl.
- Browser
- Download file 1.85 kB
-
https://huggingface.co/KaleComputer/kale-tts-1-tiny/resolve/main/runtimes/onnxruntime-node/test.mjs
- Command line
-
hf download hf://KaleComputer/kale-tts-1-tiny/runtimes/onnxruntime-node/test.mjs
-
curl -L -o test.mjs https://huggingface.co/KaleComputer/kale-tts-1-tiny/resolve/main/runtimes/onnxruntime-node/test.mjs
1.85 kB
| // onnxruntime-node + our JS API (release-draft/js/kale-tts.mjs): text in -> WAV, then the shared bench. usage: node test.mjs <nano|tiny> [threads] [voice: name or id, default kenzie] | |
| import { writeFileSync, mkdirSync } from "node:fs"; | |
| const RD = new URL("../../", import.meta.url).pathname, [, , size = "nano", threads = "4", voice = "kenzie"] = process.argv; | |
| // ---- snippet ---------------------------------------------------------------------------------------------------------------- | |
| import * as ort from "onnxruntime-node"; | |
| const { KaleTTS, toWav } = await import(RD + "js/kale-tts.mjs"); | |
| const t0 = performance.now(); | |
| const tts = await KaleTTS.load(`kale-tts-1-${size}`, { ort, threads: Number(threads) }); | |
| const load_s = (performance.now() - t0) / 1000; | |
| const { audio, sampleRate } = await tts.speak("A volcano is a place where very hot, melted rock comes up out of the ground. Most volcanoes are hidden under the sea!", { voice }); | |
| mkdirSync("out", { recursive: true }); writeFileSync(`out/${size}.wav`, toWav(audio, sampleRate)); | |
| // ----------------------------------------------------------------------------------------------------------------------------- | |
| if (tts.ettinTok) { console.log(JSON.stringify({ runtime: "onnxruntime-node", model: `kale-tts-1-${size}`, voice, text_audio_s: +(audio.length / 24000).toFixed(2), bench: "ids-only bench lines are for nano (tiny also needs Ettin word inputs per sentence)" })); process.exit(0); } | |
| const { bench } = await import(RD + "runtimes/_bench/bench.mjs"); const v = await tts._loadVoice(voice); | |
| console.log(JSON.stringify({ runtime: "onnxruntime-node", model: `kale-tts-1-${size}`, ort_node: ort.env.versions.node, node: process.version, threads: +threads, | |
| load_s: +load_s.toFixed(2), text_audio_s: +(audio.length / 24000).toFixed(2), ...(await bench((ids) => tts._render(v, ids))) })); | |