Skip to content

🎥 Make videos programmatically with React

handle compilation failure

Jonny Burger2cd24530940c
diff --git a/packages/install-whisper-cpp/src/install-whisper-cpp.ts b/packages/install-whisper-cpp/src/install-whisper-cpp.ts
index 920b05d401..cef240ef79 100644
--- a/packages/install-whisper-cpp/src/install-whisper-cpp.ts
+++ b/packages/install-whisper-cpp/src/install-whisper-cpp.ts
@@ -4,6 +4,7 @@ import {execSync} from 'node:child_process';
import {Readable} from 'node:stream';
import {finished} from 'node:stream/promises';
import type {ReadableStream} from 'node:stream/web';
+import os from 'os';
import path from 'path';
const installForWindows = async ({
@@ -64,6 +65,12 @@ const installWhisperForUnix = ({
});
};
+export const getWhisperExecutablePath = (whisperPath: string) => {
+ return os.platform() === 'win32'
+ ? path.join(whisperPath, 'main.exe')
+ : path.join(whisperPath, './main');
+};
+
export const installWhisperCpp = async ({
version,
to,
@@ -76,6 +83,16 @@ export const installWhisperCpp = async ({
alreadyExisted: boolean;
}> => {
if (existsSync(to)) {
+ if (!existsSync(getWhisperExecutablePath(to))) {
+ if (printOutput) {
+ console.log(
+ `Whisper folder exists but the executable (${to}) is missing. Delete ${to} and try again.`,
+ );
+ }
+
+ return Promise.resolve({alreadyExisted: false});
+ }
+
if (printOutput) {
console.log(`Whisper already exists at ${to}`);
}
diff --git a/packages/install-whisper-cpp/src/transcribe.ts b/packages/install-whisper-cpp/src/transcribe.ts
index e3815136b8..544c72b3f8 100644
--- a/packages/install-whisper-cpp/src/transcribe.ts
+++ b/packages/install-whisper-cpp/src/transcribe.ts
@@ -1,9 +1,9 @@
import {spawn} from 'node:child_process';
import fs, {existsSync} from 'node:fs';
-import os from 'node:os';
import path from 'node:path';
import type {WhisperModel} from './download-whisper-model';
import {getModelPath} from './download-whisper-model';
+import {getWhisperExecutablePath} from './install-whisper-cpp';
type Timestamps = {
from: string;
@@ -117,10 +117,7 @@ const transcribeToTempJSON = async ({
);
}
- const executable =
- os.platform() === 'win32'
- ? path.join(whisperPath, 'main.exe')
- : path.join(whisperPath, './main');
+ const executable = getWhisperExecutablePath(whisperPath);
const args = [
'-f',