Some checks failed
Bindings Tests (Go) / ubuntu-22 (push) Failing after 31s
CI (sycl) / ubuntu-22-cmake-sycl (linux/arm/v7, icx, icpx, ON) (push) Failing after 3s
CI (sycl) / ubuntu-22-cmake-sycl (linux/ppc64le, icx, icpx, ON) (push) Failing after 2s
CI (sycl) / ubuntu-22-cmake-sycl-fp16 (linux/amd64, icx, icpx, ON) (push) Failing after 3s
CI (sycl) / ubuntu-22-cmake-sycl-fp16 (linux/arm/v7, icx, icpx, ON) (push) Failing after 3s
CI (sycl) / ubuntu-22-cmake-sycl-fp16 (linux/arm64, icx, icpx, ON) (push) Failing after 3s
CI (sycl) / ubuntu-22-cmake-sycl-fp16 (linux/ppc64le, icx, icpx, ON) (push) Failing after 3s
CI (vad) / vad (push) Failing after 3s
CI (wasm) / emscripten (Release) (push) Failing after 4s
Bindings Tests (Ruby) / ubuntu-22 (push) Failing after 37s
CI (android) / android (push) Failing after 16s
CI (android) / android_java (push) Failing after 3s
CI (clang) / ubuntu-22-clang (linux/amd64, Debug) (push) Failing after 3s
CI (clang) / ubuntu-22-clang (linux/amd64, Release) (push) Failing after 2s
CI (clang) / ubuntu-22-clang (linux/ppc64le, Debug) (push) Failing after 3s
CI (clang) / ubuntu-22-clang (linux/ppc64le, Release) (push) Failing after 3s
CI (cpu) / ggml-ci-x64-cpu-low-perf (push) Failing after 3s
CI (cpu) / ggml-ci-x64-cpu-high-perf (push) Failing after 2s
CI (gcc) / ubuntu-22-gcc (linux/amd64, Debug) (push) Failing after 3s
CI (gcc) / ubuntu-22-gcc (linux/amd64, Release) (push) Failing after 3s
CI (gcc) / ubuntu-22-gcc (linux/ppc64le, Debug) (push) Failing after 3s
CI (gcc) / ubuntu-22-gcc (linux/ppc64le, Release) (push) Failing after 4s
CI (gcc) / ubuntu-22-gcc-arm-v7 (linux/arm/v7, Debug) (push) Failing after 3s
CI (gcc) / ubuntu-22-gcc-arm-v7 (linux/arm/v7, Release) (push) Failing after 3s
CI (quantize) / quantize (push) Failing after 3s
CI (sanitize) / ubuntu-22-gcc-sanitized (ADDRESS) (push) Failing after 3s
CI (sanitize) / ubuntu-22-gcc-sanitized (THREAD) (push) Failing after 3s
CI (sanitize) / ubuntu-22-gcc-sanitized (UNDEFINED) (push) Failing after 2s
CI (sycl) / ubuntu-22-cmake-sycl (linux/amd64, icx, icpx, ON) (push) Failing after 3s
CI (sycl) / ubuntu-22-cmake-sycl (linux/arm64, icx, icpx, ON) (push) Failing after 3s
Examples WASM / deploy-wasm-github-pages (push) Failing after 3s
Examples Tests / addon_node-ubuntu-22 (20.x) (push) Failing after 3s
Examples Tests / addon_node-ubuntu-22 (22.x) (push) Failing after 2s
CI (coreml) / coreml-base-en (push) Has been cancelled
CI (self-hosted) / gpu-vulkan (push) Has been cancelled
CI (self-hosted) / npu-amd-windows (push) Has been cancelled
CI (self-hosted) / gpu-vulkan-nvidia-cm2 (push) Has been cancelled
CI (clang) / ubuntu-22-clang-arm64 (Debug) (push) Has been cancelled
CI (clang) / ubuntu-22-clang-arm64 (Release) (push) Has been cancelled
CI (self-hosted) / gpu-cuda (push) Has been cancelled
CI (self-hosted) / gpu-vulkan-nvidia-cm (push) Has been cancelled
CI (cpu) / ggml-ci-arm64-cpu-low-perf (push) Has been cancelled
CI (cpu) / ggml-ci-arm64-cpu-high-perf (push) Has been cancelled
CI (cpu) / ggml-ci-arm64-cpu-high-perf-sve (push) Has been cancelled
CI (freebsd) / freeBSD-latest (push) Has been cancelled
CI (self-hosted) / gpu-metal (push) Has been cancelled
CI (gcc) / ubuntu-22-gcc-arm64 (Debug) (push) Has been cancelled
CI (gcc) / ubuntu-22-gcc-arm64 (Release) (push) Has been cancelled
CI (macOS) / macOS-latest (generic/platform=iOS) (push) Has been cancelled
CI (macOS) / macOS-latest (generic/platform=macOS) (push) Has been cancelled
CI (macOS) / macOS-latest (generic/platform=tvOS) (push) Has been cancelled
CI (self-hosted) / npu-amd-linux (push) Has been cancelled
CI (windows) / windows-msys2 (Release, clang, clang-x86_64, CLANG64) (push) Has been cancelled
CI (windows) / windows-msys2 (Release, gcc, ucrt-x86_64, UCRT64) (push) Has been cancelled
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/main-cuda.Dockerfile platform:linux/amd64 runs_on:ubuntu-24.04 tag:main-cuda]) (push) Has been cancelled
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/main-intel.Dockerfile platform:linux/amd64 runs_on:ubuntu-24.04 tag:main-intel]) (push) Has been cancelled
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/main-musa.Dockerfile platform:linux/amd64 runs_on:ubuntu-24.04 tag:main-musa]) (push) Has been cancelled
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/main-vulkan.Dockerfile platform:linux/amd64 runs_on:ubuntu-24.04 tag:main-vulkan]) (push) Has been cancelled
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/main-vulkan.Dockerfile platform:linux/arm64 runs_on:ubuntu-24.04-arm tag:main-vulkan-arm64]) (push) Has been cancelled
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/main.Dockerfile platform:linux/amd64 runs_on:ubuntu-24.04 tag:main]) (push) Has been cancelled
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/main.Dockerfile platform:linux/arm64 runs_on:ubuntu-24.04-arm tag:main-arm64]) (push) Has been cancelled
Mark inactive issues stale / mark-issues (push) Failing after 1s
132 lines
4.4 KiB
JavaScript
132 lines
4.4 KiB
JavaScript
const path = require("path");
|
||
const { whisper } = require(path.join(
|
||
__dirname,
|
||
"../../build/Release/addon.node"
|
||
));
|
||
const { promisify } = require("util");
|
||
|
||
const whisperAsync = promisify(whisper);
|
||
|
||
// Example with VAD enabled
|
||
const vadParams = {
|
||
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: false,
|
||
comma_in_time: true,
|
||
translate: false,
|
||
no_timestamps: false,
|
||
detect_language: false,
|
||
audio_ctx: 0,
|
||
max_len: 0,
|
||
// VAD parameters
|
||
vad: true,
|
||
vad_model: path.join(__dirname, "../../models/ggml-silero-v6.2.0.bin"), // You need to download this model
|
||
vad_threshold: 0.5,
|
||
vad_min_speech_duration_ms: 250,
|
||
vad_min_silence_duration_ms: 100,
|
||
vad_max_speech_duration_s: 30.0,
|
||
vad_speech_pad_ms: 30,
|
||
vad_samples_overlap: 0.1,
|
||
progress_callback: (progress) => {
|
||
console.log(`VAD Transcription progress: ${progress}%`);
|
||
}
|
||
};
|
||
|
||
// Example without VAD (traditional approach)
|
||
const traditionalParams = {
|
||
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: false,
|
||
comma_in_time: true,
|
||
translate: false,
|
||
no_timestamps: false,
|
||
detect_language: false,
|
||
audio_ctx: 0,
|
||
max_len: 0,
|
||
vad: false, // Explicitly disable VAD
|
||
progress_callback: (progress) => {
|
||
console.log(`Traditional transcription progress: ${progress}%`);
|
||
}
|
||
};
|
||
|
||
async function runVADExample() {
|
||
try {
|
||
console.log("=== Whisper.cpp Node.js VAD Example ===\n");
|
||
|
||
// Check if VAD model exists
|
||
const fs = require('fs');
|
||
if (!fs.existsSync(vadParams.vad_model)) {
|
||
console.log("⚠️ VAD model not found. Please download the VAD model first:");
|
||
console.log(" ./models/download-vad-model.sh silero-v6.2.0");
|
||
console.log(" Or run: python models/convert-silero-vad-to-ggml.py");
|
||
console.log("\n Falling back to traditional transcription without VAD...\n");
|
||
|
||
// Run without VAD
|
||
console.log("🎵 Running traditional transcription...");
|
||
const traditionalResult = await whisperAsync(traditionalParams);
|
||
console.log("\n📝 Traditional transcription result:");
|
||
console.log(traditionalResult);
|
||
return;
|
||
}
|
||
|
||
console.log("🎵 Running transcription with VAD enabled...");
|
||
console.log("VAD Parameters:");
|
||
console.log(` - Threshold: ${vadParams.vad_threshold}`);
|
||
console.log(` - Min speech duration: ${vadParams.vad_min_speech_duration_ms}ms`);
|
||
console.log(` - Min silence duration: ${vadParams.vad_min_silence_duration_ms}ms`);
|
||
console.log(` - Max speech duration: ${vadParams.vad_max_speech_duration_s}s`);
|
||
console.log(` - Speech padding: ${vadParams.vad_speech_pad_ms}ms`);
|
||
console.log(` - Samples overlap: ${vadParams.vad_samples_overlap}\n`);
|
||
|
||
const startTime = Date.now();
|
||
const vadResult = await whisperAsync(vadParams);
|
||
const vadDuration = Date.now() - startTime;
|
||
|
||
console.log("\n✅ VAD transcription completed!");
|
||
console.log(`⏱️ Processing time: ${vadDuration}ms`);
|
||
console.log("\n📝 VAD transcription result:");
|
||
console.log(vadResult);
|
||
|
||
// Compare with traditional approach
|
||
console.log("\n🔄 Running traditional transcription for comparison...");
|
||
const traditionalStartTime = Date.now();
|
||
const traditionalResult = await whisperAsync(traditionalParams);
|
||
const traditionalDuration = Date.now() - traditionalStartTime;
|
||
|
||
console.log("\n✅ Traditional transcription completed!");
|
||
console.log(`⏱️ Processing time: ${traditionalDuration}ms`);
|
||
console.log("\n📝 Traditional transcription result:");
|
||
console.log(traditionalResult);
|
||
|
||
// Performance comparison
|
||
console.log("\n📊 Performance Comparison:");
|
||
console.log(`VAD: ${vadDuration}ms`);
|
||
console.log(`Traditional: ${traditionalDuration}ms`);
|
||
const speedup = traditionalDuration / vadDuration;
|
||
if (speedup > 1) {
|
||
console.log(`🚀 VAD is ${speedup.toFixed(2)}x faster!`);
|
||
} else {
|
||
console.log(`ℹ️ Traditional approach was ${(1/speedup).toFixed(2)}x faster in this case.`);
|
||
}
|
||
|
||
} catch (error) {
|
||
console.error("❌ Error during transcription:", error);
|
||
}
|
||
}
|
||
|
||
// Run the example
|
||
if (require.main === module) {
|
||
runVADExample();
|
||
}
|
||
|
||
module.exports = {
|
||
runVADExample,
|
||
vadParams,
|
||
traditionalParams
|
||
};
|