Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Installation

Once tagged releases are published, prebuilt binaries install with PIE on macOS arm64, Linux x86_64, and Linux arm64, for PHP 8.3 / 8.4 / 8.5:

php pie.phar install displace/ext-whisper

From source

Requirements: Rust (the version pinned in rust-toolchain.toml installs automatically), cmake, and a C/C++ toolchain.

git clone https://github.com/DisplaceTech/ext-whisper
cd ext-whisper
make build                 # target/debug/libwhisper.{so,dylib}
php -d extension=$PWD/target/debug/libwhisper.so \
    -r 'var_dump(extension_loaded("whisper"));'

Get a model

Models come from the whisper.cpp zoo on Hugging Face:

mkdir -p models
curl -L -o models/ggml-tiny.en.bin \
  https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-tiny.en.bin
ModelSizeNotes
tiny.en75MBEnglish-only; fast; fine for clean speech
base.en142MBNoticeably better punctuation/names
small466MBMultilingual; the quality sweet spot on CPU

Verify

php -d extension=$PWD/target/debug/libwhisper.so examples/transcribe.php \
    models/ggml-tiny.en.bin tests/fixtures/jfk.wav

Expected output starts with “And so my fellow Americans…”.