mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2024-12-22 05:57:48 +00:00
58210d6a76
* node : fix compilation and update examples * node : fix readme * Update addon.node test
39 lines
885 B
JavaScript
39 lines
885 B
JavaScript
const path = require("path");
|
|
const { whisper } = require(path.join(
|
|
__dirname,
|
|
"../../build/Release/addon.node"
|
|
));
|
|
const { promisify } = require("util");
|
|
|
|
const whisperAsync = promisify(whisper);
|
|
|
|
const whisperParams = {
|
|
language: "en",
|
|
model: path.join(__dirname, "../../models/ggml-base.en.bin"),
|
|
fname_inp: "../../samples/jfk.wav",
|
|
use_gpu: true,
|
|
no_timestamps: false,
|
|
};
|
|
|
|
const arguments = process.argv.slice(2);
|
|
const params = Object.fromEntries(
|
|
arguments.reduce((pre, item) => {
|
|
if (item.startsWith("--")) {
|
|
return [...pre, item.slice(2).split("=")];
|
|
}
|
|
return pre;
|
|
}, [])
|
|
);
|
|
|
|
for (const key in params) {
|
|
if (whisperParams.hasOwnProperty(key)) {
|
|
whisperParams[key] = params[key];
|
|
}
|
|
}
|
|
|
|
console.log("whisperParams =", whisperParams);
|
|
|
|
whisperAsync(whisperParams).then((result) => {
|
|
console.log(`Result from whisper: ${result}`);
|
|
});
|