@fugood/node-whisper-wasm

中文文档
1.2.0-rc.2发布于 2026/11/09MITTypeScriptES Module零依赖近 30 天下载 2.4万

Browser WASM module for whisper.node

原始使用文档

@fugood/node-whisper-wasm

Browser WASM implementation package for @fugood/whisper.node. Application code should import @fugood/whisper.node; this package is pulled in by the main package for browser builds.

The package exposes the same high-level context API as the native packages (initWhisper, initWhisperVad, and initParakeet), but model and audio file paths are fetched as URLs and copied into the Emscripten filesystem before inference.

import { initWhisper } from '@fugood/whisper.node'

const whisper = await initWhisper({
  filePath: 'https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.en.bin',
  useGpu: false,
})

const { promise } = whisper.transcribeFile('https://raw.githubusercontent.com/ggml-org/whisper.cpp/master/samples/jfk.wav', {
  language: 'en',
})

console.log(await promise)
await whisper.release()

The package ships both single-thread and pthread WASM artifacts. On cross-origin isolated pages with SharedArrayBuffer, the loader uses the pthread artifact; otherwise it falls back to the single-thread artifact automatically. Whisper transcription defaults to up to 8 threads based on browser hardware concurrency when pthreads are available; pass maxThreads to override it. Browser WASM clamps maxThreads to the compiled pool limit of 8, or 1 in the single-thread fallback. Browser pages run model loading, transcription, benchmarks, and VAD in a dedicated module worker by default so the UI thread can keep rendering. Use the main whisper.node package entrypoint in browser code:

import { configureWasm, initWhisper } from '@fugood/whisper.node'

Use configureWasm({ worker: false }) only when you explicitly need the in-thread runtime, configureWasm({ threads: false }) to force the single-thread artifact, or pass workerPath, jsPath, and wasmPath when serving the package files from custom URLs. The older workerUrl and runtimeScriptUrl option names still work. Model downloads are cached in browser Cache Storage by default. Pass cacheModel: false to disable persistent caching, modelCacheName to isolate the cache namespace, or modelCacheKey when the fetch URL is a proxy or signed URL but should reuse the same cached model. Set useGpu: true only with a package built using GGML_WEBGPU=ON and a browser that exposes navigator.gpu. VAD currently falls back to CPU in the browser package because the Silero VAD graph hits unsupported WebGPU ops.

The default build emits wasm/whisper-node.js, wasm/whisper-node.wasm, wasm/whisper-node.threads.js, and wasm/whisper-node.threads.wasm. Use bash scripts/build-wasm.sh --single-file only when you want the WASM binary embedded into each generated JS file. Modern Emscripten embeds the pthread worker bootstrap in the main JS file, so a separate whisper-node.worker.js is not expected. The package module worker that keeps UI work off the main thread is worker.js. Use npm run build-wasm-docker to build through Docker; it selects a native arm64 Emscripten image on Apple Silicon hosts.

版本与发布记录

@fugood/node-whisper-wasm 共发布 11 个版本,首次发布于 2026/06/02;过去 12 个月发布了 11 个版本。

版本发布日期距今
1.2.0-rc.2latest2026/11/096 天前
1.2.0-rc.12026/10/071 个月前
1.2.0-rc.02026/09/171 个月前
1.1.32026/08/272 个月前
1.1.22026/08/242 个月前
1.1.12026/07/193 个月前

关于 @fugood/node-whisper-wasm 的常见问题

@fugood/node-whisper-wasm 是什么?

Browser WASM module for whisper.node

如何安装 @fugood/node-whisper-wasm?

在项目目录运行 npm install @fugood/node-whisper-wasm,或使用 pnpm add / yarn add / bun add。

@fugood/node-whisper-wasm 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fugood/node-whisper-wasm 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@fugood/node-whisper-wasm 可以商用吗?

@fugood/node-whisper-wasm 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fugood/node-whisper-wasm 的下载量有多少?

根据 npm 官方下载统计,@fugood/node-whisper-wasm 在 2026/10/16 – 2026/11/14 这 30 天内被下载 24,227 次,日均约 808 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fugood/node-whisper-wasm 还在维护吗?

最新版本 1.2.0-rc.2 发布于 2026/11/09(6 天前);至今共发布 11 个版本,其中过去 12 个月发布了 11 个;首次发布于 2026/06/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。