@remotion/install-whisper-cpp 4.0.115

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/LICENSE.md ADDED
@@ -0,0 +1,45 @@
1
+ # Remotion License
2
+
3
+ Depending on the type of your legal entity, you are granted permission to use Remotion for your project. Individuals and small companies are allowed to use Remotion to create videos for free (even commercial), while a company license is required for for-profit organizations of a certain size. This two-tier system was designed to ensure funding for this project while still allowing the source code to be available and the program to be free for most. Read below for the exact terms of use.
4
+
5
+ - [Free license](#free-license)
6
+ - [Company license](#company-license)
7
+
8
+ ## Free license
9
+
10
+ Copyright © 2024 [Remotion](https://www.remotion.dev)
11
+
12
+ ### Eligibility
13
+
14
+ You are eligible to use Remotion for free if you are:
15
+
16
+ - an individual
17
+ - a for-profit organization with up to 3 employees
18
+ - a non-profit or not-for-profit organization
19
+ - evaluating whether Remotion is a good fit, and are not yet using it in a commercial way
20
+
21
+ ### Allowed use cases
22
+
23
+ Permission is hereby granted, free of charge, to any person eligible for the "Free license", to use the software non-commercially or commercially for the purpose of creating videos and images and to modify the software to their own liking, for the purpose of fulfilling their custom use case or to contribute bug fixes or improvements back to Remotion.
24
+
25
+ ### Disallowed use cases
26
+
27
+ It is not allowed to copy or modify Remotion code for the purpose of selling, renting, licensing, relicensing, or sublicensing your own derivate of Remotion.
28
+
29
+ ### Warranty notice
30
+
31
+ The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non-infringement. In no event shall the author or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.
32
+
33
+ ### Support
34
+
35
+ Support is provided on a best-we-can-do basis via GitHub Issues and Discord.
36
+
37
+ ## Company license
38
+
39
+ You are required to obtain a company license to use Remotion if you are not within the group of entities eligible for a free license. This license will enable you to use Remotion for the allowed use cases specified in the free license, and give you access to prioritized support (read the [Support Policy](https://www.remotion.dev/docs/support)).
40
+
41
+ Visit [remotion.pro](https://www.remotion.pro/license) for pricing and to buy a license.
42
+
43
+ ### FAQs
44
+
45
+ Are you not sure whether you need a company license because of an edge case? Here are some [frequently asked questions](https://www.remotion.pro/faq).
@@ -0,0 +1,11 @@
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 {};
@@ -0,0 +1,89 @@
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;
@@ -0,0 +1,12 @@
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 type OnProgress = (downloadedBytes: number, totalBytes: number) => void;
4
+ export declare const downloadWhisperModel: ({ model, folder, printOutput, onProgress, }: {
5
+ model: WhisperModel;
6
+ folder: string;
7
+ printOutput?: boolean | undefined;
8
+ onProgress?: OnProgress | undefined;
9
+ }) => Promise<{
10
+ alreadyExisted: boolean;
11
+ }>;
12
+ export {};
@@ -0,0 +1,89 @@
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 fs_1 = __importStar(require("fs"));
31
+ const node_stream_1 = require("node:stream");
32
+ const promises_1 = require("node:stream/promises");
33
+ const path_1 = __importDefault(require("path"));
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;
@@ -0,0 +1,2 @@
1
+ export { downloadWhisperModel, OnProgress, WhisperModel, } from './download-whisper-model';
2
+ export { installWhisperCpp } from './install-whisper-cpp';
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.installWhisperCpp = exports.downloadWhisperModel = void 0;
4
+ var download_whisper_model_1 = require("./download-whisper-model");
5
+ Object.defineProperty(exports, "downloadWhisperModel", { enumerable: true, get: function () { return download_whisper_model_1.downloadWhisperModel; } });
6
+ var install_whisper_cpp_1 = require("./install-whisper-cpp");
7
+ Object.defineProperty(exports, "installWhisperCpp", { enumerable: true, get: function () { return install_whisper_cpp_1.installWhisperCpp; } });
@@ -0,0 +1,7 @@
1
+ export declare const installWhisperCpp: ({ version, to, printOutput, }: {
2
+ version: string;
3
+ to: string;
4
+ printOutput?: boolean | undefined;
5
+ }) => Promise<{
6
+ alreadyExisted: boolean;
7
+ }>;
@@ -0,0 +1,81 @@
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.installWhisperCpp = 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 installWhisperCpp = 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.installWhisperCpp = installWhisperCpp;
@@ -0,0 +1,7 @@
1
+ export declare const installWhisper: ({ version, to, printOutput, }: {
2
+ version: string;
3
+ to: string;
4
+ printOutput?: boolean | undefined;
5
+ }) => Promise<{
6
+ alreadyExisted: boolean;
7
+ }>;
@@ -0,0 +1,81 @@
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;
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@remotion/install-whisper-cpp",
3
+ "version": "4.0.115",
4
+ "description": "Install helper for Whisper.cpp",
5
+ "main": "dist/index.js",
6
+ "sideEffects": false,
7
+ "repository": {
8
+ "url": "https://github.com/remotion-dev/remotion"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/remotion-dev/remotion/issues"
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "author": "Jonny Burger <jonny@remotion.dev>",
17
+ "license": "SEE LICENSE IN LICENSE.md",
18
+ "dependencies": {},
19
+ "peerDependencies": {
20
+ "react": ">=16.8.0",
21
+ "react-dom": ">=16.8.0"
22
+ },
23
+ "devDependencies": {
24
+ "@jonny/eslint-config": "3.0.276",
25
+ "@types/node": "18.14.6",
26
+ "eslint": "8.42.0",
27
+ "eslint-plugin-10x": "1.5.2",
28
+ "eslint-plugin-react": "7.32.2",
29
+ "eslint-plugin-react-hooks": "4.4.0",
30
+ "prettier": "3.1.1",
31
+ "prettier-plugin-organize-imports": "3.2.4",
32
+ "vitest": "0.31.1"
33
+ },
34
+ "keywords": [
35
+ "remotion",
36
+ "openai",
37
+ "whisper"
38
+ ],
39
+ "publishConfig": {
40
+ "access": "public"
41
+ },
42
+ "scripts": {
43
+ "formatting": "prettier src --check",
44
+ "lint": "eslint src --ext ts,tsx",
45
+ "build": "tsc -d",
46
+ "watch": "tsc -w"
47
+ }
48
+ }