whisper.cpp README

The project's README from github.com/ggml-org/whisper.cpp. As one markdown file: README.md.

whisper.cpp

whisper.cpp

License: MIT Release Actions Status Conan Center npm

High-performance inference of OpenAI's Whisper automatic speech recognition (ASR) model:

Supported platforms:

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:

For more information about the Core ML implementation please refer to PR #566.

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:

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

Install the XRT runtime and FlexML runtime for your platform:

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 .rai cache, 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

Ascend NPU support

Ascend NPU provides inference acceleration via CANN and AI cores.

First, check if your Ascend NPU device is supported:

Verified devices

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:

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

Images

We have multiple Docker images available for this project:

  1. ghcr.io/ggml-org/whisper.cpp:main: This image includes the main executable file as well as curl and ffmpeg. (platforms: linux/amd64, linux/arm64)
  2. ghcr.io/ggml-org/whisper.cpp:main-cuda: Same as main but compiled with CUDA support. (platforms: linux/amd64)
  3. ghcr.io/ggml-org/whisper.cpp:main-musa: Same as main but compiled with MUSA support. (platforms: linux/amd64)
  4. ghcr.io/ggml-org/whisper.cpp:main-vulkan: Same as main but compiled with Vulkan support. (platforms: linux/amd64)

Usage

# download model and persist it in a local folder
docker run -it --rm \
  -v path/to/models:/models \
  whisper.cpp:main "./models/download-ggml-model.sh base /models"

# transcribe an audio file
docker run -it --rm \
  -v path/to/models:/models \
  -v path/to/audios:/audios \
  whisper.cpp:main "whisper-cli -m /models/ggml-base.bin -f /audios/jfk.wav"

# transcribe an audio file in samples folder
docker run -it --rm \
  -v path/to/models:/models \
  whisper.cpp:main "whisper-cli -m /models/ggml-base.bin -f ./

whisper.cpp (ggml-org/whisper.cpp)

embedded
Searching Database…

What is this?whisper.cpp is a high-performance C/C++ port of OpenAI's Whisper automatic speech recognition (ASR) model, letting you transcribe audio to text without Python or heavy ML frameworks.
Is this a library or a standalone CLI tool?Both: it's a lightweight C-style library (whisper.h/whisper.cpp built on the ggml ML library) that you can embed in apps, plus it ships a whisper-cli example binary for direct command-line transcription.
How do I get it running?Clone the repo, download a ggml-format Whisper model (e.g. via the provided download script), then build the whisper-cli example and run it on a 16-bit WAV file; `make base.en` gives a quick demo with sample audio.
Do I need any extra frameworks or SDKs installed?The core library has no external dependencies, but optional acceleration backends require their own SDKs: CUDA for NVIDIA, ROCm/HIP for AMD, OpenVINO, CANN for Ascend NPUs, MUSA SDK for Moore Threads, or OpenBLAS for CPU BLAS.
Any gotchas when running the CLI?The whisper-cli example only accepts 16-bit WAV audio, so other formats must first be converted (e.g. with ffmpeg).
Does it only run well on Apple Silicon, or other hardware too?Apple Silicon is a first-class target (NEON, Accelerate, Metal, Core ML), but it also runs on Intel/AMD x86 via AVX or Vulkan/CUDA/ROCm, on POWER architectures via VSX, and on ARM boards like Raspberry Pi.
Which platforms are officially supported?Mac OS (Intel and Arm), iOS, Android, Linux/FreeBSD, WebAssembly, Windows (MSVC and MinGW), Raspberry Pi, and Docker.
Does it process audio offline on-device?Yes, it's designed to run entirely offline on-device, as demonstrated by a fully offline voice-assistant example running on an iPhone.
How much memory do the different Whisper model sizes need?Memory usage scales with model size: tiny uses about 273 MB, base 388 MB, small 852 MB, medium 2.1 GB, and large about 3.9 GB.
Can I shrink the models to save disk space?Yes, whisper.cpp supports integer quantization of the ggml models, which reduces memory and disk usage and can speed up processing depending on the hardware.
What accelerates performance on Apple Silicon specifically?On Apple Silicon the encoder can run on the Apple Neural Engine via Core ML, giving more than 3x speedup over CPU-only execution, and Metal runs inference fully on the GPU.
Are there ready-made Docker images?Yes, prebuilt images are published at ghcr.io/ggml-org/whisper.cpp with variants for the base CLI, CUDA, MUSA, and Vulkan support.
Creator
ggml-org
Size
46 MB
Stars
54.5K
Age
4y
Commits · 90 Days