Skip to content

Commit 3557a3f

Browse files
dharmabclaude
andcommitted
Upgrade whisper.cpp from v1.7.2 fork to upstream v1.8.4
Switch from dharmab/whisper.cpp fork (v1.7.2-windows-fix) to upstream ggml-org/whisper.cpp v1.8.4. The Windows build fix from the fork is now in upstream. - Replace Make-based build with CMake - Update LIBRARY_PATH for new cmake output layout (split ggml libraries) - Add CGO_LDFLAGS=-fopenmp on macOS for ggml-cpu OpenMP linkage - Pass CMAKE_C_COMPILER/CMAKE_CXX_COMPILER on macOS for Homebrew LLVM - Add cmake to all platform dependency install targets and CI - Update Go module to v1.8.4 bindings - Adapt Process() call for new 4-argument signature (added EncoderBeginCallback) Benchmarked on M4 MacBook Air: small model 0.26-0.46s (baseline 0.35-0.5s), medium model 0.86-1.07s (baseline 1.1-1.5s) — ~20-30% faster on medium. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 163a3cf commit 3557a3f

7 files changed

Lines changed: 34 additions & 14 deletions

File tree

.github/actions/build-whisper/action.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ inputs:
44
whisper-cpp-repo:
55
description: 'The whisper.cpp repository to use'
66
required: true
7-
default: 'dharmab/whisper.cpp'
7+
default: 'ggml-org/whisper.cpp'
88
whisper-cpp-version:
99
description: 'The version of whisper.cpp to use'
1010
required: true
11-
default: 'v1.7.2-windows-fix'
11+
default: 'v1.8.4'
1212
os:
1313
description: 'The operating system to build for'
1414
required: true

.github/workflows/skyeye.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ jobs:
137137
install: |
138138
base-devel
139139
git
140+
mingw-w64-ucrt-x86_64-cmake
140141
mingw-w64-ucrt-x86_64-gcc
141142
mingw-w64-ucrt-x86_64-toolchain
142143
mingw-w64-ucrt-x86_64-opus

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM golang:1.26 AS builder
33
RUN apt-get update && apt-get install -y \
44
git \
55
make \
6+
cmake \
67
lsb-release \
78
gcc \
89
libopus-dev \

Makefile

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,21 @@ SKYEYE_BIN = skyeye
2424
SKYEYE_SCALER_BIN = skyeye-scaler
2525

2626
WHISPER_CPP_PATH = third_party/whisper.cpp
27-
LIBWHISPER_PATH = $(WHISPER_CPP_PATH)/libwhisper.a
27+
WHISPER_CPP_BUILD_DIR = $(WHISPER_CPP_PATH)/build_go
28+
LIBWHISPER_PATH = $(WHISPER_CPP_BUILD_DIR)/src/libwhisper.a
2829
WHISPER_H_PATH = $(WHISPER_CPP_PATH)/include/whisper.h
29-
WHISPER_CPP_REPO = https://github.com/dharmab/whisper.cpp.git
30-
WHISPER_CPP_VERSION = v1.7.2-windows-fix
31-
WHISPER_CPP_BUILD_ENV =
30+
WHISPER_CPP_REPO = https://github.com/ggml-org/whisper.cpp.git
31+
WHISPER_CPP_VERSION = v1.8.4
32+
WHISPER_CPP_CMAKE_ARGS =
3233

3334
# Compiler variables and flags
3435
GOBUILDVARS = GOARCH=$(GOARCH)
3536
ABS_WHISPER_CPP_PATH = $(abspath $(WHISPER_CPP_PATH))
37+
ABS_WHISPER_CPP_BUILD_DIR = $(abspath $(WHISPER_CPP_BUILD_DIR))
38+
LIBRARY_PATHS = $(ABS_WHISPER_CPP_BUILD_DIR)/src:$(ABS_WHISPER_CPP_BUILD_DIR)/ggml/src
3639
BUILD_VARS = CGO_ENABLED=1 \
3740
C_INCLUDE_PATH="$(ABS_WHISPER_CPP_PATH)/ggml/include:$(ABS_WHISPER_CPP_PATH)/include" \
38-
LIBRARY_PATH="$(ABS_WHISPER_CPP_PATH)"
41+
LIBRARY_PATH="$(LIBRARY_PATHS)"
3942
BUILD_FLAGS = -tags nolibopusfile
4043

4144
# Populate --version from Git tag
@@ -50,8 +53,10 @@ ifeq ($(OS_DISTRIBUTION),macOS)
5053
CC=$(shell brew --prefix llvm)/bin/clang
5154
CXX=$(shell brew --prefix llvm)/bin/clang++
5255
BUILD_VARS += CC=$(CC) CXX=$(CXX)
53-
# Enable GPU acceleration
54-
WHISPER_CPP_BUILD_ENV = GGML_METAL=1
56+
LIBRARY_PATHS := $(LIBRARY_PATHS):$(ABS_WHISPER_CPP_BUILD_DIR)/ggml/src/ggml-metal:$(ABS_WHISPER_CPP_BUILD_DIR)/ggml/src/ggml-blas
57+
# Link OpenMP runtime for ggml-cpu on macOS (Go bindings only specify -fopenmp on Linux)
58+
BUILD_VARS += CGO_LDFLAGS=-fopenmp
59+
WHISPER_CPP_CMAKE_ARGS = -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX)
5560
endif
5661

5762
# Windows-specific settings
@@ -82,6 +87,7 @@ install-msys2-dependencies:
8287
pacman -Syu --needed \
8388
git \
8489
base-devel \
90+
$(MINGW_PACKAGE_PREFIX)-cmake \
8591
$(MINGW_PACKAGE_PREFIX)-toolchain \
8692
$(MINGW_PACKAGE_PREFIX)-go \
8793
$(MINGW_PACKAGE_PREFIX)-opus \
@@ -92,6 +98,7 @@ install-arch-linux-dependencies:
9298
sudo pacman -Syu \
9399
git \
94100
base-devel \
101+
cmake \
95102
go \
96103
opus \
97104
libsoxr
@@ -102,6 +109,7 @@ install-debian-dependencies:
102109
sudo apt-get install -y \
103110
git \
104111
build-essential \
112+
cmake \
105113
golang-go \
106114
libopus-dev \
107115
libopus0 \
@@ -114,6 +122,7 @@ install-fedora-dependencies:
114122
git \
115123
development-tools \
116124
c-development \
125+
cmake \
117126
golang \
118127
opus-devel \
119128
opus \
@@ -125,6 +134,7 @@ install-macos-dependencies:
125134
xcode-select --install || true
126135
brew install \
127136
git \
137+
cmake \
128138
llvm \
129139
pkg-config \
130140
go \
@@ -136,8 +146,15 @@ download-whisper-%:
136146
curl -L -o $*.bin https://huggingface.co/ggerganov/whisper.cpp/resolve/main/$*.bin
137147

138148
$(LIBWHISPER_PATH) $(WHISPER_H_PATH):
139-
if [ ! -f $(LIBWHISPER_PATH) -o ! -f $(WHISPER_H_PATH) ]; then git -C "$(WHISPER_CPP_PATH)" checkout --quiet $(WHISPER_CPP_VERSION) || git clone --depth 1 --branch $(WHISPER_CPP_VERSION) -c advice.detachedHead=false "$(WHISPER_CPP_REPO)" "$(WHISPER_CPP_PATH)" && $(WHISPER_CPP_BUILD_ENV) make -C $(WHISPER_CPP_PATH)/bindings/go whisper; fi
140-
if [ -f third_party/whisper.cpp/whisper.a ] && [ ! -f $(LIBWHISPER_PATH) ]; then cp third_party/whisper.cpp/whisper.a $(LIBWHISPER_PATH); fi
149+
if [ ! -f $(LIBWHISPER_PATH) -o ! -f $(WHISPER_H_PATH) ]; then \
150+
git -C "$(WHISPER_CPP_PATH)" checkout --quiet $(WHISPER_CPP_VERSION) || \
151+
git clone --depth 1 --branch $(WHISPER_CPP_VERSION) -c advice.detachedHead=false "$(WHISPER_CPP_REPO)" "$(WHISPER_CPP_PATH)" && \
152+
cmake -S "$(WHISPER_CPP_PATH)" -B "$(WHISPER_CPP_BUILD_DIR)" \
153+
-DCMAKE_BUILD_TYPE=Release \
154+
-DBUILD_SHARED_LIBS=OFF \
155+
$(WHISPER_CPP_CMAKE_ARGS) && \
156+
cmake --build "$(WHISPER_CPP_BUILD_DIR)" --target whisper; \
157+
fi
141158

142159
.PHONY: whisper
143160
whisper: $(LIBWHISPER_PATH) $(WHISPER_H_PATH)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/dharmab/goacmi v1.0.3
1212
github.com/dharmab/numwords v1.0.1
1313
github.com/gammazero/deque v0.2.1
14-
github.com/ggerganov/whisper.cpp/bindings/go v0.0.0-20241121150429-8c6a9b8bb6a0
14+
github.com/ggerganov/whisper.cpp/bindings/go v0.0.0-20260319084013-9386f2394010
1515
github.com/go-audio/aiff v1.1.0
1616
github.com/gofrs/flock v0.13.0
1717
github.com/gopxl/beep/v2 v2.0.3

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ github.com/fzipp/gocyclo v0.6.0 h1:lsblElZG7d3ALtGMx9fmxeTKZaLLpU8mET09yN4BBLo=
210210
github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA=
211211
github.com/gammazero/deque v0.2.1 h1:qSdsbG6pgp6nL7A0+K/B7s12mcCY/5l5SIUpMOl+dC0=
212212
github.com/gammazero/deque v0.2.1/go.mod h1:LFroj8x4cMYCukHJDbxFCkT+r9AndaJnFMuZDV34tuU=
213-
github.com/ggerganov/whisper.cpp/bindings/go v0.0.0-20241121150429-8c6a9b8bb6a0 h1:vSv0WhsCkhau0BdC1H7Q2lHR8pzz0skaQkXZdEPYp/4=
214-
github.com/ggerganov/whisper.cpp/bindings/go v0.0.0-20241121150429-8c6a9b8bb6a0/go.mod h1:qyHjS/50ORo01H0NsuEEGsQR9VCtOcEye0gUl2sx1s8=
213+
github.com/ggerganov/whisper.cpp/bindings/go v0.0.0-20260319084013-9386f2394010 h1:+m6yO3VYSAUUzpG9lz4ktBx0cCba/Nvww8OKDgnapQQ=
214+
github.com/ggerganov/whisper.cpp/bindings/go v0.0.0-20260319084013-9386f2394010/go.mod h1:qyHjS/50ORo01H0NsuEEGsQR9VCtOcEye0gUl2sx1s8=
215215
github.com/ghostiam/protogetter v0.3.20 h1:oW7OPFit2FxZOpmMRPP9FffU4uUpfeE/rEdE1f+MzD0=
216216
github.com/ghostiam/protogetter v0.3.20/go.mod h1:FjIu5Yfs6FT391m+Fjp3fbAYJ6rkL/J6ySpZBfnODuI=
217217
github.com/go-audio/aiff v1.1.0 h1:m2LYgu/2BarpF2yZnFPWtY3Tp41k0A4y51gDRZZsEuU=

pkg/recognizer/whisper.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func (r *whisperRecognizer) Recognize(ctx context.Context, sample []float32, ena
4848

4949
err = wCtx.Process(
5050
sample,
51+
nil,
5152
func(segment whisper.Segment) {
5253
event := log.Debug()
5354
if enableTranscriptionLogging {

0 commit comments

Comments
 (0)