mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2024-12-22 14:02:21 +00:00
0463028bc2
* whisper : check state->ctx_metal not null * whisper : add whisper_context_params { use_gpu } * whisper : new API with params & deprecate old API * examples : use no-gpu param && whisper_init_from_file_with_params * whisper.objc : enable metal & disable on simulator * whisper.swiftui, metal : enable metal & support load default.metallib * whisper.android : use new API * bindings : use new API * addon.node : fix build & test * bindings : updata java binding * bindings : add missing whisper_context_default_params_by_ref WHISPER_API for java * metal : use SWIFTPM_MODULE_BUNDLE for GGML_SWIFT and reuse library load * metal : move bundle var into block * metal : use SWIFT_PACKAGE instead of GGML_SWIFT * style : minor updates --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
38 lines
864 B
JavaScript
38 lines
864 B
JavaScript
const path = require("path");
|
|
const { whisper } = require(path.join(
|
|
__dirname,
|
|
"../../build/Release/whisper-addon"
|
|
));
|
|
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,
|
|
};
|
|
|
|
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}`);
|
|
});
|