@remotion/install-whisper-cpp 4.0.115 → 4.0.117
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/dist/download-whisper-model.js +22 -12
- package/package.json +1 -1
|
@@ -29,7 +29,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.downloadWhisperModel = void 0;
|
|
30
30
|
const fs_1 = __importStar(require("fs"));
|
|
31
31
|
const node_stream_1 = require("node:stream");
|
|
32
|
-
const promises_1 = require("node:stream/promises");
|
|
33
32
|
const path_1 = __importDefault(require("path"));
|
|
34
33
|
const models = [
|
|
35
34
|
'tiny',
|
|
@@ -68,22 +67,33 @@ const downloadWhisperModel = async ({ model, folder, printOutput = true, onProgr
|
|
|
68
67
|
if (contentLength === null) {
|
|
69
68
|
throw new Error('Content-Length header not found');
|
|
70
69
|
}
|
|
70
|
+
const totalFileSize = parseInt(contentLength, 10);
|
|
71
71
|
let downloaded = 0;
|
|
72
72
|
let lastPrinted = 0;
|
|
73
73
|
const readable = node_stream_1.Readable.fromWeb(body);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
await new Promise((resolve, reject) => {
|
|
75
|
+
readable.on('error', (err) => {
|
|
76
|
+
reject(err);
|
|
77
|
+
});
|
|
78
|
+
readable.on('data', (chunk) => {
|
|
79
|
+
downloaded += chunk.length;
|
|
80
|
+
if (printOutput) {
|
|
81
|
+
if (downloaded - lastPrinted > 1024 * 1024 * 10 ||
|
|
82
|
+
downloaded === totalFileSize) {
|
|
83
|
+
console.log(`Downloaded ${downloaded} of ${contentLength} bytes (${((downloaded / Number(contentLength)) *
|
|
84
|
+
100).toFixed(2)}%)`);
|
|
85
|
+
lastPrinted = downloaded;
|
|
86
|
+
}
|
|
81
87
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
88
|
+
fileStream.write(chunk, () => {
|
|
89
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress(downloaded, totalFileSize);
|
|
90
|
+
if (downloaded === totalFileSize) {
|
|
91
|
+
fileStream.end();
|
|
92
|
+
resolve();
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
85
96
|
});
|
|
86
|
-
await (0, promises_1.finished)(readable);
|
|
87
97
|
return { alreadyExisted: false };
|
|
88
98
|
};
|
|
89
99
|
exports.downloadWhisperModel = downloadWhisperModel;
|