feat(node-addon): fixes

pull/484/head
Dmitry Kryaklin 2 years ago
parent cfc06bf8df
commit 1ca8edf87f

@ -0,0 +1,28 @@
rm -rf ./build
rm -rf ./examples/addon.node/whisper
npx cmake-js compile -T whisper-addon
mkdir ./examples/addon.node/whisper
cp ./build/Release/* ./examples/addon.node/whisper
rm -rf ./build
cd ./examples/addon.node
node ./index.js --model=../../models/tiny.en.bin --fname_inp=../../samples/jfk.wav
# pkg index.js --target node16-macos-arm64
# rm ./whisper/addon.node
# ./index --model=../../models/tiny.en.bin --fname_inp=../../samples/jfk.wav
# cd ..
# ./addon.node/index --model=../models/tiny.en.bin --fname_inp=../samples/jfk.wav
# cp ./index ../../index
# cd ../..
# ./index --model=./models/tiny.en.bin --fname_inp=./samples/jfk.wav

@ -1,4 +1,5 @@
set(TARGET whisper-addon)
# set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
# Base settings
#==================================================================
@ -8,7 +9,7 @@ include_directories(${CMAKE_JS_INC})
#==================================================================
add_library(${TARGET} SHARED ${CMAKE_JS_SRC} addon.cpp)
set_target_properties(${TARGET} PROPERTIES PREFIX "" SUFFIX ".node")
set_target_properties(${TARGET} PROPERTIES PREFIX "" SUFFIX ".node" LINK_FLAGS "-Wl,-rpath,@loader_path/")
include(DefaultTargetOptions)

@ -1,27 +1,26 @@
const path = require('path');
const { whisper } = require(path.join(__dirname, '../../build/Release/whisper-addon'));
const whisperParams = {
language: 'en',
model: path.join(__dirname, '../../models/ggml-base.en.bin'),
fname_inp: '',
};
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;
}, []),
arguments.reduce((pre, item) => {
if (item.startsWith("--")) {
return [...pre, item.slice(2).split("=")];
}
return pre;
}, [])
);
const { whisper } = require(params.whisper);
const whisperParams = {
language: "en",
model: "",
fname_inp: "",
};
for (const key in params) {
if (whisperParams.hasOwnProperty(key)) {
whisperParams[key] = params[key];
}
if (whisperParams.hasOwnProperty(key)) {
whisperParams[key] = params[key];
}
}
console.log('whisperParams =', whisperParams);
console.log("whisperParams =", whisperParams);
console.log(whisper(whisperParams));

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save