From a3b401f6b64be8d47700f849984c0fb62aa1b758 Mon Sep 17 00:00:00 2001 From: Jorge Mora Date: Thu, 13 Mar 2025 11:05:54 -0600 Subject: [PATCH 1/2] fix: whisper_cpp_main_path constant in win32 platform --- src/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constants.ts b/src/constants.ts index b4dee17..17a82d7 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -47,4 +47,4 @@ export const DEFAULT_MODEL = 'tiny.en' export const WHISPER_CPP_PATH = path.join(__dirname, '..', 'cpp', 'whisper.cpp') export const WHISPER_CPP_MAIN_PATH = - process.platform === 'win32' ? 'build\\bin\\Release\\whisper-cli.exe' : './build/bin/whisper-cli' + process.platform === 'win32' ? 'build\\bin\\whisper-cli.exe' : './build/bin/whisper-cli' From 3b43c32bec5a75546f140e26c36ba139e5279f17 Mon Sep 17 00:00:00 2001 From: Jorge Mora Date: Thu, 13 Mar 2025 11:28:19 -0600 Subject: [PATCH 2/2] fix: define execPath when using electron --- src/autoDownloadModel.ts | 2 ++ src/downloadModel.ts | 2 ++ src/utils.ts | 2 ++ src/whisper.ts | 2 ++ 4 files changed, 8 insertions(+) diff --git a/src/autoDownloadModel.ts b/src/autoDownloadModel.ts index 6ef5503..ac7d1bf 100644 --- a/src/autoDownloadModel.ts +++ b/src/autoDownloadModel.ts @@ -3,6 +3,8 @@ import shell from 'shelljs' import fs from 'fs' import { MODEL_OBJECT, MODELS_LIST, WHISPER_CPP_PATH } from './constants' +shell.config.execPath = shell.which('node').stdout + export default async function autoDownloadModel( logger = console, autoDownloadModelName?: string, diff --git a/src/downloadModel.ts b/src/downloadModel.ts index a038479..720b55d 100644 --- a/src/downloadModel.ts +++ b/src/downloadModel.ts @@ -8,6 +8,8 @@ import readlineSync from 'readline-sync' import { MODELS_LIST, DEFAULT_MODEL, MODELS, WHISPER_CPP_PATH, MODEL_OBJECT } from './constants' import fs from 'fs' +shell.config.execPath = shell.which('node').stdout + const askForModel = async (logger = console): Promise => { const answer = await readlineSync.question( `\n[Nodejs-whisper] Enter model name (e.g. 'tiny.en') or 'cancel' to exit\n(ENTER for tiny.en): ` diff --git a/src/utils.ts b/src/utils.ts index ee66e4a..a2d2cf7 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -2,6 +2,8 @@ import fs from 'fs' import path from 'path' import shell from 'shelljs' +shell.config.execPath = shell.which('node').stdout + export const checkIfFileExists = (filePath: string) => { if (!fs.existsSync(filePath)) { throw new Error(`[Nodejs-whisper] Error: No such file: ${filePath}`) diff --git a/src/whisper.ts b/src/whisper.ts index 0047d18..5bbfd74 100644 --- a/src/whisper.ts +++ b/src/whisper.ts @@ -1,6 +1,8 @@ import shell from 'shelljs' import { WHISPER_CPP_PATH, WHISPER_CPP_MAIN_PATH } from './constants' +shell.config.execPath = shell.which('node').stdout + const projectDir = process.cwd() export interface IShellOptions {