// Dev helper — download the Phase 1 CPU whisper model into // %LOCALAPPDATA%\WhispAssist\models. In-product model management (choose size, // download/remove with progress) is Phase 3 (FR-MODEL-1); this script only gets // a dev machine to a working `whisper-rs` baseline quickly. // // Usage: node scripts/download-models.mjs import { createWriteStream, existsSync, mkdirSync } from "node:fs"; import { pipeline } from "node:stream/promises"; import path from "node:path"; const MODEL_URL = "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.en-q5_1.bin"; const MODEL_NAME = "ggml-base.en-q5_1.bin"; const modelsDir = path.join(process.env.LOCALAPPDATA ?? process.cwd(), "WhispAssist", "models"); const dest = path.join(modelsDir, MODEL_NAME); if (existsSync(dest)) { console.log(`Already have ${dest}`); process.exit(0); } mkdirSync(modelsDir, { recursive: true }); console.log(`Downloading ${MODEL_URL} -> ${dest}`); const res = await fetch(MODEL_URL, { redirect: "follow" }); if (!res.ok || !res.body) { console.error(`Download failed: HTTP ${res.status}`); process.exit(1); } const tmp = `${dest}.part`; await pipeline(res.body, createWriteStream(tmp)); const { renameSync } = await import("node:fs"); renameSync(tmp, dest); console.log("Done.");