Skip to content

🎥 Make videos programmatically with React

`@remotion/install-whisper-cpp`: Fix downloadWhisperModel() syntax

Jonny Burger3fc2354709f5
diff --git a/packages/install-whisper-cpp/src/download-whisper-model.ts b/packages/install-whisper-cpp/src/download-whisper-model.ts
index 79e4618ce3..ca74238cf3 100644
--- a/packages/install-whisper-cpp/src/download-whisper-model.ts
+++ b/packages/install-whisper-cpp/src/download-whisper-model.ts
@@ -83,16 +83,13 @@ export const downloadWhisperModel = async ({
while (true) {
const {done, value} = await reader.read();
- if (!value) {
- throw new Error('Failed to read from stream');
- }
-
- downloaded += value.length;
+ if (value) {
+ downloaded += value.length;
- if (printOutput) {
if (
- downloaded - lastPrinted > 1024 * 1024 * 10 ||
- downloaded === totalFileSize
+ printOutput &&
+ (downloaded - lastPrinted > 1024 * 1024 * 10 ||
+ downloaded === totalFileSize)
) {
console.log(
`Downloaded ${downloaded} of ${contentLength} bytes (${(
@@ -102,15 +99,15 @@ export const downloadWhisperModel = async ({
);
lastPrinted = downloaded;
}
- }
- fileStream.write(value, () => {
- onProgress?.(downloaded, totalFileSize);
- if (downloaded === totalFileSize) {
- fileStream.end();
- resolve();
- }
- });
+ fileStream.write(value, () => {
+ onProgress?.(downloaded, totalFileSize);
+ if (downloaded === totalFileSize) {
+ fileStream.end();
+ resolve();
+ }
+ });
+ }
if (done) {
break;