Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/actions/build-whisper/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ inputs:
whisper-cpp-repo:
description: 'The whisper.cpp repository to use'
required: true
default: 'dharmab/whisper.cpp'
default: 'ggml-org/whisper.cpp'
whisper-cpp-version:
description: 'The version of whisper.cpp to use'
required: true
default: 'v1.7.2-windows-fix'
default: 'v1.8.4'
os:
description: 'The operating system to build for'
required: true
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/skyeye.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ jobs:
install: |
base-devel
git
mingw-w64-ucrt-x86_64-cmake
mingw-w64-ucrt-x86_64-gcc
mingw-w64-ucrt-x86_64-toolchain
mingw-w64-ucrt-x86_64-opus
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM golang:1.26 AS builder
RUN apt-get update && apt-get install -y \
git \
make \
cmake \
lsb-release \
gcc \
libopus-dev \
Expand Down
43 changes: 33 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,21 @@ SKYEYE_BIN = skyeye
SKYEYE_SCALER_BIN = skyeye-scaler

WHISPER_CPP_PATH = third_party/whisper.cpp
LIBWHISPER_PATH = $(WHISPER_CPP_PATH)/libwhisper.a
WHISPER_CPP_BUILD_DIR = $(WHISPER_CPP_PATH)/build_go
LIBWHISPER_PATH = $(WHISPER_CPP_BUILD_DIR)/src/libwhisper.a
WHISPER_H_PATH = $(WHISPER_CPP_PATH)/include/whisper.h
WHISPER_CPP_REPO = https://github.com/dharmab/whisper.cpp.git
WHISPER_CPP_VERSION = v1.7.2-windows-fix
WHISPER_CPP_BUILD_ENV =
WHISPER_CPP_REPO = https://github.com/ggml-org/whisper.cpp.git
WHISPER_CPP_VERSION = v1.8.4
WHISPER_CPP_CMAKE_ARGS =

# Compiler variables and flags
GOBUILDVARS = GOARCH=$(GOARCH)
ABS_WHISPER_CPP_PATH = $(abspath $(WHISPER_CPP_PATH))
ABS_WHISPER_CPP_BUILD_DIR = $(abspath $(WHISPER_CPP_BUILD_DIR))
LIBRARY_PATHS = $(ABS_WHISPER_CPP_BUILD_DIR)/src:$(ABS_WHISPER_CPP_BUILD_DIR)/ggml/src
BUILD_VARS = CGO_ENABLED=1 \
C_INCLUDE_PATH="$(ABS_WHISPER_CPP_PATH)/ggml/include:$(ABS_WHISPER_CPP_PATH)/include" \
LIBRARY_PATH="$(ABS_WHISPER_CPP_PATH)"
LIBRARY_PATH="$(LIBRARY_PATHS)"
BUILD_FLAGS = -tags nolibopusfile

# Populate --version from Git tag
Expand All @@ -50,8 +53,11 @@ ifeq ($(OS_DISTRIBUTION),macOS)
CC=$(shell brew --prefix llvm)/bin/clang
CXX=$(shell brew --prefix llvm)/bin/clang++
BUILD_VARS += CC=$(CC) CXX=$(CXX)
# Enable GPU acceleration
WHISPER_CPP_BUILD_ENV = GGML_METAL=1
LIBRARY_PATHS := $(LIBRARY_PATHS):$(ABS_WHISPER_CPP_BUILD_DIR)/ggml/src/ggml-metal:$(ABS_WHISPER_CPP_BUILD_DIR)/ggml/src/ggml-blas
# Link OpenMP runtime for ggml-cpu on macOS (Go bindings only specify -fopenmp on Linux)
BUILD_VARS += CGO_LDFLAGS=-fopenmp
WHISPER_CPP_CMAKE_ARGS = -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX) \
-DCMAKE_C_FLAGS=-Wno-elaborated-enum-base -DCMAKE_CXX_FLAGS=-Wno-elaborated-enum-base
endif

# Windows-specific settings
Expand All @@ -62,12 +68,14 @@ SKYEYE_SCALER_BIN = skyeye-scaler.exe
# Override Windows Go environment with MSYS2 UCRT64 Go environment
GO = /ucrt64/bin/go
GOBUILDVARS += GOROOT="/ucrt64/lib/go" GOPATH="/ucrt64"
# Use MSYS Makefiles generator for cmake on MSYS2
WHISPER_CPP_CMAKE_ARGS = -G "MSYS Makefiles"
# Static linking on Windows to avoid MSYS2 dependency at runtime
LIBRARIES = opus soxr
CFLAGS = $(shell pkg-config $(LIBRARIES) --cflags --static)
BUILD_VARS += CFLAGS='$(CFLAGS)'
EXTLDFLAGS = $(shell pkg-config $(LIBRARIES) --libs --static)
LDFLAGS += -linkmode external -extldflags "$(EXTLDFLAGS) -static"
LDFLAGS += -linkmode external -extldflags "$(EXTLDFLAGS) -lgomp -static"
endif

BUILD_VARS += LDFLAGS='$(LDFLAGS)'
Expand All @@ -82,6 +90,7 @@ install-msys2-dependencies:
pacman -Syu --needed \
git \
base-devel \
$(MINGW_PACKAGE_PREFIX)-cmake \
$(MINGW_PACKAGE_PREFIX)-toolchain \
$(MINGW_PACKAGE_PREFIX)-go \
$(MINGW_PACKAGE_PREFIX)-opus \
Expand All @@ -92,6 +101,7 @@ install-arch-linux-dependencies:
sudo pacman -Syu \
git \
base-devel \
cmake \
go \
opus \
libsoxr
Expand All @@ -102,6 +112,7 @@ install-debian-dependencies:
sudo apt-get install -y \
git \
build-essential \
cmake \
golang-go \
libopus-dev \
libopus0 \
Expand All @@ -114,6 +125,7 @@ install-fedora-dependencies:
git \
development-tools \
c-development \
cmake \
golang \
opus-devel \
opus \
Expand All @@ -125,6 +137,7 @@ install-macos-dependencies:
xcode-select --install || true
brew install \
git \
cmake \
llvm \
pkg-config \
go \
Expand All @@ -136,8 +149,18 @@ download-whisper-%:
curl -L -o $*.bin https://huggingface.co/ggerganov/whisper.cpp/resolve/main/$*.bin

$(LIBWHISPER_PATH) $(WHISPER_H_PATH):
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
if [ -f third_party/whisper.cpp/whisper.a ] && [ ! -f $(LIBWHISPER_PATH) ]; then cp third_party/whisper.cpp/whisper.a $(LIBWHISPER_PATH); fi
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)" && \
cmake -S "$(WHISPER_CPP_PATH)" -B "$(WHISPER_CPP_BUILD_DIR)" \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
$(WHISPER_CPP_CMAKE_ARGS) && \
cmake --build "$(WHISPER_CPP_BUILD_DIR)" --target whisper && \
for f in $$(find "$(WHISPER_CPP_BUILD_DIR)" -name '*.a' ! -name 'lib*'); do \
mv "$$f" "$$(dirname $$f)/lib$$(basename $$f)"; \
done; \
fi

.PHONY: whisper
whisper: $(LIBWHISPER_PATH) $(WHISPER_H_PATH)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/dharmab/goacmi v1.0.3
github.com/dharmab/numwords v1.0.1
github.com/gammazero/deque v0.2.1
github.com/ggerganov/whisper.cpp/bindings/go v0.0.0-20241121150429-8c6a9b8bb6a0
github.com/ggerganov/whisper.cpp/bindings/go v0.0.0-20260319084013-9386f2394010
github.com/go-audio/aiff v1.1.0
github.com/gofrs/flock v0.13.0
github.com/gopxl/beep/v2 v2.0.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ github.com/fzipp/gocyclo v0.6.0 h1:lsblElZG7d3ALtGMx9fmxeTKZaLLpU8mET09yN4BBLo=
github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA=
github.com/gammazero/deque v0.2.1 h1:qSdsbG6pgp6nL7A0+K/B7s12mcCY/5l5SIUpMOl+dC0=
github.com/gammazero/deque v0.2.1/go.mod h1:LFroj8x4cMYCukHJDbxFCkT+r9AndaJnFMuZDV34tuU=
github.com/ggerganov/whisper.cpp/bindings/go v0.0.0-20241121150429-8c6a9b8bb6a0 h1:vSv0WhsCkhau0BdC1H7Q2lHR8pzz0skaQkXZdEPYp/4=
github.com/ggerganov/whisper.cpp/bindings/go v0.0.0-20241121150429-8c6a9b8bb6a0/go.mod h1:qyHjS/50ORo01H0NsuEEGsQR9VCtOcEye0gUl2sx1s8=
github.com/ggerganov/whisper.cpp/bindings/go v0.0.0-20260319084013-9386f2394010 h1:+m6yO3VYSAUUzpG9lz4ktBx0cCba/Nvww8OKDgnapQQ=
github.com/ggerganov/whisper.cpp/bindings/go v0.0.0-20260319084013-9386f2394010/go.mod h1:qyHjS/50ORo01H0NsuEEGsQR9VCtOcEye0gUl2sx1s8=
github.com/ghostiam/protogetter v0.3.20 h1:oW7OPFit2FxZOpmMRPP9FffU4uUpfeE/rEdE1f+MzD0=
github.com/ghostiam/protogetter v0.3.20/go.mod h1:FjIu5Yfs6FT391m+Fjp3fbAYJ6rkL/J6ySpZBfnODuI=
github.com/go-audio/aiff v1.1.0 h1:m2LYgu/2BarpF2yZnFPWtY3Tp41k0A4y51gDRZZsEuU=
Expand Down
1 change: 1 addition & 0 deletions pkg/recognizer/whisper.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func (r *whisperRecognizer) Recognize(ctx context.Context, sample []float32, ena

err = wCtx.Process(
sample,
nil,
func(segment whisper.Segment) {
event := log.Debug()
if enableTranscriptionLogging {
Expand Down
Loading