Phase 1
This commit is contained in:
+34
-10
@@ -1,12 +1,36 @@
|
||||
// Dev helper (placeholder) — download default models into %LOCALAPPDATA%\WhispAssist\models.
|
||||
// In the app, model download is a Phase 3 in-product flow (FR-MODEL-1) with progress events;
|
||||
// this script is only for setting up a dev machine quickly.
|
||||
// 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.
|
||||
//
|
||||
// Intended models (pin URLs/checksums at implementation time):
|
||||
// - Whisper: base (q5) GGUF for whisper.cpp
|
||||
// - Diarization: pyannote segmentation (ONNX) + ERes2Net speaker embedding (ONNX)
|
||||
//
|
||||
// Usage (once implemented): node scripts/download-models.mjs --set default
|
||||
// Usage: node scripts/download-models.mjs
|
||||
|
||||
console.log("TODO: implement model download (Phase 3). See docs/05-roadmap.md T3.7.");
|
||||
process.exit(0);
|
||||
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.");
|
||||
|
||||
Reference in New Issue
Block a user