mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2025-07-24 19:45:37 +02:00
.devops
.github
bindings
ci
cmake
examples
addon.node
__test__
.gitignore
CMakeLists.txt
README.md
addon.cpp
index.js
package.json
bench
bench.wasm
cli
command
command.wasm
deprecation-warning
lsp
python
quantize
server
stream
stream.wasm
sycl
talk-llama
wchess
whisper.android
whisper.android.java
whisper.nvim
whisper.objc
whisper.swiftui
whisper.wasm
CMakeLists.txt
common-ggml.cpp
common-ggml.h
common-sdl.cpp
common-sdl.h
common-whisper.cpp
common-whisper.h
common.cpp
common.h
ffmpeg-transcode.cpp
generate-karaoke.sh
grammar-parser.cpp
grammar-parser.h
helpers.js
json.hpp
livestream.sh
miniaudio.h
server.py
stb_vorbis.c
twitch.sh
yt-wsp.sh
ggml
grammars
include
models
samples
scripts
src
tests
.gitignore
.gitmodules
AUTHORS
CMakeLists.txt
LICENSE
Makefile
README.md
README_sycl.md
build-xcframework.sh
close-issue.yml
52 lines
1.1 KiB
JavaScript
52 lines
1.1 KiB
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: path.join(__dirname, "../../samples/jfk.wav"),
|
|
use_gpu: true,
|
|
flash_attn: false,
|
|
no_prints: true,
|
|
comma_in_time: false,
|
|
translate: true,
|
|
no_timestamps: false,
|
|
audio_ctx: 0,
|
|
max_len: 0,
|
|
};
|
|
|
|
const arguments = process.argv.slice(2);
|
|
const params = Object.fromEntries(
|
|
arguments.reduce((pre, item) => {
|
|
if (item.startsWith("--")) {
|
|
const [key, value] = item.slice(2).split("=");
|
|
if (key === "audio_ctx") {
|
|
whisperParams[key] = parseInt(value);
|
|
} else {
|
|
whisperParams[key] = value;
|
|
}
|
|
return pre;
|
|
}
|
|
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();
|
|
console.log(result);
|
|
});
|