2023-03-22 20:19:22 +00:00
|
|
|
const path = require("path");
|
|
|
|
const { whisper } = require(path.join(
|
|
|
|
__dirname,
|
|
|
|
"../../build/Release/whisper-addon"
|
|
|
|
));
|
|
|
|
const { promisify } = require("util");
|
|
|
|
|
|
|
|
const whisperAsync = promisify(whisper);
|
2023-02-04 07:10:25 +00:00
|
|
|
|
|
|
|
const whisperParams = {
|
2023-03-22 20:19:22 +00:00
|
|
|
language: "en",
|
|
|
|
model: path.join(__dirname, "../../models/ggml-base.en.bin"),
|
|
|
|
fname_inp: "../../samples/jfk.wav",
|
2023-11-06 09:04:24 +00:00
|
|
|
use_gpu: true,
|
2023-02-04 07:10:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const arguments = process.argv.slice(2);
|
|
|
|
const params = Object.fromEntries(
|
2023-03-22 20:19:22 +00:00
|
|
|
arguments.reduce((pre, item) => {
|
|
|
|
if (item.startsWith("--")) {
|
|
|
|
return [...pre, item.slice(2).split("=")];
|
|
|
|
}
|
|
|
|
return pre;
|
|
|
|
}, [])
|
2023-02-04 07:10:25 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
for (const key in params) {
|
2023-03-22 20:19:22 +00:00
|
|
|
if (whisperParams.hasOwnProperty(key)) {
|
|
|
|
whisperParams[key] = params[key];
|
|
|
|
}
|
2023-02-04 07:10:25 +00:00
|
|
|
}
|
|
|
|
|
2023-03-22 20:19:22 +00:00
|
|
|
console.log("whisperParams =", whisperParams);
|
|
|
|
|
|
|
|
whisperAsync(whisperParams).then((result) => {
|
|
|
|
console.log(`Result from whisper: ${result}`);
|
|
|
|
});
|