需先单独下载 ggml 格式模型文件,仓库不含模型权重;whisper-cli 只接受 16-bit WAV,其他格式需先用 ffmpeg 转换;启用 CUDA/ROCm/Vulkan 等 GPU 后端需在 cmake 时加对应 -DGGML_* 开关并预装相应 SDK。
whisper.cpp
ggml-orgMIT活跃维护OpenAI Whisper 语音识别模型的 C/C++ 移植版,无需 Python 和 GPU 依赖,在普通 CPU 上就能跑语音转文字。
Port of OpenAI's Whisper model in C/C++
git clone https://github.com/ggml-org/whisper.cpp.git && cd whisper.cpp && sh ./models/download-ggml-model.sh base.en && cmake -B build && cmake --build build -j --config Release && ./build/bin/whisper-cli -f samples/jfk.wav支持纯 CPU 推理;GPU 可选 NVIDIA(CUDA)、AMD(ROCm)、Vulkan、华为昇腾 NPU、摩尔线程 GPU、AMD Ryzen AI NPU 等后端。README 未给出具体显存要求,仅列出各模型内存占用:tiny 约 273 MB、base 约 388 MB、small 约 852 MB、medium 约 2.1 GB、large 约 3.9 GB。
OpenAI Whisper 语音识别模型的 C/C++ 移植版,无需依赖即可在各类设备上离线转写音频
OpenAI Whisper 语音识别模型的 C/C++ 移植版,无需 Python 和 GPU 依赖,在普通 CPU 上就能跑语音转文字。
核心能力
- 纯 C/C++ 实现,不依赖外部库
- 支持整数量化,显著降低内存与磁盘占用
- Apple Silicon 上通过 Metal/Core ML 加速编码器
- 支持 NVIDIA CUDA、AMD ROCm、Vulkan 等多种 GPU 后端
- 内置 VAD 语音活动检测与 C 风格 API
容易踩的坑
- v1.9.5最新正式版2026-10-06 · 2026-10-06 17:39 UTC
Overview
Maintenance release. Updates to ggml v0.26.0.
Nightly build: b5454 More info: dist : releases and versioning of ggml-org projects
Changelog since v1.9.4
d1be6fde whisper : bump version to 1.9.5 (#4102) 4afec37b talk-llama : update llama.cpp to v0.6.0 3d451abe sync : ggml 47f1c7dc ggml : bump version to 0.26.0 (ggml/1652) e71b7844 CUDA: make the alloc_deps check batch independent (llama/29986) cdc87302 vulkan: fix Flash Attention shmem write out of bounds (llama/29988) 563a9f7a vulkan: revert mul_mat_id tile selection PR #29182 (llama/29936) ebb8a170 cuda: use the vector lightning indexer kernel on MUSA (llama/29990) 8c6ca4ab CUDA: Optimize accumulation in mmq for NVFP4 type (llama/29857) 82fa9df7 vulkan: fix stale prealloc_y reuse across flash attention and soft_max (llama/29591) f6915422 vulkan: sparse flash attention for quantized K/V (llama/29639) d477de3c llama : fix unexpected graph reallocation in the k-pool models (llama/29958) 95283ca7 ggml-cpu : add Q8_0 IME1 matrix kernel for SpacemiT X60 (llama/28479) 155c5c28 vulkan : Fix undeclared identifiers when -DGGML_VULKAN_RUN_TESTS=ON (llama/29912) 7091d4a2 webgpu: add MMVQ support for Q1_0/Q5_0/Q5_1/Q3_K/Q5_K/Q6_K/MXFP4 (llama/29483) 4cc62b81 cuda: tile the lightning indexer over keys and tokens for 4 heads (llama/29901) 7e576cbd metal : few-row MMA mat-mul (llama/29869) 91da4702 CUDA: use MMVF for thin f16/bf16 mul_mat at small batch size (llama/29633) 8bb85d96 CUDA: prefer whole-tile FlashAttention scheduling for efficient two-stage kernels (llama/29435) ce6552ef CUDA: refactor swizzling code (llama/29612) bfe3dc63 ggml-cpu: support BF16/FP16/FP32 K tails in tinyBLAS on x86 (llama/29806) 25453c0a cuda : move neu_padded to where it is used (llama/29940) 7914776a cuda : move blocks_per_col to where it is used (llama/29939) 6421d2c1 CUDA: fix MMQ memory fault if n_expert >> n_ubatch (llama/29941) 05d4d89a vulkan: fix rdna4 mat_vec tuning (llama/29934) 51bfbd61 webgpu: add f16 support to fill/set_rows (llama/29897) f2aa80ad ggml-openvino: update to 2026.4.1, optimize performance, expand ops, improve device listing. (llama/29852) 7f4a67a5 qwen4exp : halve the indexer score memory (llama/29825) cf5d9e30 CUDA: fuse shared experts into MMVQ (llama/29184) d7682b58 ggml-cuda : fix cpy transposed path corrupting non-contiguous dst (llama/27663) 6b704713 ggml-quants : avoid invalid rounding in qkx3 scale search (llama/29817) 0b35d1f3 ggml-cpu : fix soft_max_back wrong output when dst aliases src1 (llama/27096) d0dc4363 metal : add tensor API flash attention kernel for F16 KV (llama/29570) cca8f72b opencl: use sigmoid f16 for bf16 (llama/29787) cd1bee52 SYCL: Q8_0 DMMV ESIMD and MMVQ wide load (llama/29186) 95a05ed4 vulkan: disable large matmul tile on Samsung GPUs with 32KB shared memory (llama/28531) c4051a33 sycl: large register file for D=512 FA vec kernels (llama/29062) ae92605f sycl : do not use slow oneDNN reference matmul and fattn (llama/28985) 9c968f7e qwen4exp : optimize mask constructions (llama/29824) 4435763c ggml : add
alloc_buffer_nto buffer type interface (llama/23671) 8291ab84 vulkan: add logging to pipeline compile issues (llama/29794) eaadab3d hexagon: install rebuilt HTP skels (llama/29828) 0295ef68 hexagon: add q2_k and q3_k quant type support (llama/29717) 396f68d3 CUDA: fix 2 broken Volta FA cases (llama/29803) 3a3598cc llama: refer to segment documentation [no ci] (llama/29074) 15229ac9 hexagon: shared strided DMA copy for CPY and CONCAT, any-dim CONCAT via DMA (llama/29685) aa538005 cuda : route sm70 to the Turing MMVQ nwarps table (llama/29753) 81ca4f81 metal : release temporary private transfer buffers (llama/29777) 88948bdb webgpu: add bfloat16 support for MUL_MAT/MUL_MAT_ID/GET_ROWS- #29358 (llama/29 - b5454pre-release2026-10-06 · 2026-10-06 16:51 UTC
这个版本没有写更新说明。
- v1.9.42026-09-11 · 2026-09-11 05:31 UTC
查看更新说明
Overview
New version has been released.
Nightly build: b5130 More info: dist : releases and versioning of ggml-org projects
Changelog since v1.9.3
927cfce3 metal : remove leftover ggml-metal.metal kernels file (#4051) dd80eb2a scripts : use sed instead of grep for version parsing [no ci] (#4052) 1fa6dfa0 ci : update WoA CUDA 13.4 to use 13.4.1 GA (#4053) a2b36eb6 whisper : bump version to 1.9.4 (#4050) 6fb4cd67 ci : add Windows On ARM support to release job (#4048) c44b60b8 whisper : call encoder_begin_callback before language auto-detect (#3936) 6d0ed914 whisper : re-seed decoder 0 between calls (#4025) cec4dbe5 ci : update close-issue job to not close issues (#4045) 79f2d921 tests : load backends before init when built with GGML_BACKEND_DL (#4031) 61e6ccad server : return language in detect response (#4035) 52a939a2 sync : ggml a937f4e8 ggml : bump version to 0.23.0 (ggml/1618) 11d4eec8 metal : add remaining fa-vec tunings for M3 Max (llama/28373) 140e57a4 ggml : replace compile definitions with version.h.in (llama/28364) e2389eb9 ggml : rename and make private ggml_op_alloc_size_may_expand() (ggml/0) 1b37bead ggml : don't crash when backend search path can't be read (llama/28271) f32e6fa0 ggml : remove GGML_CUDA_PEER_MAX_BATCH_SIZE (llama/28177) e1bbe405 ggml-cpu(s390x) : fix q5_1 uninitialized v_acc (llama/28332) d1e0e649 sycl: fuse rms_norm+mul+add and add+add residual chains (llama/27610) 36f170e5 SYCL: Refactor GGML_SYCL_ENABLE_MKL_FA to global var (llama/26863) d784add7 opencl: quant lm_head / decode GEMV and medium-batch GEMM optimizations (speculative decoding/MTP) (llama/26477) 0a4a95c8 tune MMVQ to MMQ crossover for SM87 (llama/28285) 4dd48dde metal : add sparse FA (llama/28098) d55d345e metal : fix glu dispatch with ne00 = 1 (llama/28306) 25350b57 CUDA: Allow concurrent streams per split for multi-GPU (llama/28198) 47d348a2 vulkan: fix FA dequant path engagement (llama/28190) f24a3860 sycl : enhance the api to support peer-to-peer copy (llama/27550) a704770e sycl: reduce redundant work in Q4_K multi-column MMVQ (llama/27062) e5605697 finetune: fix no KV cache (llama/27199) 37f0f443 ggml-hexagon: add F16 support for unary ops (llama/28228) 1bdda1e3 metal : add fa-vec tunings for M3 (llama/28236) 3a1c7d6b metal : fix memory query under low-memory conditions (llama/27701) 4d343d7c ggml-cuda : remove unused vars (llama/28235) 519df618 CUDA + ggml: add sparse-fa for DSV4/GLM (llama/27970) c2b40075 ggml: avoid KleidiAI buffer type init on dispatch (llama/27891) dc70853e hexagon: MUL_MAT and MUL_MAT_ID fusion and fixes (llama/28202) 1c7d35e1 vulkan: handle larger batch sizes (>4) efficiently for IQ3_S mat-vec (llama/27449) a9e58612 vulkan : only request VK_KHR_shader_bfloat16 extension if supported (llama/28155) d57ae982 ggml-cpu : conditionally add SpacemiT IME kernel sources (llama/27961) 35133c94 opencl: fix out‐of‐bound reads in the Adreno image kernels (#27632) c94921f8 hexagon: add missing FARF logs for cpy/get_rows/set_rows/gdn ops (llama/28217) fcc2feee metal : add metallib build support for xcframework (llama/28163) 2c486783 cuda: fuse MoE weighted expert reduction (llama/25952) f162a194 Revert "sycl : add Kronecker product FWHT support for sizes 384, 640, 768, 12…" (#28184) 408faaaf sycl : add Kronecker product FWHT support for sizes 384, 640, 768, 1280 (llama/28016) 5f07f856 metal : add fa-vec tuning for M2 Pro (llama/28122) 8cca1a36 metal : add fa-vec tunings for A18 Pro (MacBook Neo) (llama/28152) a245a8f4 metal : fix more leaks due to missing autoreleasepools (llama/27883) 870db2af metal : add fa-vec tuning for M2 Max (llama/28015) 4f3a2a4b sycl : support limit max alloc memory within 2GB for host-pinned memory (llama/27559) 5032008b metal: enable Metal 4.0 tensor API on M5+/A19+ (llama/27461) 8e54c659 metal : add fa-vec tunings for M1 Ultra (llama/28088) f22bb2ea CUDA: XOR sw
- b5130pre-release2026-09-11 · 2026-09-11 05:29 UTC
这个版本没有写更新说明。
- b5127pre-release2026-09-10 · 2026-09-10 11:55 UTC
查看更新说明
Note: the Windows arm64 (CUDA) build (
whisper-bin-win-cuda-*-arm64.zip) uses a preview edition of the CUDA Toolkit for Windows on Arm and should be considered experimental.
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
whisper.cpp

High-performance inference of OpenAI's Whisper automatic speech recognition (ASR) model:
- Plain C/C++ implementation without dependencies
- Apple Silicon first-class citizen - optimized via ARM NEON, Accelerate framework, Metal and Core ML
- AVX intrinsics support for x86 architectures
- VSX intrinsics support for POWER architectures
- Mixed F16 / F32 precision
- Integer quantization support
- Zero memory allocations at runtime
- Vulkan support
- Support for CPU-only inference
- Efficient GPU support for NVIDIA
- AMD ROCm GPU support
- AMD Ryzen AI NPU Support
- OpenVINO Support
- Huawei Ascend NPU Support
- Moore Threads GPU Support
- C-style API
- Voice Activity Detection (VAD)
Supported platforms:
- Mac OS (Intel and Arm)
- iOS
- Android
- Java
- Linux / FreeBSD
- WebAssembly
- Windows (MSVC and MinGW)
- Raspberry Pi
- Docker
The entire high-level implementation of the model is contained in whisper.h and whisper.cpp.
The rest of the code is part of the ggml machine learning library.
Having such a lightweight implementation of the model allows to easily integrate it in different platforms and applications. As an example, here is a video of running the model on an iPhone 13 device - fully offline, on-device: whisper.objc
https://user-images.githubusercontent.com/1991296/197385372-962a6dea-bca1-4d50-bf96-1d8c27b98c81.mp4
You can also easily make your own offline voice assistant application: command
https://user-images.githubusercontent.com/1991296/204038393-2f846eae-c255-4099-a76d-5735c25c49da.mp4
On Apple Silicon, the inference runs fully on the GPU via Metal:
https://github.com/ggml-org/whisper.cpp/assets/1991296/c82e8f86-60dc-49f2-b048-d2fdbd6b5225
Quick start
First clone the repository:
git clone https://github.com/ggml-org/whisper.cpp.git
Navigate into the directory:
cd whisper.cpp
Then, download one of the Whisper models converted in ggml format. For example:
sh ./models/download-ggml-model.sh base.en
Now build the whisper-cli example and transcribe an audio file like this:
# build the project
cmake -B build
cmake --build build -j --config Release
# transcribe an audio file
./build/bin/whisper-cli -f samples/jfk.wav
For a quick demo, simply run make base.en.
The command downloads the base.en model converted to custom ggml format and runs the inference on all .wav samples in the folder samples.
For detailed usage instructions, run: ./build/bin/whisper-cli -h
Note that the whisper-cli example currently runs only with 16-bit WAV files, so make sure to convert your input before running the tool.
For example, you can use ffmpeg like this:
ffmpeg -i input.mp3 -ar 16000 -ac 1 -c:a pcm_s16le output.wav
More audio samples
If you want some extra audio samples to play with, simply run:
make -j samples
This will download a few more audio files from Wikipedia and convert them to 16-bit WAV format via ffmpeg.
You can download and run the other models as follows:
make -j tiny.en
make -j tiny
make -j base.en
make -j base
make -j small.en
make -j small
make -j medium.en
make -j medium
make -j large-v1
make -j large-v2
make -j large-v3
make -j large-v3-turbo
Memory usage
| Model | Disk | Mem |
|---|---|---|
| tiny | 75 MiB | ~273 MB |
| base | 142 MiB | ~388 MB |
| small | 466 MiB | ~852 MB |
| medium | 1.5 GiB | ~2.1 GB |
| large | 2.9 GiB | ~3.9 GB |
POWER VSX Intrinsics
whisper.cpp supports POWER architectures and includes code which
significantly speeds operation on Linux running on POWER9/10, making it
capable of faster-than-realtime transcription on underclocked Raptor
Talos II. Ensure you have a BLAS package installed, and replace the
standard cmake setup with:
# build with GGML_BLAS defined
cmake -B build -DGGML_BLAS=1
cmake --build build -j --config Release
./build/bin/whisper-cli [ .. etc .. ]
Quantization
whisper.cpp supports integer quantization of the Whisper ggml models.
Quantized models require less memory and disk space and depending on the hardware can be processed more efficiently.
Here are the steps for creating and using a quantized model:
# quantize a model with Q5_0 method
cmake -B build
cmake --build build -j --config Release
./build/bin/quantize models/ggml-base.en.bin models/ggml-base.en-q5_0.bin q5_0
# run the examples as usual, specifying the quantized model file
./build/bin/whisper-cli -m models/ggml-base.en-q5_0.bin ./samples/gb0.wav
Core ML support
On Apple Silicon devices, the Encoder inference can be executed on the Apple Neural Engine (ANE) via Core ML. This can result in significant
speed-up - more than x3 faster compared with CPU-only execution. Here are the instructions for generating a Core ML model and using it with whisper.cpp:
-
Install Python dependencies needed for the creation of the Core ML model:
pip install ane_transformers pip install openai-whisper pip install coremltools- To ensure
coremltoolsoperates correctly, please confirm that Xcode is installed and executexcode-select --installto install the command-line tools. - Python 3.11 is recommended.
- MacOS Sonoma (version 14) or newer is recommended, as older versions of MacOS might experience issues with transcription hallucination.
- [OPTIONAL] It is recommended to utilize a Python version management system, such as Miniconda for this step:
- To create an environment, use:
conda create -n py311-whisper python=3.11 -y - To activate the environment, use:
conda activate py311-whisper
- To create an environment, use:
- To ensure
-
Generate a Core ML model. For example, to generate a
base.enmodel, use:./models/generate-coreml-model.sh base.enThis will generate the folder
models/ggml-base.en-encoder.mlmodelc -
Build
whisper.cppwith Core ML support:# using CMake cmake -B build -DWHISPER_COREML=1 cmake --build build -j --config Release -
Run the examples as usual. For example:
$ ./build/bin/whisper-cli -m models/ggml-base.en.bin -f samples/jfk.wav ... whisper_init_state: loading Core ML model from 'models/ggml-base.en-encoder.mlmodelc' whisper_init_state: first run on a device may take a while ... whisper_init_state: Core ML model loaded system_info: n_threads = 4 / 10 | AVX = 0 | AVX2 = 0 | AVX512 = 0 | FMA = 0 | NEON = 1 | ARM_FMA = 1 | F16C = 0 | FP16_VA = 1 | WASM_SIMD = 0 | BLAS = 1 | SSE3 = 0 | VSX = 0 | COREML = 1 | ...The first run on a device is slow, since the ANE service compiles the Core ML model to some device-specific format. Next runs are faster.
For more information about the Core ML implementation please refer to PR #566.
ANEForge support
On Apple Silicon, the Encoder can also run on the Apple Neural Engine via ANEForge, which dispatches to the ANE directly instead of through Core ML.
It is about 2x faster than the Core ML encoder from tiny to medium (benchmarks).
The Decoder is unchanged, and no build flag is needed.
Compile the encoder into a bundle (tied to the machine and OS build that produced it):
git clone https://github.com/sbryngelson/ANEForge && cd ANEForge
pip install -e ".[models]"
PYTHONPATH=. python3 bench/whisper_encoder_ane/export_bundle.py \
--model openai/whisper-base --out /tmp/whisper-base-encoder
Then point whisper.cpp at it:
export ANEFORGE_ENCODER=/tmp/whisper-base-encoder
export ANEFORGE_DYLIB=$PWD/aneforge/_lib/libane_e5rt_dispatch.dylib
./build/bin/whisper-cli -m models/ggml-base.bin -f samples/jfk.wav
For more information about the ANEForge implementation, see PR #3905.
OpenVINO support
On platforms that support OpenVINO, the Encoder inference can be executed on OpenVINO-supported devices including x86 CPUs and Intel GPUs (integrated & discrete).
This can result in significant speedup in encoder performance. Here are the instructions for generating the OpenVINO model and using it with whisper.cpp:
-
First, setup python virtual env. and install python dependencies. Python 3.10 is recommended.
Windows:
cd models python -m venv openvino_conv_env openvino_conv_env\Scripts\activate python -m pip install --upgrade pip pip install -r requirements-openvino.txtLinux and macOS:
cd models python3 -m venv openvino_conv_env source openvino_conv_env/bin/activate python -m pip install --upgrade pip pip install -r requirements-openvino.txt -
Generate an OpenVINO encoder model. For example, to generate a
base.enmodel, use:python convert-whisper-to-openvino.py --model base.enThis will produce ggml-base.en-encoder-openvino.xml/.bin IR model files. It's recommended to relocate these to the same folder as
ggmlmodels, as that is the default location that the OpenVINO extension will search at runtime. -
Build
whisper.cppwith OpenVINO support:Download OpenVINO package from release page. The recommended version to use is 2026.3.0. Ready to use Binaries of the required libraries can be found in the OpenVino Archives
After downloading & extracting package onto your development system, set up required environment by sourcing setupvars script. For example:
Linux:
source /path/to/openvino_toolkit_ubuntu/setupvars.shWindows (cmd):
C:\Path\To\openvino_toolkit_windows\setupvars.batAnd then build the project using cmake:
cmake -B build -DWHISPER_OPENVINO=1 cmake --build build -j --config Release -
Run the examples as usual. For example:
$ ./build/bin/whisper-cli -m models/ggml-base.en.bin -f samples/jfk.wav ... whisper_ctx_init_openvino_encoder: loading OpenVINO model from 'models/ggml-base.en-encoder-openvino.xml' whisper_ctx_init_openvino_encoder: first run on a device may take a while ... whisper_openvino_init: path_model = models/ggml-base.en-encoder-openvino.xml, device = GPU, cache_dir = models/ggml-base.en-encoder-openvino-cache whisper_ctx_init_openvino_encoder: OpenVINO model loaded system_info: n_threads = 4 / 8 | AVX = 1 | AVX2 = 1 | AVX512 = 0 | FMA = 1 | NEON = 0 | ARM_FMA = 0 | F16C = 1 | FP16_VA = 0 | WASM_SIMD = 0 | BLAS = 0 | SSE3 = 1 | VSX = 0 | COREML = 0 | OPENVINO = 1 | ...The first time run on an OpenVINO device is slow, since the OpenVINO framework will compile the IR (Intermediate Representation) model to a device-specific 'blob'. This device-specific blob will get cached for the next run.
For more information about the OpenVINO implementation please refer to PR #1037.
AMD Ryzen™ AI NPU support
On AMD Ryzen™ AI 300 and 400 Series processors with a dedicated NPU, whisper.cpp can fully offload the Whisper encoder to the NPU via VitisAI, delivering significant speedup over CPU-only inference.
Prerequisites
Supported Platforms
- Windows 11
- Linux (Ubuntu 24.04 LTS, Python 3.12)
Install the XRT runtime and FlexML runtime for your platform:
- XRT: provides the NPU kernel driver and
xrt-smidiagnostic tool — on Windows this is bundled with the NPU driver; on Linux install it separately following the NPU driver installation guide - FlexML runtime (
flexmlrt): VitisAI inference engine used by whisper.cpp — download from the FlexML runtime releases
After installing, source the setup scripts in every shell you use to build or run whisper.cpp:
# Linux
source /opt/xilinx/xrt/setup.sh
source /path/to/flexmlrt/setup.sh
:: Windows
cd /path/to/flexmlrt && call setup.bat
You can verify the NPU is visible with:
xrt-smi examine
Download models
Download the ggml model and the matching prebuilt VitisAI encoder cache:
# Linux / macOS
sh ./models/download-ggml-model.sh base
sh ./models/download-vitisai-model.sh base
:: Windows
.\models\download-ggml-model.cmd base
.\models\download-vitisai-model.cmd base
Use the same model name with both scripts. To see all available VitisAI encoder caches:
sh ./models/download-vitisai-model.sh --list
.\models\download-vitisai-model.cmd --list
The VitisAI script queries the AMD Ryzen AI Whisper NPU collection on Hugging Face and downloads the .rai encoder cache as models/ggml-<model>-encoder-vitisai.rai.
Depending on the
.raicache, VitisAI may offload the encoder only, or the encoder plus cross-projection layers. whisper.cpp detects this at runtime and logs the selected offload mode during model initialization.
Build
cmake -B build -DWHISPER_VITISAI=1
cmake --build build -j --config Release
Run
./build/bin/whisper-cli -m models/ggml-base.bin -f samples/jfk.wav
For more information see the Ryzen AI documentation.
NVIDIA GPU support
With NVIDIA cards the processing of the models is done efficiently on the GPU via cuBLAS and custom CUDA kernels.
First, make sure you have installed cuda: https://developer.nvidia.com/cuda-downloads
Now build whisper.cpp with CUDA support:
cmake -B build -DGGML_CUDA=1
cmake --build build -j --config Release
or for newer NVIDIA GPU's (RTX 5000 series):
cmake -B build -DGGML_CUDA=1 -DCMAKE_CUDA_ARCHITECTURES="86"
cmake --build build -j --config Release
Vulkan GPU support
Cross-vendor solution which allows you to accelerate workload on your GPU. First, make sure your graphics card driver provides support for Vulkan API.
Now build whisper.cpp with Vulkan support:
cmake -B build -DGGML_VULKAN=1
cmake --build build -j --config Release
AMD ROCm GPU support
With AMD GPUs the processing can be accelerated via HIP/ROCm. First, make sure you have installed ROCm.
Now build whisper.cpp with HIP support:
cmake -B build -DGGML_HIP=1 -DAMDGPU_TARGETS="gfx1201"
cmake --build build -j --config Release
Replace gfx1201 with your GPU architecture. You can find it with:
rocminfo | grep "gfx"
Common architectures: gfx1100 (RX 7900 XTX), gfx1101 (RX 7800 XT), gfx1201 (RX 9070 XT).
For multiple GPUs with different architectures: -DAMDGPU_TARGETS="gfx1100;gfx1201".
BLAS CPU support via OpenBLAS
Encoder processing can be accelerated on the CPU via OpenBLAS.
First, make sure you have installed openblas: https://www.openblas.net/
Now build whisper.cpp with OpenBLAS support:
cmake -B build -DGGML_BLAS=1
cmake --build build -j --config Release
Huawei Ascend NPU support
Huawei Ascend NPU provides inference acceleration via CANN and AI cores.
First, check if your Huawei Ascend NPU device is supported:
Verified devices
| Huawei Ascend NPU | Status |
|---|---|
| Atlas 300T A2 | Support |
| Atlas 300I Duo | Support |
Then, make sure you have installed CANN toolkit . The latest version of CANN is recommended.
Now build whisper.cpp with CANN support:
cmake -B build -DGGML_CANN=1
cmake --build build -j --config Release
Run the inference examples as usual, for example:
./build/bin/whisper-cli -f samples/jfk.wav -m models/ggml-base.en.bin -t 8
Notes:
- If you have trouble with Huawei Ascend NPU device, please create a issue with [CANN] prefix/tag.
- If you run successfully with your Huawei Ascend NPU device, please help update the table
Verified devices.
Moore Threads GPU support
With Moore Threads cards the processing of the models is done efficiently on the GPU via muBLAS and custom MUSA kernels.
First, make sure you have installed MUSA SDK rc4.2.0: https://developer.mthreads.com/sdk/download/musa?equipment=&os=&driverVersion=&version=4.2.0
Now build whisper.cpp with MUSA support:
cmake -B build -DGGML_MUSA=1
cmake --build build -j --config Release
or specify the architecture for your Moore Threads GPU. For example, if you have a MTT S80 GPU, you can specify the architecture as follows:
cmake -B build -DGGML_MUSA=1 -DMUSA_ARCHITECTURES="21"
cmake --build build -j --config Release
FFmpeg support (examples only)
By default, the examples in this repo use the miniaudio library to decode audio files.
Some of the examples also can use FFmpeg for decoding and broader format support. To enable that, build with WHISPER_COMMON_FFMPEG.
First, you need to install required libraries:
# Debian/Ubuntu
sudo apt install libavcodec-dev libavformat-dev libavutil-dev
# RHEL/Fedora
sudo dnf install libavcodec-free-devel libavformat-free-devel libavutil-free-devel
Then you can build the project as follows:
cmake -B build -D WHISPER_COMMON_FFMPEG=yes
cmake --build build
Run the following example to confirm it's working:
# Convert an audio file to Opus format
ffmpeg -i samples/jfk.wav jfk.opus
# Transcribe the audio file
./build/bin/whisper-cli --model models/ggml-base.en.bin --file jfk.opus
Docker
Prerequisites
- Docker must be installed and running on your system.
- Create a folder to store big models & intermediate files (ex. /whisper/models)
Images
We have multiple Docker images available for this project:
ghcr.io/ggml-org/whisper.cpp:main: This image includes the main executable file as well ascurlandffmpeg. (platforms:linux/amd64,linux/arm64)ghcr.io/ggml-org/whisper.cpp:main-cuda: Same asmainbut compiled with CUDA support. (platforms:linux/amd64)ghcr.io/ggml-org/whisper.cpp:main-musa: Same asmainbut compiled with MUSA support. (platforms:linux/amd64)ghcr.io/ggml-org/whisper.cpp:main-vulkan: Same asmainbut compiled with Vulkan support. (platforms:linux/amd64)
Usage
# Use the main tag or: cublas, main-cuda, main-intel, main-musa, main-rocm, main-vulkan.
IMAGE="ghcr.io/ggml-org/whisper.cpp:main"
MODEL_PATH="/tmp/whisper.cpp-models"
AUDIO_PATH="/tmp/whisper.cpp-audio"
AUDIO_URL="https://github.com/ggml-org/whisper.cpp/raw/refs/heads/master/samples/jfk.wav"
mkdir -p "$MODEL_PATH" "$AUDIO_PATH"
wget -O "$AUDIO_PATH/jfk.wav" "$AUDIO_URL"
# download model and persist it in a local folder
docker run -it --rm \
-v $MODEL_PATH:/models \
$IMAGE \
download-ggml-model.sh base /models
# transcribe an audio file
docker run -it --rm \
-v $MODEL_PATH:/models \
-v $AUDIO_PATH:/audios \
$IMAGE \
whisper-cli -m /models/ggml-base.bin -f /audios/jfk.wav
# run the web server
docker run -it --rm \
-p "8080:8080" \
-v $MODEL_PATH:/models \
$IMAGE \
whisper-server --host 0.0.0.0 -m /models/ggml-base.bin
# then:
curl -v http://127.0.0.1:8080/inference \
-F "file=@${AUDIO_PATH}/jfk.wav" \
-F 'response_format=json'
# download small.en and run the bench on it using 4 threads
docker run -it --rm \
-v $MODEL_PATH:/models \
$IMAGE \
download-ggml-model.sh small.en /models
docker run -it --rm \
-v $MODEL_PATH:/models \
$IMAGE \
whisper-bench -m /models/ggml-small.en.bin -t 4
# the methods above use the CPU - use your GPU by sharing the device, for example, for an AMD iGPU via Vulkan:
docker run --rm \
--device /dev/dri \
-v $MODEL_PATH:/models \
"ghcr.io/ggml-org/whisper.cpp:main-vulkan" \
whisper-bench -m /models/ggml-small.en.bin -t 4
Installing with Conan
You can install pre-built binaries for whisper.cpp or build it from source using Conan. Use the following command:
conan install --requires="whisper-cpp/[*]" --build=missing
For detailed instructions on how to use Conan, please refer to the Conan documentation.
Limitations
- Inference only
Real-time audio input example
This is a naive example of performing real-time inference on audio from your microphone. The stream tool samples the audio every half a second and runs the transcription continuously. More info is available in issue #10. You will need to have sdl2 installed for it to work properly.
cmake -B build -DWHISPER_SDL2=ON
cmake --build build -j --config Release
./build/bin/whisper-stream -m ./models/ggml-base.en.bin -t 8 --step 500 --length 5000
https://user-images.githubusercontent.com/1991296/194935793-76afede7-cfa8-48d8-a80f-28ba83be7d09.mp4
Confidence color-coding
Adding the --print-colors argument will print the transcribed text using an experimental color coding strategy
to highlight words with high or low confidence:
./build/bin/whisper-cli -m models/ggml-base.en.bin -f samples/gb0.wav --print-colors
Controlling the length of the generated text segments (experimental)
For example, to limit the line length to a maximum of 16 characters, simply add -ml 16:
$ ./build/bin/whisper-cli -m ./models/ggml-base.en.bin -f ./samples/jfk.wav -ml 16
whisper_model_load: loading model from './models/ggml-base.en.bin'
...
system_info: n_threads = 4 / 10 | AVX2 = 0 | AVX512 = 0 | NEON = 1 | FP16_VA = 1 | WASM_SIMD = 0 | BLAS = 1 |
main: processing './samples/jfk.wav' (176000 samples, 11.0 sec), 4 threads, 1 processors, lang = en, task = transcribe, timestamps = 1 ...
[00:00:00.000 --> 00:00:00.850] And so my
[00:00:00.850 --> 00:00:01.590] fellow
[00:00:01.590 --> 00:00:04.140] Americans, ask
[00:00:04.140 --> 00:00:05.660] not what your
[00:00:05.660 --> 00:00:06.840] country can do
[00:00:06.840 --> 00:00:08.430] for you, ask
[00:00:08.430 --> 00:00:09.440] what you can do
[00:00:09.440 --> 00:00:10.020] for your
[00:00:10.020 --> 00:00:11.000] country.
Word-level timestamp (experimental)
The --max-len argument can be used to obtain word-level timestamps. Simply use -ml 1:
$ ./build/bin/whisper-cli -m ./models/ggml-base.en.bin -f ./samples/jfk.wav -ml 1
whisper_model_load: loading model from './models/ggml-base.en.bin'
...
system_info: n_threads = 4 / 10 | AVX2 = 0 | AVX512 = 0 | NEON = 1 | FP16_VA = 1 | WASM_SIMD = 0 | BLAS = 1 |
main: processing './samples/jfk.wav' (176000 samples, 11.0 sec), 4 threads, 1 processors, lang = en, task = transcribe, timestamps = 1 ...
[00:00:00.000 --> 00:00:00.320]
[00:00:00.320 --> 00:00:00.370] And
[00:00:00.370 --> 00:00:00.690] so
[00:00:00.690 --> 00:00:00.850] my
[00:00:00.850 --> 00:00:01.590] fellow
[00:00:01.590 --> 00:00:02.850] Americans
[00:00:02.850 --> 00:00:03.300] ,
[00:00:03.300 --> 00:00:04.140] ask
[00:00:04.140 --> 00:00:04.990] not
[00:00:04.990 --> 00:00:05.410] what
[00:00:05.410 --> 00:00:05.660] your
[00:00:05.660 --> 00:00:06.260] country
[00:00:06.260 --> 00:00:06.600] can
[00:00:06.600 --> 00:00:06.840] do
[00:00:06.840 --> 00:00:07.010] for
[00:00:07.010 --> 00:00:08.170] you
[00:00:08.170 --> 00:00:08.190] ,
[00:00:08.190 --> 00:00:08.430] ask
[00:00:08.430 --> 00:00:08.910] what
[00:00:08.910 --> 00:00:09.040] you
[00:00:09.040 --> 00:00:09.320] can
[00:00:09.320 --> 00:00:09.440] do
[00:00:09.440 --> 00:00:09.760] for
[00:00:09.760 --> 00:00:10.020] your
[00:00:10.020 --> 00:00:10.510] country
[00:00:10.510 --> 00:00:11.000] .
Speaker segmentation via tinydiarize (experimental)
More information about this approach is available here: https://github.com/ggml-org/whisper.cpp/pull/1058
Sample usage:
# download a tinydiarize compatible model
./models/download-ggml-model.sh small.en-tdrz
# run as usual, adding the "-tdrz" command-line argument
./build/bin/whisper-cli -f ./samples/a13.wav -m ./models/ggml-small.en-tdrz.bin -tdrz
...
main: processing './samples/a13.wav' (480000 samples, 30.0 sec), 4 threads, 1 processors, lang = en, task = transcribe, tdrz = 1, timestamps = 1 ...
...
[00:00:00.000 --> 00:00:03.800] Okay Houston, we've had a problem here. [SPEAKER_TURN]
[00:00:03.800 --> 00:00:06.200] This is Houston. Say again please. [SPEAKER_TURN]
[00:00:06.200 --> 00:00:08.260] Uh Houston we've had a problem.
[00:00:08.260 --> 00:00:11.320] We've had a main beam up on a volt. [SPEAKER_TURN]
[00:00:11.320 --> 00:00:13.820] Roger main beam interval. [SPEAKER_TURN]
[00:00:13.820 --> 00:00:15.100] Uh uh [SPEAKER_TURN]
[00:00:15.100 --> 00:00:18.020] So okay stand, by thirteen we're looking at it. [SPEAKER_TURN]
[00:00:18.020 --> 00:00:25.740] Okay uh right now uh Houston the uh voltage is uh is looking good um.
[00:00:27.620 --> 00:00:29.940] And we had a a pretty large bank or so.
Karaoke-style movie generation (experimental)
The whisper-cli example provides support for output of karaoke-style movies, where the
currently pronounced word is highlighted. Use the -owts argument and run the generated bash script.
This requires to have ffmpeg installed.
Here are a few "typical" examples:
./build/bin/whisper-cli -m ./models/ggml-base.en.bin -f ./samples/jfk.wav -owts
source ./samples/jfk.wav.wts
ffplay ./samples/jfk.wav.mp4
https://user-images.githubusercontent.com/1991296/199337465-dbee4b5e-9aeb-48a3-b1c6-323ac4db5b2c.mp4
./build/bin/whisper-cli -m ./models/ggml-base.en.bin -f ./samples/mm0.wav -owts
source ./samples/mm0.wav.wts
ffplay ./samples/mm0.wav.mp4
https://user-images.githubusercontent.com/1991296/199337504-cc8fd233-0cb7-4920-95f9-4227de3570aa.mp4
./build/bin/whisper-cli -m ./models/ggml-base.en.bin -f ./samples/gb0.wav -owts
source ./samples/gb0.wav.wts
ffplay ./samples/gb0.wav.mp4
https://user-images.githubusercontent.com/1991296/199337538-b7b0c7a3-2753-4a88-a0cd-f28a317987ba.mp4
Video comparison of different models
Use the scripts/bench-wts.sh script to generate a video in the following format:
./scripts/bench-wts.sh samples/jfk.wav
ffplay ./samples/jfk.wav.all.mp4
https://user-images.githubusercontent.com/1991296/223206245-2d36d903-cf8e-4f09-8c3b-eb9f9c39d6fc.mp4
Benchmarks
In order to have an objective comparison of the performance of the inference across different system configurations, use the whisper-bench tool. The tool simply runs the Encoder part of the model and prints how much time it took to execute it. The results are summarized in the following Github issue:
Additionally a script to run whisper.cpp with different models and audio files is provided bench.py.
You can run it with the following command, by default it will run against any standard model in the models folder.
python3 scripts/bench.py -f samples/jfk.wav -t 2,4,8 -p 1,2
It is written in python with the intention of being easy to modify and extend for your benchmarking use case.
It outputs a csv file with the results of the benchmarking.
ggml format
The original models are converted to a custom binary format. This allows to pack everything needed into a single file:
- model parameters
- mel filters
- vocabulary
- weights
You can download the converted models using the models/download-ggml-model.sh script or manually from here:
For more details, see the conversion script models/convert-pt-to-ggml.py or models/README.md.
Bindings
- Rust: tazz4843/whisper-rs | #310
- JavaScript: bindings/javascript | #309
- React Native (iOS / Android): whisper.rn
- Go: bindings/go | #312
- Java:
- Ruby: bindings/ruby | #507
- Objective-C / Swift: ggml-org/whisper.spm | #313
- .NET: | #422
- Python: | #9
- stlukey/whispercpp.py (Cython)
- AIWintermuteAI/whispercpp (Updated fork of aarnphm/whispercpp)
- aarnphm/whispercpp (Pybind11)
- abdeladim-s/pywhispercpp (Pybind11)
- R: bnosac/audio.whisper
- Unity: macoron/whisper.unity
XCFramework
The XCFramework is a precompiled version of the library for iOS, visionOS, tvOS, and macOS. It can be used in Swift projects without the need to compile the library from source. For example, the v1.7.5 version of the XCFramework can be used as follows:
// swift-tools-version: 5.10
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "Whisper",
targets: [
.executableTarget(
name: "Whisper",
dependencies: [
"WhisperFramework"
]),
.binaryTarget(
name: "WhisperFramework",
url: "https://github.com/ggml-org/whisper.cpp/releases/download/v1.7.5/whisper-v1.7.5-xcframework.zip",
checksum: "c7faeb328620d6012e130f3d705c51a6ea6c995605f2df50f6e1ad68c59c6c4a"
)
]
)
Voice Activity Detection (VAD)
Support for Voice Activity Detection (VAD) can be enabled using the --vad
argument to whisper-cli. In addition to this option a VAD model is also
required.
The way this works is that first the audio samples are passed through the VAD model which will detect speech segments. Using this information, only the speech segments that are detected are extracted from the original audio input and passed to whisper for processing. This reduces the amount of audio data that needs to be processed by whisper and can significantly speed up the transcription process.
The following VAD models are currently supported:
Silero-VAD
Silero-vad is a lightweight VAD model written in Python that is fast and accurate.
Models can be downloaded by running the following command on Linux or MacOS:
$ ./models/download-vad-model.sh silero-v6.2.0
Downloading ggml model silero-v6.2.0 from 'https://huggingface.co/ggml-org/whisper-vad' ...
ggml-silero-v6.2.0.bin 100%[==============================================>] 864.35K --.-KB/s in 0.04s
Done! Model 'silero-v6.2.0' saved in '/path/models/ggml-silero-v6.2.0.bin'
You can now use it like this:
$ ./build/bin/whisper-cli -vm /path/models/ggml-silero-v6.2.0.bin --vad -f samples/jfk.wav -m models/ggml-base.en.bin
And the following command on Windows:
> .\models\download-vad-model.cmd silero-v6.2.0
Downloading vad model silero-v6.2.0...
Done! Model silero-v6.2.0 saved in C:\Users\danie\work\ai\whisper.cpp\ggml-silero-v6.2.0.bin
You can now use it like this:
C:\path\build\bin\Release\whisper-cli.exe -vm C:\path\ggml-silero-v6.2.0.bin --vad -m models/ggml-base.en.bin -f samples\jfk.wav
To see a list of all available models, run the above commands without any arguments.
This model can be also be converted manually to ggml using the following command:
$ python3 -m venv venv && source venv/bin/activate
$ (venv) pip install silero-vad
$ (venv) $ python models/convert-silero-vad-to-ggml.py --output models/silero.bin
Saving GGML Silero-VAD model to models/silero-v6.2.0-ggml.bin
And it can then be used with whisper as follows:
$ ./build/bin/whisper-cli \
--file ./samples/jfk.wav \
--model ./models/ggml-base.en.bin \
--vad \
--vad-model ./models/silero-v6.2.0-ggml.bin
VAD Options
-
--vad-threshold: Threshold probability for speech detection. A probability for a speech segment/frame above this threshold will be considered as speech.
-
--vad-min-speech-duration-ms: Minimum speech duration in milliseconds. Speech segments shorter than this value will be discarded to filter out brief noise or false positives.
-
--vad-min-silence-duration-ms: Minimum silence duration in milliseconds. Silence periods must be at least this long to end a speech segment. Shorter silence periods will be ignored and included as part of the speech.
-
--vad-max-speech-duration-s: Maximum speech duration in seconds. Speech segments longer than this will be automatically split into multiple segments at silence points exceeding 98ms to prevent excessively long segments.
-
--vad-speech-pad-ms: Speech padding in milliseconds. Adds this amount of padding before and after each detected speech segment to avoid cutting off speech edges.
-
--vad-samples-overlap: Amount of audio to extend from each speech segment into the next one, in seconds (e.g., 0.10 = 100ms overlap). This ensures speech isn't cut off abruptly between segments when they're concatenated together.
Examples
There are various examples of using the library for different projects in the examples folder. Some of the examples are even ported to run in the browser using WebAssembly. Check them out!
| Example | Web | Description |
|---|---|---|
| whisper-cli | whisper.wasm | Tool for translating and transcribing audio using Whisper |
| whisper-bench | bench.wasm | Benchmark the performance of Whisper on your machine |
| whisper-stream | stream.wasm | Real-time transcription of raw microphone capture |
| whisper-command | command.wasm | Basic voice assistant example for receiving voice commands from the mic |
| whisper-server | HTTP transcription server with OAI-like API | |
| whisper-talk-llama | Talk with a LLaMA bot | |
| whisper.objc | iOS mobile application using whisper.cpp | |
| whisper.swiftui | SwiftUI iOS / macOS application using whisper.cpp | |
| whisper.android | Android mobile application using whisper.cpp | |
| whisper.nvim | Speech-to-text plugin for Neovim | |
| generate-karaoke.sh | Helper script to easily generate a karaoke video of raw audio capture | |
| livestream.sh | Livestream audio transcription | |
| yt-wsp.sh | Download + transcribe and/or translate any VOD (original) | |
| wchess | wchess.wasm | Voice-controlled chess |
Discussions
If you have any kind of feedback about this project feel free to use the Discussions section and open a new topic.
You can use the Show and tell category
to share your own projects that use whisper.cpp. If you have a question, make sure to check the
Frequently asked questions (#126) discussion.