nodejs-whisper
Advanced tools
Comparing version 0.1.10 to 0.1.11
@@ -1,1 +0,1 @@ | ||
export default function autoDownloadModel(autoDownloadModelName?: string, verbose?: boolean): Promise<any>; | ||
export default function autoDownloadModel(autoDownloadModelName?: string, verbose?: boolean, withCuda?: boolean): Promise<any>; |
@@ -19,3 +19,3 @@ "use strict"; | ||
const fs_1 = __importDefault(require("fs")); | ||
function autoDownloadModel(autoDownloadModelName, verbose) { | ||
function autoDownloadModel(autoDownloadModelName, verbose, withCuda = false) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -52,3 +52,8 @@ const projectDir = process.cwd(); | ||
shelljs_1.default.cd('../'); | ||
shelljs_1.default.exec('make'); | ||
if (withCuda) { | ||
shelljs_1.default.exec('WHISPER_CUDA=1 make -j'); | ||
} | ||
else { | ||
shelljs_1.default.exec('make -j'); | ||
} | ||
resolve('Model Downloaded Successfully'); | ||
@@ -55,0 +60,0 @@ } |
@@ -39,2 +39,13 @@ #! /usr/bin/env node | ||
}); | ||
const askIfUserWantToUseCuda = () => __awaiter(void 0, void 0, void 0, function* () { | ||
const answer = yield readline_sync_1.default.question(`\n[Nodejs-whisper] Do you want to use CUDA for compilation? (y/n)\n(ENTER for n): `); | ||
if (answer === 'y') { | ||
console.log('[Nodejs-whisper] Using CUDA for compilation.'); | ||
return true; | ||
} | ||
else { | ||
console.log('[Nodejs-whisper] Not using CUDA for compilation.'); | ||
return false; | ||
} | ||
}); | ||
function downloadModel() { | ||
@@ -84,3 +95,9 @@ return __awaiter(this, void 0, void 0, function* () { | ||
shelljs_1.default.cd('../'); | ||
shelljs_1.default.exec('make'); | ||
const withCuda = yield askIfUserWantToUseCuda(); | ||
if (withCuda) { | ||
shelljs_1.default.exec('WHISPER_CUDA=1 make -j'); | ||
} | ||
else { | ||
shelljs_1.default.exec('make -j'); | ||
} | ||
process.exit(0); | ||
@@ -87,0 +104,0 @@ } |
@@ -6,2 +6,3 @@ import { WhisperOptions } from './types'; | ||
whisperOptions?: WhisperOptions; | ||
withCuda?: boolean; | ||
verbose?: boolean; | ||
@@ -8,0 +9,0 @@ removeWavFileAfterTranscription?: boolean; |
@@ -26,3 +26,3 @@ "use strict"; | ||
if (options.autoDownloadModelName) { | ||
yield (0, autoDownloadModel_1.default)(options.autoDownloadModelName, verbose); | ||
yield (0, autoDownloadModel_1.default)(options.autoDownloadModelName, verbose, options.withCuda); | ||
} | ||
@@ -36,3 +36,3 @@ (0, utils_1.checkIfFileExists)(filePath); | ||
} | ||
const transcript = yield (0, whisper_1.executeCppCommand)(command, verbose); | ||
const transcript = yield (0, whisper_1.executeCppCommand)(command, verbose, options.withCuda); | ||
if (!transcript) { | ||
@@ -39,0 +39,0 @@ throw new Error('Something went wrong while executing the command.'); |
@@ -6,2 +6,2 @@ export interface IShellOptions { | ||
export declare function whisperShell(command: string, options: IShellOptions, verbose: boolean): Promise<any>; | ||
export declare const executeCppCommand: (command: string, verbose: boolean) => Promise<any>; | ||
export declare const executeCppCommand: (command: string, verbose: boolean, withCuda: boolean) => Promise<any>; |
@@ -56,3 +56,3 @@ "use strict"; | ||
exports.whisperShell = whisperShell; | ||
const executeCppCommand = (command, verbose) => __awaiter(void 0, void 0, void 0, function* () { | ||
const executeCppCommand = (command, verbose, withCuda) => __awaiter(void 0, void 0, void 0, function* () { | ||
try { | ||
@@ -63,3 +63,8 @@ shelljs_1.default.cd(WHISPER_CPP_PATH); | ||
shelljs_1.default.echo("[Nodejs-whisper] Attempting to run 'make' command in /whisper directory..."); | ||
shelljs_1.default.exec('make'); | ||
if (withCuda) { | ||
shelljs_1.default.exec('WHISPER_CUDA=1 make -j'); | ||
} | ||
else { | ||
shelljs_1.default.exec('make -j'); | ||
} | ||
if (!shelljs_1.default.which(WHISPER_CPP_MAIN_PATH)) { | ||
@@ -66,0 +71,0 @@ console.log(" [Nodejs-whisper] 'make' command failed. Please run 'make' command in /whisper.cpp directory. Current shelljs directory: ", __dirname); |
{ | ||
"name": "nodejs-whisper", | ||
"version": "0.1.10", | ||
"version": "0.1.11", | ||
"description": "Node bindings for OpenAI's Whisper. Optimized for CPU.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -53,2 +53,4 @@ # nodejs-whisper | ||
autoDownloadModelName: 'base.en', // (optional) autodownload a model if model is not present | ||
verbose?: boolean | ||
removeWavFileAfterTranscription?: boolean | ||
whisperOptions: { | ||
@@ -55,0 +57,0 @@ outputInText: false, // get output result in txt file |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5338609
4290
147