221.2. whisper.cpp-1.9.4
Speech to text on the CPU or a Vulkan GPU, with the model on the disk and nothing sent anywhere
| Version | 1.9.4, release 2 |
| Shelf | ai — Machine learning inference, speech recognition, computer vision and neural translation |
| Phase | 42_graphics (Graphics Stack), 48 of 189 in build order |
| Licence | MIT |
| Homepage | https://github.com/ggml-org/whisper.cpp |
| Build time | 2.6 SBU |
| Installed size | 6.7 MiB in 23 files |
| Recipe | ports/core/ai/whisper.cpp/kpkgbuild |
About
whisper.cpp is a C/C++ implementation of OpenAI’s Whisper speech recognition, running on the processor or, through ggml’s Vulkan backend, on a GPU, with the model as a file on the disk and nothing sent anywhere. The package installs the library and the example programs, among them whisper-cli, which transcribes a file, and whisper-stream, which transcribes the microphone live. The English base model is the separate whisper-model-base-en port.
Why it is in KDOS
The comment above it in script/phases/42_graphics/packages.d/ai.txt:
Speech to text with the model on the disk and nothing sent anywhere, which is the whole reason it is here rather than in a box. The English base model is whisper-model-base-en; the others are hundreds of megabytes each, and picking one picks a language.
Sources
whisper.cpp-1.9.4.tar.gz(8.9 MiB)
sha25657e280cee375ab02425b806ad5146b99f6eb9357e3c2b31357c8a6af2e2e44ae
upstream: https://github.com/ggml-org/whisper.cpp/archive/refs/tags/v1.9.4.tar.gz
archive copy: sources-1/ai--whisper.cpp-1.9.4.tar.gz
Dependencies
Depends on: cmake, sdl2-compat, ffmpeg, libggml.
Required by (1): shotcut.
Patches
build.sh applies these; kpkg applies nothing by itself.
sdl2-stream-only.patch—WHISPER_SDL2builds four programs besidewhisper-stream, and talk-llama’s CMake fetches llama.cpp from GitHub at configure time, which ends an offline configure withCould not resolve host. No switch drops it, so the patch takescommand,talk-llama,lspandwchessout of the example subdirectories and the flag buildswhisper-streamalone.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/42_graphics/phase.env && kpkg install whisper.cpp'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/ai/whisper.cpp.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/ai/whisper.cpp
echo '57e280cee375ab02425b806ad5146b99f6eb9357e3c2b31357c8a6af2e2e44ae whisper.cpp-1.9.4.tar.gz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/whisper.cpp
SRC=$SRC_ROOT/whisper.cpp-1.9.4
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf whisper.cpp-1.9.4.tar.gz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
patch -p1 -i "$PORT_SRC/sdl2-stream-only.patch"
mkdir -p build && cd build
cmake .. -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=lib \
-DBUILD_SHARED_LIBS=ON -DWHISPER_BUILD_TESTS=OFF \
-DWHISPER_BUILD_EXAMPLES=ON -DWHISPER_SDL2=ON \
-DWHISPER_COMMON_FFMPEG=ON \
-DWHISPER_USE_SYSTEM_GGML=ON
make
make DESTDIR=$PKG install
[ ! -e "$PKG/usr/lib/libggml.so" ] && [ ! -d "$PKG/usr/lib/ggml" ] ||
{ echo "whisper.cpp: installed its own ggml over the libggml port" >&2; exit 1; }
The switches, and why each is set:
-DBUILD_SHARED_LIBS=ON— Buildlibwhisperas a shared library.-DWHISPER_BUILD_TESTS=OFF— Leave out the tests.-DWHISPER_BUILD_EXAMPLES=ON— Build the example programs, which are the command-line tools:whisper-cli,whisper-server,whisper-benchand the rest.-DWHISPER_SDL2=ON— Build the programs that read a microphone through SDL’s audio device, the one this port wants beingwhisper-stream, which transcribes a rolling window of live audio.SDL_Init(SDL_INIT_AUDIO)opens no window, so it runs in a terminal with no compositor. sdl2-compat provides SDL2.-DWHISPER_COMMON_FFMPEG=ON— Let the programs fall back to ffmpeg when the bundled miniaudio decoder, which reads WAV, MP3, FLAC and (through stb_vorbis) Ogg Vorbis, cannot open a file, sowhisper-clialso reads Opus, AAC and the audio track of a video.-DWHISPER_USE_SYSTEM_GGML=ON— Link the libggml port instead of building the copy of ggml in the tarball, so whisper.cpp and llama.cpp load one set of CPU, OpenBLAS and Vulkan backend modules from/usr/lib/ggml.build.shfails if the install put alibggml.soor a/usr/lib/ggmlof its own into the package, which would overwrite the port’s files.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/whisper.cpp, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf whisper.cpp-1.9.4-2.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/whisper.cpp, and runs the triggers its paths call for.
Contents
Installed programs: parakeet-cli, parakeet-quantize, whisper-bench, whisper-cli, whisper-quantize, whisper-server, whisper-stream, whisper-vad-speech-segments.
Installed libraries: libparakeet.so, libwhisper.so.
Installed directories: /usr/lib/cmake/parakeet, /usr/lib/cmake/whisper, /usr/share/licenses/whisper.cpp.
Short descriptions
parakeet.pc |
Port of NVIDIA's Parakeet model in C/C++ |
whisper.pc |
Port of OpenAI's Whisper model in C/C++ |