whisper.cpp is a high-performance C/C++ port of the OpenAI Whisper automatic speech recognition (ASR) model, designed to provide dependency-free, offline speech transcription capabilities. Its core implementation is located in whisper.h and whisper.cpp, while the rest of the code belongs to the ggml machine learning library.
Main Capabilities
- Pure C/C++ implementation, no external dependencies, zero memory allocation at runtime.
- Supports mixed F16/F32 precision and integer quantization; quantized models use less memory and disk space.
- Supports CPU inference, with optimizations for different architectures: Apple Silicon (ARM NEON, Accelerate, Metal, Core ML), x86 (AVX instruction set), POWER (VSX instruction set).
- Supports multiple GPU/NPU accelerations: NVIDIA (cuBLAS and custom CUDA kernels), AMD ROCm, AMD Ryzen AI NPU (VitisAI), OpenVINO (x86 CPU and Intel GPU), Ascend NPU (CANN), Moore Threads GPU (muBLAS and MUSA kernels), Vulkan.
- Built-in voice activity detection (VAD).
- Supported platforms: macOS (Intel and Arm), Linux/FreeBSD, Windows (MSVC and MinGW).
Usage
- Clone the repository and enter the directory.
- Download a Whisper model already converted to ggml format (e.g., base.en).
- Build the whisper-cli example and transcribe an audio file. For a quick demo, run
make base.en, this command will download the base.en model and perform inference on all .wav samples in the samples folder. - For detailed usage, run
./build/bin/whisper-cli -h. Note: whisper-cli currently only supports 16-bit WAV files; other formats need to be converted in advance using tools such as ffmpeg.
Acceleration and Extensions
- Core ML: On Apple Silicon, the encoder can be executed via Core ML on the Apple Neural Engine (ANE), with speed improvements of more than 3x. Python dependencies need to be installed and a Core ML model generated, then build with
-DWHISPER_COREML=1. The first run is slower, and subsequent runs are faster. - ANEForge: On Apple Silicon, the encoder can also be dispatched directly to the ANE via ANEForge, about 2x faster than the Core ML encoder (tiny to medium models), with no build flags required.
- OpenVINO: On platforms that support OpenVINO, the encoder can execute on x86 CPU and Intel GPU. An OpenVINO model needs to be generated and build with
-DWHISPER_OPENVINO=1. - AMD Ryzen AI NPU: On AMD Ryzen AI 300/400 series processors, the encoder can be fully offloaded to the NPU. XRT and FlexML runtimes need to be installed, and the VitisAI encoder cache downloaded.
- NVIDIA GPU: Accelerated through cuBLAS and custom CUDA kernels. CUDA needs to be installed and built with CUDA support.
- Vulkan: A cross-vendor GPU acceleration solution that requires graphics driver support for the Vulkan API.
- AMD GPU: Accelerated through HIP/ROCm. ROCm needs to be installed and built with HIP support.
- OpenBLAS: Accelerates encoder processing on the CPU through OpenBLAS.
- Ascend NPU: Accelerated through CANN and AI cores. The CANN toolkit needs to be installed and built with CANN support.
- Moore Threads GPU: Accelerated through muBLAS and custom MUSA kernels. The MUSA SDK needs to be installed.
Applicable Scenarios
whisper.cpp is suitable for scenarios requiring offline, localized speech transcription, such as local dictation applications, offline voice assistants, speech recognition on embedded devices, and developers who need to integrate it into different platforms and applications. Its lightweight implementation makes it easy to run completely offline on devices such as the iPhone.
Limitations
- The whisper-cli example currently only supports 16-bit WAV files; other formats need to be converted in advance.
- Some acceleration features (such as Core ML, OpenVINO, Ryzen AI NPU) require additional dependency installation and generation of specific models, and the first run may be slower.
- The build methods and dependency requirements vary across different hardware platforms, so the corresponding documentation should be consulted.
- The official materials do not provide information such as fees, pricing, or performance promises.