Files
Spencer BryngelsonandDaniel Bevenius 4afa009405 whisper : optional ANEForge encoder backend (Apple Neural Engine) (#3905)
* whisper : optional ANEForge encoder backend (Apple Neural Engine)

Runs the Whisper encoder directly on the Apple Neural Engine via ANEForge, an
alternative to the CoreML encoder backend. About 2x faster than the CoreML encoder
and faster than the Metal GPU encoder on M-series, at ~5x lower energy, with the
same transcripts (cosine 0.999 vs the reference encoder).

Mirrors the existing CoreML/OpenVINO seam: fills embd_enc from the external aneforge
package via the same whisper_encode_external path, gated at runtime by the
ANEFORGE_ENCODER env var. With the variable unset the build behaves exactly like
stock whisper.cpp (the backend dlopens its dispatch dylib only when enabled, no new
link-time dependency). Encoder only; the decoder is untouched.

Adds src/aneforge/whisper-aneforge.{h,cpp}, one line to src/CMakeLists.txt, and ~30
lines to src/whisper.cpp (include, state field, encode branch, init, free).

* aneforge: one statement per line, align dlsym block (review)

* aneforge: guard the backend to Apple Silicon, stub elsewhere (fix non-Apple CI)

whisper-aneforge.cpp uses <dlfcn.h> and __fp16, which are unavailable on Windows
(MSVC) and non-ARM Linux, so the unconditional build broke those CI jobs. Wrap the
real implementation in #if defined(__APPLE__) && defined(__aarch64__) and provide
no-op stubs elsewhere; the encoder is Apple-Neural-Engine-only anyway, and the
library now links on every platform.

* examples : include whisper-aneforge.cpp in android examples

Refs: https://github.com/ggml-org/whisper.cpp/actions/runs/32758607709/job/97689705921?pr=3905#step:5:200

* ci : specify explicit packages (platform-tools)

This commit updates the android jobs to specify platform-tools as an
explicit package.

The motivation for this to try to fix the Setup Android SDK step which
is also trying to install an obolete tools package.

Refs: https://github.com/ggml-org/whisper.cpp/actions/runs/35215042978/job/105181619536?pr=3905

---------

Co-authored-by: Daniel Bevenius <daniel.bevenius@gmail.com>
2026-09-18 06:18:56 +02:00
..
2022-12-16 19:20:13 +02:00
2022-12-16 19:20:13 +02:00
2022-12-16 19:20:13 +02:00
2022-12-16 19:20:13 +02:00
2024-06-16 18:19:48 +03:00

A sample Android app using whisper.cpp to do voice-to-text transcriptions.

To use:

  1. Select a model from the whisper.cpp repository.1
  2. Copy the model to the "app/src/main/assets/models" folder.
  3. Select a sample audio file (for example, jfk.wav).
  4. Copy the sample to the "app/src/main/assets/samples" folder.
  5. Select the "release" active build variant, and use Android Studio to run and deploy to your device.

(PS: Do not move this android project folder individually to other folders, because this android project folder depends on the files of the whole project.)

image

  1. I recommend the tiny or base models for running on an Android device. ↩︎