Skip to content
Closed
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
122 changes: 78 additions & 44 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ jobs:
run: >
cmake -S . -B ./build -A ${{ matrix.arch }}
-DCMAKE_BUILD_TYPE=${{ matrix.build }}
-DBUILD_SHARED_LIBS=ON
-DWHISPER_SDL2=${{ matrix.sdl2 }}

- name: Build
Expand All @@ -570,10 +571,17 @@ jobs:
if: matrix.sdl2 == 'ON'
run: copy "$env:SDL2_DIR/../lib/${{ matrix.s2arc }}/SDL2.dll" build/bin/${{ matrix.build }}

- name: Upload SDL2.dll
if: matrix.sdl2 == 'ON'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.s2arc }}_SDL2.dll
path: build/bin/${{ matrix.build }}/SDL2.dll

- name: Upload dll
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.jnaPath }}_whisper.dll
name: whisper_${{ matrix.arch }}.dll
path: build/bin/${{ matrix.build }}/whisper.dll

- name: Upload binaries
Expand Down Expand Up @@ -995,49 +1003,75 @@ jobs:
# chmod +x ./gradlew
# ./gradlew assembleRelease

# TODO: disabled because of following fail: https://github.com/ggerganov/whisper.cpp/actions/runs/9686220096/job/26735899598
# java:
# needs: [ 'windows' ]
# runs-on: windows-latest
# steps:
# - uses: actions/checkout@v4
#
# - name: Install Java
# uses: actions/setup-java@v4
# with:
# distribution: zulu
# java-version: 20
#
# - name: Download Windows lib
# uses: actions/download-artifact@v4
# with:
# name: win32-x86-64_whisper.dll
# path: bindings/java/build/generated/resources/main/win32-x86-64
#
# - name: Build
# run: |
# models\download-ggml-model.cmd tiny.en
# cd bindings/java
# chmod +x ./gradlew
# ./gradlew build
#
# - name: Upload jar
# uses: actions/upload-artifact@v4
# with:
# name: whispercpp.jar
# path: bindings/java/build/libs/whispercpp-*.jar
#
# - name: Publish package
# if: ${{ github.ref == 'refs/heads/master' }}
# uses: gradle/[email protected]
# with:
# arguments: publish
# build-root-directory: bindings/java
# env:
# MAVEN_USERNAME: ${{ secrets.JIRA_USER }}
# MAVEN_PASSWORD: ${{ secrets.JIRA_PASS }}
# PGP_SECRET: ${{ secrets.GPG_PRIVATE_KEY }}
# PGP_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
bindings-java:
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
github.event.inputs.run_type == 'full-ci' }}
needs: ['windows']
runs-on: windows-latest
steps:
- uses: actions/checkout@v4

- name: Install Java
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 20

- name: Download Windows lib
uses: actions/download-artifact@v4
with:
name: whisper_x64.dll

- name: Download SDL2.dll
uses: actions/download-artifact@v4
with:
name: x64_SDL2.dll

- name: List downloaded files
shell: pwsh
run: |
Get-ChildItem -Path "." -Recurse -Filter "*.dll"

- name: Move DLL to correct location
shell: pwsh
run: |
New-Item -Path "build\Release" -ItemType Directory -Force

Copy-Item -Path "whisper.dll" -Destination "build\Release\whisper.dll" -Force
Write-Host "Copied whisper.dll to build\Release\whisper.dll directory"

Copy-Item -Path "SDL2.dll" -Destination "build\Release\SDL2.dll" -Force
Write-Host "Copied SDL2.dll to build\Release\SDL2.dll directory"

- name: List build release files
shell: pwsh
run: |
Get-ChildItem -Path "build\Release" -Recurse -Filter "*.dll"

- name: Build
run: |
models\download-ggml-model.cmd tiny.en
cd bindings/java
chmod +x ./gradlew
./gradlew build --info

- name: Upload jar
uses: actions/upload-artifact@v4
with:
name: whispercpp.jar
path: bindings/java/build/libs/whispercpp-*.jar

- name: Publish package
if: ${{ github.ref == 'refs/heads/master' }}
uses: gradle/[email protected]
with:
arguments: publish
build-root-directory: bindings/java
env:
MAVEN_USERNAME: ${{ secrets.JIRA_USER }}
MAVEN_PASSWORD: ${{ secrets.JIRA_PASS }}
PGP_SECRET: ${{ secrets.GPG_PRIVATE_KEY }}
PGP_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

quantize:
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
Expand Down
14 changes: 10 additions & 4 deletions bindings/java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,29 @@ sourceSets {
tasks.register('copyLibwhisperDynlib', Copy) {
from '../../build/src'
include 'libwhisper.dylib'
into 'build/generated/resources/main/darwin'
into 'build/generated/resources/main'
}

tasks.register('copyLibwhisperSo', Copy) {
from '../../build/src'
include 'libwhisper.so'
into 'build/generated/resources/main/linux-x86-64'
into 'build/generated/resources/main'
}

tasks.register('copyWhisperDll', Copy) {
from '../../build/Release'
include 'whisper.dll'
into 'build/generated/resources/main/windows-x86-64'
into 'build/generated/resources/main'
}

tasks.register('copySDL2Dll', Copy) {
from '../../build/Release'
include 'SDL2.dll'
into 'build/generated/resources/main'
}

tasks.register('copyLibs') {
dependsOn copyLibwhisperDynlib, copyLibwhisperSo, copyWhisperDll
dependsOn copyLibwhisperDynlib, copyLibwhisperSo, copyWhisperDll, copySDL2Dll
}

test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,22 @@
import io.github.ggerganov.whispercpp.params.WhisperContextParams;
import io.github.ggerganov.whispercpp.params.WhisperFullParams;

class JnaDebugHelper {
static {
System.setProperty("jna.debug_load", "true");
System.out.println("JNA Library Path: " + System.getProperty("jna.library.path"));
System.out.println("Working directory: " + System.getProperty("user.dir"));

if (System.getProperty("jna.library.path") != null) {
java.io.File libraryFile = new java.io.File(System.getProperty("jna.library.path"), System.mapLibraryName("whisper"));
System.out.println("Library file exists: " + libraryFile.exists() + " at " + libraryFile.getAbsolutePath());
}
}
}

public interface WhisperCppJnaLibrary extends Library {
JnaDebugHelper DEBUG_HELPER = new JnaDebugHelper();

WhisperCppJnaLibrary instance = Native.load("whisper", WhisperCppJnaLibrary.class);

String whisper_print_system_info();
Expand Down
Loading