@remotion/install-whisper-cpp 4.0.138 → 4.0.139

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.
@@ -28,7 +28,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.downloadWhisperModel = exports.getModelPath = void 0;
30
30
  const fs_1 = __importStar(require("fs"));
31
- const node_stream_1 = require("node:stream");
32
31
  const path_1 = __importDefault(require("path"));
33
32
  const models = [
34
33
  'tiny',
@@ -74,29 +73,40 @@ const downloadWhisperModel = async ({ model, folder, printOutput = true, onProgr
74
73
  const totalFileSize = parseInt(contentLength, 10);
75
74
  let downloaded = 0;
76
75
  let lastPrinted = 0;
77
- const readable = node_stream_1.Readable.fromWeb(body);
78
- await new Promise((resolve, reject) => {
79
- readable.on('error', (err) => {
80
- reject(err);
81
- });
82
- readable.on('data', (chunk) => {
83
- downloaded += chunk.length;
84
- if (printOutput) {
85
- if (downloaded - lastPrinted > 1024 * 1024 * 10 ||
86
- downloaded === totalFileSize) {
87
- console.log(`Downloaded ${downloaded} of ${contentLength} bytes (${((downloaded / Number(contentLength)) *
88
- 100).toFixed(2)}%)`);
89
- lastPrinted = downloaded;
76
+ const reader = body.getReader();
77
+ // eslint-disable-next-line no-async-promise-executor
78
+ await new Promise(async (resolve, reject) => {
79
+ try {
80
+ // eslint-disable-next-line no-constant-condition
81
+ while (true) {
82
+ const { done, value } = await reader.read();
83
+ if (!value) {
84
+ throw new Error('Failed to read from stream');
90
85
  }
91
- }
92
- fileStream.write(chunk, () => {
93
- onProgress === null || onProgress === void 0 ? void 0 : onProgress(downloaded, totalFileSize);
94
- if (downloaded === totalFileSize) {
95
- fileStream.end();
96
- resolve();
86
+ downloaded += value.length;
87
+ if (printOutput) {
88
+ if (downloaded - lastPrinted > 1024 * 1024 * 10 ||
89
+ downloaded === totalFileSize) {
90
+ console.log(`Downloaded ${downloaded} of ${contentLength} bytes (${((downloaded / Number(contentLength)) *
91
+ 100).toFixed(2)}%)`);
92
+ lastPrinted = downloaded;
93
+ }
94
+ }
95
+ fileStream.write(value, () => {
96
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress(downloaded, totalFileSize);
97
+ if (downloaded === totalFileSize) {
98
+ fileStream.end();
99
+ resolve();
100
+ }
101
+ });
102
+ if (done) {
103
+ break;
97
104
  }
98
- });
99
- });
105
+ }
106
+ }
107
+ catch (e) {
108
+ reject(e);
109
+ }
100
110
  });
101
111
  return { alreadyExisted: false };
102
112
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/install-whisper-cpp",
3
- "version": "4.0.138",
3
+ "version": "4.0.139",
4
4
  "description": "Install helper for Whisper.cpp",
5
5
  "main": "dist/index.js",
6
6
  "sideEffects": false,