whisper.cpp/bindings/javascript
Daniel Bevenius 81c190560a
cmake : update semver and release process [no ci] (#3996)
* cmake : update semver handling to be consistent with ggml/llama.cpp

This commit modifies the semantic version handling to be consistent with
how llama.cpp and ggml handle semver.

This commit introdues a new example named test-cmake which is intended
to be used to test the cmake configuration and installation.

* ci : update release workflow to be consistent with llama.cpp

work in progress...

* ci : fix if statement in release.yml

* ci : comment out all but one build in release.yml

This is just for testing and this commit should not be included in the
main PR later.

* ci : use DEPLOY_KEY_RELEASE

This commit updates the release and make-release workflows to use the
DEPLOY_KEY_RELEASE secret. Two github ruleset have been imported.

* ci : add github rulesets for releases

These were retrived from llama.cpp and then imported into my fork for
testing. If all works well they will be imported into whisper.cpp
upstream as well.

* fix move artifacts step

* examples : use FetchContent for llama.cpp in talk-llama

This commit updated the example talk-llama to remove the vendored
llama.cpp and instead use FetchContent to pull it in from the
upstream repo.

* ci: add GGML_NATIVE=OFF to build-clang.yml

This commit disables native CPU instructions from the ubuntu-22-clang
job.

The motivation for this is that currently it is possible that the
running compiling llama.cpp (via ccache) might have support for cpu
instructions that are not available on the target runner.

Refs: https://github.com/ggml-org/whisper.cpp/actions/runs/32224048267/job/95980031403?pr=3996

* ci : add missing GGML_NATIVE=OFF to jobs

* ci : add attestation for signed release artifacts

This commit add attenstions of artifacts to the release workflow.

After building the artifacts can be verified with the following command:
```console
$ curl -sSL -o whisper-bin-ubuntu-x64.tar.gz \
    https://github.com/danbev/whisper.cpp/releases/download/b4947/whisper-bin-ubuntu-x64.tar.gz

$ gh attestation verify --repo danbev/whisper.cpp whisper-bin-ubuntu-x64.tar.gz
Loaded digest sha256:722a6812263195d7ee2192b57fc64a6d6b09a6cdf2f55a152f793db27a651e31 for file://whisper-bin-ubuntu-x64.tar.gz
Loaded 1 attestation from GitHub API

The following policy criteria will be enforced:
- Predicate type must match:................ https://slsa.dev/provenance/v1
- Source Repository Owner URI must match:... https://github.com/danbev
- Source Repository URI must match:......... https://github.com/danbev/whisper.cpp
- Subject Alternative Name must match regex: (?i)^https://github\.com/danbev/whisper\.cpp/
- OIDC Issuer must match:................... https://token.actions.githubusercontent.com

✓ Verification succeeded!

The following 1 attestation matched the policy criteria

- Attestation #1
  - Build repo:..... danbev/whisper.cpp
  - Build workflow:. .github/workflows/release.yml@refs/heads/master
  - Signer repo:.... danbev/whisper.cpp
  - Signer workflow: .github/workflows/release.yml@refs/heads/master
```

* cmake : add WHISPER_USE_SYSTEM_LLAMA option [no ci]

This commit adds a new CMake option WHISPER_USE_SYSTEM_LLAMA that allows
the talk-llama example to use a system-installed llama.cpp library.

Setting this will automatically also set WHISPER_USE_SYSTEM_GGML to ON
and the system ggml library will be used in addition to the system
llama.cpp.

* ci : remove unused ccache step

* Revert "ci : comment out all but one build in release.yml"

This reverts commit 24b56776e1.

* ci : set WHISPER_BUILD_IS_DEV=OFF in release.yml
2026-08-20 09:34:27 +02:00
..
.gitignore wip : initial WASM port 2022-10-22 18:54:01 +03:00
CMakeLists.txt Node.js package (#260) 2022-12-12 20:17:27 +02:00
README.md bindings.javascript : update test instructions [no ci] (#2951) 2025-03-26 14:49:12 +01:00
emscripten.cpp whisper : add context param to disable gpu (#1293) 2023-11-06 11:04:24 +02:00
libwhisper.worker.js ggml : sync (ggml-alloc, GPU, eps, etc.) (#1220) 2023-09-05 13:54:40 +03:00
package-tmpl.json cmake : update semver and release process [no ci] (#3996) 2026-08-20 09:34:27 +02:00
package.json cmake : update semver and release process [no ci] (#3996) 2026-08-20 09:34:27 +02:00
whisper.js wchess : whisper assisted chess (#1595) 2023-12-14 15:58:26 +02:00

README.md

whisper.cpp

Node.js package for Whisper speech recognition

Package: https://www.npmjs.com/package/whisper.cpp

Details

The performance is comparable to when running whisper.cpp in the browser via WASM.

The API is currently very rudimentary: bindings/javascript/emscripten.cpp

For sample usage check tests/test-whisper.js

Package building + test

# load emscripten
source /path/to/emsdk/emsdk_env.sh

# clone repo
git clone https://github.com/ggerganov/whisper.cpp
cd whisper.cpp

# grab base.en model
./models/download-ggml-model.sh base.en

# prepare PCM sample for testing
ffmpeg -i samples/jfk.wav -f f32le -acodec pcm_f32le samples/jfk.pcmf32

# build
mkdir build-em && cd build-em
emcmake cmake .. && make -j

# run test
node ../tests/test-whisper.js

# For Node.js versions prior to v16.4.0, experimental features need to be enabled:
node --experimental-wasm-threads --experimental-wasm-simd ../tests/test-whisper.js

# publish npm package
make publish-npm

Sample run

$ node --experimental-wasm-threads --experimental-wasm-simd ../tests/test-whisper.js

whisper_model_load: loading model from 'whisper.bin'
whisper_model_load: n_vocab       = 51864
whisper_model_load: n_audio_ctx   = 1500
whisper_model_load: n_audio_state = 512
whisper_model_load: n_audio_head  = 8
whisper_model_load: n_audio_layer = 6
whisper_model_load: n_text_ctx    = 448
whisper_model_load: n_text_state  = 512
whisper_model_load: n_text_head   = 8
whisper_model_load: n_text_layer  = 6
whisper_model_load: n_mels        = 80
whisper_model_load: f16           = 1
whisper_model_load: type          = 2
whisper_model_load: adding 1607 extra tokens
whisper_model_load: mem_required  =  506.00 MB
whisper_model_load: ggml ctx size =  140.60 MB
whisper_model_load: memory size   =   22.83 MB
whisper_model_load: model size    =  140.54 MB

system_info: n_threads = 8 / 10 | AVX = 0 | AVX2 = 0 | AVX512 = 0 | NEON = 0 | F16C = 0 | FP16_VA = 0 | WASM_SIMD = 1 | BLAS = 0 |

operator(): processing 176000 samples, 11.0 sec, 8 threads, 1 processors, lang = en, task = transcribe ...

[00:00:00.000 --> 00:00:11.000]   And so my fellow Americans, ask not what your country can do for you, ask what you can do for your country.

whisper_print_timings:     load time =   162.37 ms
whisper_print_timings:      mel time =   183.70 ms
whisper_print_timings:   sample time =     4.27 ms
whisper_print_timings:   encode time =  8582.63 ms / 1430.44 ms per layer
whisper_print_timings:   decode time =   436.16 ms / 72.69 ms per layer
whisper_print_timings:    total time =  9370.90 ms