@drakulavich/parakeet-cli 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/models.ts +42 -11
package/package.json
CHANGED
package/src/models.ts
CHANGED
|
@@ -53,7 +53,7 @@ export async function downloadModel(noCache = false, modelDir?: string): Promise
|
|
|
53
53
|
const dir = modelDir ?? getModelDir();
|
|
54
54
|
|
|
55
55
|
if (!noCache && isModelCached(dir)) {
|
|
56
|
-
console.
|
|
56
|
+
console.log("Model already downloaded.");
|
|
57
57
|
return dir;
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -98,12 +98,19 @@ export async function downloadModel(noCache = false, modelDir?: string): Promise
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
console.
|
|
101
|
+
console.log("Model downloaded successfully.");
|
|
102
102
|
return dir;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
const COREML_BINARY_NAME = "parakeet-coreml-darwin-arm64";
|
|
106
|
+
const GITHUB_REPO = "drakulavich/parakeet-cli";
|
|
107
|
+
|
|
105
108
|
export function getCoreMLDownloadURL(version: string): string {
|
|
106
|
-
return `https://github.com/
|
|
109
|
+
return `https://github.com/${GITHUB_REPO}/releases/download/v${version}/${COREML_BINARY_NAME}`;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function getCoreMLLatestDownloadURL(): string {
|
|
113
|
+
return `https://github.com/${GITHUB_REPO}/releases/latest/download/${COREML_BINARY_NAME}`;
|
|
107
114
|
}
|
|
108
115
|
|
|
109
116
|
export async function downloadCoreML(noCache = false): Promise<string> {
|
|
@@ -111,19 +118,32 @@ export async function downloadCoreML(noCache = false): Promise<string> {
|
|
|
111
118
|
const binPath = getCoreMLBinPath();
|
|
112
119
|
|
|
113
120
|
if (!noCache && existsSync(binPath)) {
|
|
114
|
-
|
|
115
|
-
|
|
121
|
+
// Binary exists — ensure models are also downloaded
|
|
122
|
+
const checkProc = Bun.spawnSync([binPath, "--download-only"], {
|
|
123
|
+
stdout: "pipe",
|
|
124
|
+
stderr: "pipe",
|
|
125
|
+
});
|
|
126
|
+
if (checkProc.exitCode === 0) {
|
|
127
|
+
console.log("CoreML backend already installed.");
|
|
128
|
+
return binPath;
|
|
129
|
+
}
|
|
130
|
+
// Models missing — continue to re-download
|
|
116
131
|
}
|
|
117
132
|
|
|
118
|
-
|
|
119
|
-
const
|
|
120
|
-
|
|
133
|
+
// Try latest release first, fall back to version-specific
|
|
134
|
+
const latestUrl = getCoreMLLatestDownloadURL();
|
|
121
135
|
console.error("Downloading parakeet-coreml binary...");
|
|
122
136
|
|
|
123
|
-
|
|
137
|
+
let res = await fetch(latestUrl, { redirect: "follow" });
|
|
124
138
|
|
|
125
139
|
if (!res.ok) {
|
|
126
|
-
|
|
140
|
+
const pkg = await Bun.file(new URL("../package.json", import.meta.url)).json();
|
|
141
|
+
const versionUrl = getCoreMLDownloadURL(pkg.version);
|
|
142
|
+
res = await fetch(versionUrl, { redirect: "follow" });
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (!res.ok) {
|
|
146
|
+
throw new Error(`Failed to download CoreML binary (HTTP ${res.status}). No release found with ${COREML_BINARY_NAME}.`);
|
|
127
147
|
}
|
|
128
148
|
|
|
129
149
|
mkdirSync(dirname(binPath), { recursive: true });
|
|
@@ -132,6 +152,17 @@ export async function downloadCoreML(noCache = false): Promise<string> {
|
|
|
132
152
|
|
|
133
153
|
chmodSync(binPath, 0o755);
|
|
134
154
|
|
|
135
|
-
|
|
155
|
+
// Download CoreML model files (first transcription would be slow without this)
|
|
156
|
+
console.error("Downloading CoreML models...");
|
|
157
|
+
const downloadProc = Bun.spawnSync([binPath, "--download-only"], {
|
|
158
|
+
stdout: "inherit",
|
|
159
|
+
stderr: "inherit",
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
if (downloadProc.exitCode !== 0) {
|
|
163
|
+
throw new Error("Failed to download CoreML models");
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
console.log("CoreML backend installed successfully.");
|
|
136
167
|
return binPath;
|
|
137
168
|
}
|