Skip to content

Commit 0b502e2

Browse files
committed
subtitleswindow builds for windows with CUDA (not checked, yet)
1 parent 7435fc6 commit 0b502e2

File tree

6 files changed

+165
-62
lines changed

6 files changed

+165
-62
lines changed

.github/workflows/build.yaml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: build
2+
on: [workflow_call]
3+
4+
jobs:
5+
build:
6+
runs-on: ubuntu-24.04
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
target:
11+
- name: ENABLE_CUDA=true stt-linux-amd64
12+
artifact: stt-linux-amd64-cuda
13+
- name: stt-linux-amd64
14+
artifact: stt-linux-amd64-cpu
15+
- name: ENABLE_CUDA=true sttd-linux-amd64
16+
artifact: sttd-linux-amd64-cuda
17+
- name: sttd-linux-amd64
18+
artifact: sttd-linux-amd64-cpu
19+
- name: ENABLE_CUDA=true subtitleswindow-linux-amd64
20+
artifact: subtitleswindow-linux-amd64-cuda
21+
- name: subtitleswindow-linux-amd64
22+
artifact: subtitleswindow-linux-amd64-cpu
23+
- name: ENABLE_CUDA=true subtitleswindow-windows-amd64
24+
artifact: subtitleswindow-windows-amd64-cuda
25+
- name: subtitleswindow-windows-amd64
26+
artifact: subtitleswindow-windows-amd64-cpu
27+
name: build
28+
steps:
29+
- uses: actions/checkout@v4
30+
- name: setup go
31+
uses: actions/setup-go@v5
32+
with:
33+
go-version: '1.23'
34+
check-latest: true
35+
- name: add ffmpeg7 repo
36+
run: sudo add-apt-repository -y ppa:ubuntuhandbook1/ffmpeg7
37+
- name: add nvidia repo
38+
run: |
39+
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb && \
40+
sudo dpkg -i cuda-keyring_1.1-1_all.deb && \
41+
sudo apt-get update \
42+
- name: install fyne
43+
run: go install fyne.io/fyne/v2/cmd/fyne@latest
44+
- name: apt install
45+
run: |
46+
sudo apt install -fy \
47+
libavcodec-dev \
48+
libavformat-dev \
49+
libavfilter-dev \
50+
libavdevice-dev \
51+
libswscale-dev \
52+
libsrt-openssl-dev \
53+
libssl-dev \
54+
libasound2-dev \
55+
libxxf86vm-dev \
56+
make \
57+
cmake \
58+
nvidia-cuda-toolkit \
59+
cuda-toolkit-12-2 \
60+
libxcursor-dev \
61+
libxrandr-dev \
62+
libxinerama-dev \
63+
libxi-dev \
64+
gcc-mingw-w64-x86-64-win32 \
65+
g++-mingw-w64-x86-64-win32 \
66+
- name: apt clean
67+
run: sudo apt clean
68+
- name: make ${{ matrix.target.name }}
69+
run: make ${{ matrix.target.name }} INSTALL_DEST=build/${{ matrix.target.artifact }}
70+
- name: upload-artifact
71+
uses: actions/upload-artifact@v4
72+
with:
73+
name: ${{ matrix.target.artifact }}
74+
path: build/${{ matrix.target.artifact }}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: rolling-release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- test/ci
8+
9+
jobs:
10+
build:
11+
uses: ./.github/workflows/build.yaml
12+
rolling-release:
13+
name: rolling-release
14+
needs: [build]
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: download stt-linux-amd64-cuda
18+
uses: actions/download-artifact@v4
19+
with:
20+
name: stt-linux-amd64-cuda
21+
- name: download stt-linux-amd64
22+
uses: actions/download-artifact@v4
23+
with:
24+
name: stt-linux-amd64
25+
- name: download sttd-linux-amd64-cuda
26+
uses: actions/download-artifact@v4
27+
with:
28+
name: sttd-linux-amd64-cuda
29+
- name: download sttd-linux-amd64
30+
uses: actions/download-artifact@v4
31+
with:
32+
name: sttd-linux-amd64
33+
- name: download subtitleswindow-linux-amd64
34+
uses: actions/download-artifact@v4
35+
with:
36+
name: subtitleswindow-linux-amd64
37+
- name: download subtitleswindow-linux-amd64-cuda
38+
uses: actions/download-artifact@v4
39+
with:
40+
name: subtitleswindow-linux-amd64-cuda
41+
- name: download subtitleswindow-windows-amd64
42+
uses: actions/download-artifact@v4
43+
with:
44+
name: subtitleswindow-windows-amd64
45+
- name: get the timestamp
46+
id: date
47+
run: echo "::set-output name=date::$(date +'%Y-%m-%d_%H%M%S')"
48+
- uses: "marvinpinto/action-automatic-releases@latest"
49+
with:
50+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
51+
prerelease: true
52+
automatic_release_tag: unstable-${{ steps.date.outputs.date }}
53+
files: |
54+
stt-linux-amd64-cuda
55+
stt-linux-amd64
56+
sttd-linux-amd64-cuda
57+
sttd-linux-amd64
58+
subtitleswindow-linux-amd64-cuda
59+
subtitleswindow-linux-amd64
60+
subtitleswindow-windows-amd64

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ BUILD_DATE_STRING?=$(shell date +%s)
6767

6868
LINKER_FLAGS?=-X=github.com/xaionaro-go/buildvars.GitCommit=$(GIT_COMMIT) -X=github.com/xaionaro-go/buildvars.Version=$(VERSION_STRING) -X=github.com/xaionaro-go/buildvars.BuildDateString=$(BUILD_DATE_STRING)
6969

70-
WINDOWS_EXTLINKER_FLAGS?=-L$(PWD)/thirdparty/windows/portaudio-binaries/ -L$(PWD)/thirdparty/windows/amd64/ffmpeg-n7.0-21-gfb8f0ea7b3-win64-gpl-shared-7.0/lib
70+
WINDOWS_EXTLINKER_FLAGS?=-L$(PWD)/thirdparty/windows/portaudio-binaries/ -L$(PWD)/thirdparty/windows/amd64/ffmpeg-n7.0-21-gfb8f0ea7b3-win64-gpl-shared-7.0/lib -L$(PWD)/thirdparty/windows/amd64/cuda_12.2/libcublas/cublas_dev/lib/x64/ -L$(PWD)/thirdparty/windows/amd64/cuda_12.2/cuda_cudart/cudart/lib/x64/ -L$(PWD)/thirdparty/windows/amd64/whisper/ -lwhisper
7171

7272
LINKER_FLAGS_ANDROID?=$(LINKER_FLAGS)
7373
LINKER_FLAGS_DARWIN?=$(LINKER_FLAGS)
@@ -111,7 +111,9 @@ thirdparty/portaudio/include/portaudio.h:
111111

112112
thirdparty/windows/amd64/ready:
113113
mkdir -p thirdparty/windows/amd64
114-
sh -c 'cd thirdparty/windows/amd64 && wget https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2024-04-30-12-51/ffmpeg-n7.0-21-gfb8f0ea7b3-win64-gpl-shared-7.0.zip && unzip -o ffmpeg-n7.0-21-gfb8f0ea7b3-win64-gpl-shared-7.0.zip && rm -f ffmpeg-n7.0-21-gfb8f0ea7b3-win64-gpl-shared-7.0.zip'
114+
sh -c 'cd thirdparty/windows/amd64 && wget -nc -q --show-progress https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2024-04-30-12-51/ffmpeg-n7.0-21-gfb8f0ea7b3-win64-gpl-shared-7.0.zip && unzip -o ffmpeg-n7.0-21-gfb8f0ea7b3-win64-gpl-shared-7.0.zip && rm -f ffmpeg-n7.0-21-gfb8f0ea7b3-win64-gpl-shared-7.0.zip'
115+
sh -c 'cd thirdparty/windows/amd64 && wget -nc -q --show-progress https://developer.download.nvidia.com/compute/cuda/12.2.0/local_installers/cuda_12.2.0_536.25_windows.exe && 7z x -y -ocuda_12.2 cuda_12.2.0_536.25_windows.exe && rm -f cuda_12.2.0_536.25_windows.exe'
116+
sh -c 'cd thirdparty/windows/amd64 && wget -nc -q --show-progress https://github.com/xaionaro/whisper-prebuilds/releases/download/99b011a9f5e63f71/whisper-cublas-12.2.0-bin-x64.zip && mkdir whisper && cd whisper && unzip ../whisper-cublas-12.2.0-bin-x64.zip && rm -f ../whisper-cublas-12.2.0-bin-x64.zip'
115117
touch thirdparty/windows/amd64/ready
116118

117119
pkg/speech/speechtotext/implementations/whisper/pkgconfig/libwhisper.pc:
@@ -147,7 +149,7 @@ subtitleswindow-linux-amd64: build deps
147149

148150
subtitleswindow-windows-amd64: build deps windows-deps
149151
$(eval INSTALL_DEST?=build/subtitleswindow-windows-amd64.exe)
150-
PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) CGO_ENABLED=1 CGO_LDFLAGS="-static" CGO_CFLAGS="$(WINDOWS_CGO_FLAGS)" CC=x86_64-w64-mingw32-gcc GOOS=windows go build $(GOBUILD_FLAGS) -ldflags "$(LINKER_FLAGS_WINDOWS)" -o "$(INSTALL_DEST)" ./cmd/subtitleswindow
152+
PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) CGO_ENABLED=1 CGO_LDFLAGS="" CGO_CFLAGS="$(WINDOWS_CGO_FLAGS)" CC=x86_64-w64-mingw32-gcc GOOS=windows go build $(GOBUILD_FLAGS) -ldflags "$(LINKER_FLAGS_WINDOWS)" -o "$(INSTALL_DEST)" ./cmd/subtitleswindow
151153
$(eval undefine INSTALL_DEST)
152154

153155
example-stt: stt-$(shell go env GOOS)-$(shell go env GOARCH)

pkg/subtitleswindow/speech_recognizer.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ import (
1111
"fyne.io/fyne/v2/widget"
1212
"github.com/facebookincubator/go-belt/tool/logger"
1313
"github.com/hashicorp/go-multierror"
14+
syswhisper "github.com/mutablelogic/go-whisper/sys/whisper"
1415
"github.com/xaionaro-go/observability"
1516
"github.com/xaionaro-go/speech/pkg/speech"
1617
"github.com/xaionaro-go/speech/pkg/speech/speechtotext/client"
18+
"github.com/xaionaro-go/speech/pkg/speech/speechtotext/implementations/whisper"
1719
"github.com/xaionaro-go/speech/pkg/speech/speechtotext/implementations/whisper/types"
1820
"github.com/xaionaro-go/speech/pkg/speech/speechtotext/server/goconv"
1921
"github.com/xaionaro-go/speech/pkg/speech/speechtotext/server/proto/go/speechtotext_grpc"
@@ -295,3 +297,27 @@ func (r *speechRecognizer) Close() error {
295297
})
296298
return mErr.ErrorOrNil()
297299
}
300+
301+
func initLocalSTT(
302+
ctx context.Context,
303+
gpu int,
304+
whisperModel []byte,
305+
language speech.Language,
306+
shouldTranslate bool,
307+
vadThreshold float64,
308+
) (speech.ToText, error) {
309+
var opts whisper.Options
310+
if gpu >= 0 {
311+
opts = append(opts, whisper.OptionGPUDeviceID(gpu))
312+
}
313+
return whisper.New(
314+
ctx,
315+
whisperModel,
316+
language,
317+
types.SamplingStrategyBreamSearch,
318+
shouldTranslate,
319+
syswhisper.AlignmentAheadsPresetNone,
320+
vadThreshold,
321+
opts...,
322+
)
323+
}

pkg/subtitleswindow/speech_recognizer_notwindows.go

Lines changed: 0 additions & 37 deletions
This file was deleted.

pkg/subtitleswindow/speech_recognizer_windows.go

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)