@remotion/install-whisper-cpp 4.0.125 → 4.0.127
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/dist/download-model.d.ts +0 -11
- package/dist/download-model.js +0 -89
- package/dist/install-whisper.d.ts +0 -7
- package/dist/install-whisper.js +0 -81
package/package.json
CHANGED
package/dist/download-model.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
declare const models: readonly ["tiny", "tiny.en", "base", "base.en", "small", "small.en", "medium", "medium.en", "large-v1", "large-v2", "large-v3"];
|
|
2
|
-
export type WhisperModel = (typeof models)[number];
|
|
3
|
-
export declare const downloadWhisperModel: ({ model, folder, printOutput, onProgress, }: {
|
|
4
|
-
model: WhisperModel;
|
|
5
|
-
folder: string;
|
|
6
|
-
printOutput?: boolean | undefined;
|
|
7
|
-
onProgress?: ((downloadedBytes: number, totalBytes: number) => void) | undefined;
|
|
8
|
-
}) => Promise<{
|
|
9
|
-
alreadyExisted: boolean;
|
|
10
|
-
}>;
|
|
11
|
-
export {};
|
package/dist/download-model.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.downloadWhisperModel = void 0;
|
|
30
|
-
const path_1 = __importDefault(require("path"));
|
|
31
|
-
const fs_1 = __importStar(require("fs"));
|
|
32
|
-
const promises_1 = require("node:stream/promises");
|
|
33
|
-
const node_stream_1 = require("node:stream");
|
|
34
|
-
const models = [
|
|
35
|
-
"tiny",
|
|
36
|
-
"tiny.en",
|
|
37
|
-
"base",
|
|
38
|
-
"base.en",
|
|
39
|
-
"small",
|
|
40
|
-
"small.en",
|
|
41
|
-
"medium",
|
|
42
|
-
"medium.en",
|
|
43
|
-
"large-v1",
|
|
44
|
-
"large-v2",
|
|
45
|
-
"large-v3",
|
|
46
|
-
];
|
|
47
|
-
const downloadWhisperModel = async ({ model, folder, printOutput = true, onProgress, }) => {
|
|
48
|
-
if (!models.includes(model)) {
|
|
49
|
-
throw new Error(`Invalid whisper model ${model}. Available: ${models.join(", ")}`);
|
|
50
|
-
}
|
|
51
|
-
const filePath = path_1.default.join(folder, `ggml-${model}.bin`);
|
|
52
|
-
if ((0, fs_1.existsSync)(filePath)) {
|
|
53
|
-
if (printOutput) {
|
|
54
|
-
console.log(`Model already exists at ${filePath}`);
|
|
55
|
-
}
|
|
56
|
-
return Promise.resolve({ alreadyExisted: true });
|
|
57
|
-
}
|
|
58
|
-
const baseModelUrl = `https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-${model}.bin`;
|
|
59
|
-
if (printOutput) {
|
|
60
|
-
console.log(`Downloading whisper model ${model} from ${baseModelUrl}`);
|
|
61
|
-
}
|
|
62
|
-
const fileStream = fs_1.default.createWriteStream(filePath);
|
|
63
|
-
const { body, headers } = await fetch(baseModelUrl);
|
|
64
|
-
const contentLength = headers.get("content-length");
|
|
65
|
-
if (body === null) {
|
|
66
|
-
throw new Error("Failed to download whisper model");
|
|
67
|
-
}
|
|
68
|
-
if (contentLength === null) {
|
|
69
|
-
throw new Error("Content-Length header not found");
|
|
70
|
-
}
|
|
71
|
-
let downloaded = 0;
|
|
72
|
-
let lastPrinted = 0;
|
|
73
|
-
const readable = node_stream_1.Readable.fromWeb(body);
|
|
74
|
-
readable.on("data", (chunk) => {
|
|
75
|
-
downloaded += chunk.length;
|
|
76
|
-
if (printOutput) {
|
|
77
|
-
if (downloaded - lastPrinted > 1024 * 1024 * 10) {
|
|
78
|
-
console.log(`Downloaded ${downloaded} of ${contentLength} bytes (${((downloaded / Number(contentLength)) *
|
|
79
|
-
100).toFixed(2)}%)`);
|
|
80
|
-
lastPrinted = downloaded;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
fileStream.write(chunk);
|
|
84
|
-
onProgress === null || onProgress === void 0 ? void 0 : onProgress(downloaded, parseInt(contentLength, 10));
|
|
85
|
-
});
|
|
86
|
-
await (0, promises_1.finished)(readable);
|
|
87
|
-
return { alreadyExisted: false };
|
|
88
|
-
};
|
|
89
|
-
exports.downloadWhisperModel = downloadWhisperModel;
|
package/dist/install-whisper.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.installWhisper = void 0;
|
|
30
|
-
const fs_1 = __importStar(require("fs"));
|
|
31
|
-
const node_child_process_1 = require("node:child_process");
|
|
32
|
-
const node_stream_1 = require("node:stream");
|
|
33
|
-
const promises_1 = require("node:stream/promises");
|
|
34
|
-
const path_1 = __importDefault(require("path"));
|
|
35
|
-
const installForWindows = async ({ version, to, printOutput, }) => {
|
|
36
|
-
const url = `https://github.com/ggerganov/whisper.cpp/releases/download/v${version}/whisper-bin-x64.zip`;
|
|
37
|
-
const filePath = path_1.default.join(process.cwd(), "whisper-bin-x64.zip");
|
|
38
|
-
const fileStream = fs_1.default.createWriteStream(filePath);
|
|
39
|
-
const { body } = await fetch(url);
|
|
40
|
-
if (body === null) {
|
|
41
|
-
throw new Error("Failed to download whisper binary");
|
|
42
|
-
}
|
|
43
|
-
await (0, promises_1.finished)(node_stream_1.Readable.fromWeb(body).pipe(fileStream));
|
|
44
|
-
(0, node_child_process_1.execSync)(`Expand-Archive -Force ${filePath} ${to}`, {
|
|
45
|
-
shell: "powershell",
|
|
46
|
-
stdio: printOutput ? "inherit" : "ignore",
|
|
47
|
-
});
|
|
48
|
-
(0, fs_1.rmSync)(filePath);
|
|
49
|
-
};
|
|
50
|
-
const installWhisperForUnix = ({ version, to, printOutput, }) => {
|
|
51
|
-
const stdio = printOutput ? "inherit" : "ignore";
|
|
52
|
-
(0, node_child_process_1.execSync)(`git clone https://github.com/ggerganov/whisper.cpp.git ${to}`, {
|
|
53
|
-
stdio,
|
|
54
|
-
});
|
|
55
|
-
(0, node_child_process_1.execSync)(`git checkout v${version}`, {
|
|
56
|
-
stdio,
|
|
57
|
-
cwd: to,
|
|
58
|
-
});
|
|
59
|
-
(0, node_child_process_1.execSync)(`make`, {
|
|
60
|
-
cwd: to,
|
|
61
|
-
stdio,
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
const installWhisper = async ({ version, to, printOutput = true, }) => {
|
|
65
|
-
if ((0, fs_1.existsSync)(to)) {
|
|
66
|
-
if (printOutput) {
|
|
67
|
-
console.log(`Whisper already exists at ${to}`);
|
|
68
|
-
}
|
|
69
|
-
return Promise.resolve({ alreadyExisted: true });
|
|
70
|
-
}
|
|
71
|
-
if (process.platform === "darwin" || process.platform === "linux") {
|
|
72
|
-
installWhisperForUnix({ version, to, printOutput });
|
|
73
|
-
return Promise.resolve({ alreadyExisted: false });
|
|
74
|
-
}
|
|
75
|
-
if (process.platform === "win32") {
|
|
76
|
-
await installForWindows({ version, to, printOutput });
|
|
77
|
-
return Promise.resolve({ alreadyExisted: false });
|
|
78
|
-
}
|
|
79
|
-
throw new Error(`Unsupported platform: ${process.platform}`);
|
|
80
|
-
};
|
|
81
|
-
exports.installWhisper = installWhisper;
|