@drakulavich/parakeet-cli 0.7.1 → 0.7.2
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 +3 -2
- package/src/cli.ts +6 -5
- package/src/coreml-install.ts +4 -3
- package/src/log.ts +9 -0
- package/src/onnx-install.ts +4 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drakulavich/parakeet-cli",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Fast local speech-to-text CLI. CoreML on Apple Silicon, ONNX on CPU. 25 languages.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"typescript": "^6.0.2"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"onnxruntime-node": "^1.24.0"
|
|
56
|
+
"onnxruntime-node": "^1.24.0",
|
|
57
|
+
"picocolors": "^1.1.1"
|
|
57
58
|
}
|
|
58
59
|
}
|
package/src/cli.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { transcribe } from "./lib";
|
|
|
4
4
|
import { downloadModel } from "./onnx-install";
|
|
5
5
|
import { downloadCoreML } from "./coreml-install";
|
|
6
6
|
import { isMacArm64 } from "./coreml";
|
|
7
|
+
import { log } from "./log";
|
|
7
8
|
|
|
8
9
|
async function main(): Promise<void> {
|
|
9
10
|
const args = process.argv.slice(2);
|
|
@@ -24,7 +25,7 @@ async function main(): Promise<void> {
|
|
|
24
25
|
try {
|
|
25
26
|
if (forceCoreML) {
|
|
26
27
|
if (!isMacArm64()) {
|
|
27
|
-
|
|
28
|
+
log.error("CoreML backend is only available on macOS Apple Silicon.");
|
|
28
29
|
process.exit(1);
|
|
29
30
|
}
|
|
30
31
|
await downloadCoreML(noCache);
|
|
@@ -37,7 +38,7 @@ async function main(): Promise<void> {
|
|
|
37
38
|
}
|
|
38
39
|
} catch (err: unknown) {
|
|
39
40
|
const message = err instanceof Error ? err.message : String(err);
|
|
40
|
-
|
|
41
|
+
log.error(message);
|
|
41
42
|
process.exit(1);
|
|
42
43
|
}
|
|
43
44
|
process.exit(0);
|
|
@@ -46,8 +47,8 @@ async function main(): Promise<void> {
|
|
|
46
47
|
const file = positional[0];
|
|
47
48
|
|
|
48
49
|
if (!file) {
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
log.info("Usage: parakeet [--version] <audio_file>");
|
|
51
|
+
log.info(" parakeet install [--coreml | --onnx] [--no-cache]");
|
|
51
52
|
process.exit(1);
|
|
52
53
|
}
|
|
53
54
|
|
|
@@ -56,7 +57,7 @@ async function main(): Promise<void> {
|
|
|
56
57
|
if (text) process.stdout.write(text + "\n");
|
|
57
58
|
} catch (err: unknown) {
|
|
58
59
|
const message = err instanceof Error ? err.message : String(err);
|
|
59
|
-
|
|
60
|
+
log.error(message);
|
|
60
61
|
process.exit(1);
|
|
61
62
|
}
|
|
62
63
|
}
|
package/src/coreml-install.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { join, dirname } from "path";
|
|
|
2
2
|
import { homedir } from "os";
|
|
3
3
|
import { existsSync, mkdirSync, chmodSync } from "fs";
|
|
4
4
|
import { getCoreMLBinPath } from "./coreml";
|
|
5
|
+
import { log } from "./log";
|
|
5
6
|
|
|
6
7
|
const COREML_BINARY_NAME = "parakeet-coreml-darwin-arm64";
|
|
7
8
|
const GITHUB_REPO = "drakulavich/parakeet-cli";
|
|
@@ -226,12 +227,12 @@ export async function downloadCoreML(
|
|
|
226
227
|
const plan = planCoreMLInstall(state, noCache);
|
|
227
228
|
|
|
228
229
|
if (!plan.downloadBinary && !plan.downloadModels) {
|
|
229
|
-
|
|
230
|
+
log.success("CoreML backend already installed.");
|
|
230
231
|
return binPath;
|
|
231
232
|
}
|
|
232
233
|
|
|
233
234
|
if (plan.downloadBinary) {
|
|
234
|
-
|
|
235
|
+
log.progress("Downloading parakeet-coreml binary...");
|
|
235
236
|
const res = await fetchCoreMLBinary();
|
|
236
237
|
mkdirSync(dirname(binPath), { recursive: true });
|
|
237
238
|
await Bun.write(binPath, res);
|
|
@@ -242,6 +243,6 @@ export async function downloadCoreML(
|
|
|
242
243
|
await ensureCoreMLModels(binPath, runner, output);
|
|
243
244
|
}
|
|
244
245
|
|
|
245
|
-
|
|
246
|
+
log.success("CoreML backend installed successfully.");
|
|
246
247
|
return binPath;
|
|
247
248
|
}
|
package/src/log.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import pc from "picocolors";
|
|
2
|
+
|
|
3
|
+
export const log = {
|
|
4
|
+
info: (msg: string) => console.log(msg),
|
|
5
|
+
success: (msg: string) => console.log(pc.green(msg)),
|
|
6
|
+
progress: (msg: string) => console.log(pc.cyan(msg)),
|
|
7
|
+
warn: (msg: string) => console.error(pc.yellow(msg)),
|
|
8
|
+
error: (msg: string) => console.error(pc.red(msg)),
|
|
9
|
+
};
|
package/src/onnx-install.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { join } from "path";
|
|
2
2
|
import { homedir } from "os";
|
|
3
3
|
import { existsSync, mkdirSync } from "fs";
|
|
4
|
+
import { log } from "./log";
|
|
4
5
|
|
|
5
6
|
export const HF_REPO = "istupakov/parakeet-tdt-0.6b-v3-onnx";
|
|
6
7
|
|
|
@@ -48,7 +49,7 @@ export async function downloadModel(noCache = false, modelDir?: string): Promise
|
|
|
48
49
|
const dir = modelDir ?? getModelDir();
|
|
49
50
|
|
|
50
51
|
if (!noCache && isModelCached(dir)) {
|
|
51
|
-
|
|
52
|
+
log.success("Model already downloaded.");
|
|
52
53
|
return dir;
|
|
53
54
|
}
|
|
54
55
|
|
|
@@ -60,7 +61,7 @@ export async function downloadModel(noCache = false, modelDir?: string): Promise
|
|
|
60
61
|
|
|
61
62
|
if (!noCache && existsSync(dest)) continue;
|
|
62
63
|
|
|
63
|
-
|
|
64
|
+
log.progress(`Downloading ${file}...`);
|
|
64
65
|
|
|
65
66
|
let res: Response;
|
|
66
67
|
try {
|
|
@@ -93,6 +94,6 @@ export async function downloadModel(noCache = false, modelDir?: string): Promise
|
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
|
|
97
|
+
log.success("Model downloaded successfully.");
|
|
97
98
|
return dir;
|
|
98
99
|
}
|