UNPKG

@pr0gramm/fluester

Version:

Node.js bindings for OpenAI's Whisper. Optimized for CPU.

29 lines (28 loc) 990 B
#!/usr/bin/env node import { canExecute, execute } from "../execute.js"; import { nodeModulesWhisper } from "../interop.js"; // Docs: https://github.com/ggerganov/whisper.cpp const whisperCppMain = "./main"; try { process.chdir(nodeModulesWhisper); if (!(await canExecute(whisperCppMain))) { console.log("whisper.cpp not initialized, compiling..."); await execute("make"); if (!(await canExecute(whisperCppMain))) { console.error(`"make" command failed. Please run "make" command in whisper directory. Current directory: ${nodeModulesWhisper}`); process.exit(-1); } } const test = await execute(whisperCppMain, ["--help"]); if (test.exitCode === 0 && test.stderr.length > 0) { console.log("whisper.cpp initialized successfully"); } else { console.error("Could not test-run whisper.cpp"); process.exit(-1); } } catch (error) { console.log("Error caught"); throw error; }