diff --git a/CMakeLists.txt b/CMakeLists.txt index 59cda63..298de2d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,7 +85,7 @@ install( DESTINATION ${CMAKE_INSTALL_PREFIX} USE_SOURCE_PERMISSIONS FILES_MATCHING - PATTERN "*.so" + PATTERN "*.so.*" PATTERN "*.dylib" ) diff --git a/README.md b/README.md index 1dfa805..3a84231 100644 --- a/README.md +++ b/README.md @@ -6,16 +6,12 @@ A JNI wrapper for [whisper.cpp](https://github.com/ggerganov/whisper.cpp), allow This library aims to support the following platforms: -* Windows10 x86_64 +* Windows10 x86_64 (included binary requires CPU features avx2, fma, f16c, avx) * Linux GLIBC x86_64/arm64 (built with debian focal, GLIBC version 2.31) * macOS x86_64/arm64 (built targeting v11.0) The native binaries for those platforms are included in the distributed jar. - -The library has been tested on all the supported platforms unless macOS arm64. - -The included binaries have been built with some features enabled that I think are available in most modern devices, -please open an issue if you found it don't work on any of the supported platforms. +Please open an issue if you found it don't work on any of the supported platforms. ## Installation diff --git a/build_debian.sh b/build_debian.sh index 6a5c1c2..53b7b9a 100755 --- a/build_debian.sh +++ b/build_debian.sh @@ -6,9 +6,9 @@ build_lib() { cmake -B build $CMAKE_ARGS -DCMAKE_C_FLAGS="$CMAKE_CFLAGS" -DCMAKE_INSTALL_PREFIX=$TMP_DIR cmake --build build --config Release cmake --install build - mv $TMP_DIR/libwhisper.so $TARGET_DIR/libwhisper$LIB_VARIANT.so + cp $TMP_DIR/libwhisper.so.1 $TARGET_DIR/libwhisper$LIB_VARIANT.so.1 if [ "$ADD_WRAPPER" = true ]; then - mv $TMP_DIR/libwhisper-jni.so $TARGET_DIR/libwhisper-jni.so + cp $TMP_DIR/libwhisper-jni.so $TARGET_DIR/libwhisper-jni.so fi rm -rf $TMP_DIR rm -rf build diff --git a/build_macos.sh b/build_macos.sh index 4ed4fe3..2a18b5b 100755 --- a/build_macos.sh +++ b/build_macos.sh @@ -20,8 +20,13 @@ esac INCLUDE_JAVA="-I $JAVA_HOME/include -I $JAVA_HOME/include/darwin" TARGET=$AARCH-apple-macosx$TARGET_VERSION - -cmake -Bbuild -DCMAKE_INSTALL_PREFIX=src/main/resources/macos-$AARCH_NAME -DCMAKE_OSX_DEPLOYMENT_TARGET=$TARGET_VERSION -DCMAKE_OSX_ARCHITECTURES=$AARCH +TARGET_DIR=src/main/resources/macos-$AARCH_NAME +TMP_DIR=src/main/resources/tmp-macos-$AARCH_NAME +mkdir -p $TMP_DIR +cmake -Bbuild -DCMAKE_INSTALL_PREFIX=$TMP_DIR -DCMAKE_OSX_DEPLOYMENT_TARGET=$TARGET_VERSION -DCMAKE_OSX_ARCHITECTURES=$AARCH cmake --build build --config Release cmake --install build -rm -rf build \ No newline at end of file +rm -rf build +cp $TMP_DIR/libwhisper.1.dylib $TARGET_DIR +cp $TMP_DIR/libwhisper-jni.dylib $TARGET_DIR +rm -rf $TMP_DIR \ No newline at end of file diff --git a/pom.xml b/pom.xml index 637903a..c442820 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ whisper-jni whisper-jni https://github.com/GiviMAD/whisper-jni - 1.5.4-0 + 1.6.0 A JNI wrapper for [whisper.cpp](https://github.com/ggerganov/whisper.cpp), allows to transcribe speech to text in Java diff --git a/src/main/java/io/github/givimad/whisperjni/internal/LibraryUtils.java b/src/main/java/io/github/givimad/whisperjni/internal/LibraryUtils.java index 5dd3b42..db9b0e2 100644 --- a/src/main/java/io/github/givimad/whisperjni/internal/LibraryUtils.java +++ b/src/main/java/io/github/givimad/whisperjni/internal/LibraryUtils.java @@ -141,12 +141,12 @@ public static void loadLibrary(WhisperJNI.LoadOptions options) throws IOExceptio options.logger.log("Compatible amd64 architecture detected."); if(options.whisperLib == null) { if(cpuInfo.contains("avx2") && cpuInfo.contains("fma") && cpuInfo.contains("f16c") && cpuInfo.contains("avx")) { - LibraryUtils.extractLibraryFromJar("/debian-amd64/libwhisper+mf16c+mfma+mavx+mavx2.so", "libwhisper.so", options.logger); + LibraryUtils.extractLibraryFromJar("/debian-amd64/libwhisper+mf16c+mfma+mavx+mavx2.so.1", "libwhisper.so.1", options.logger); } else { - LibraryUtils.extractLibraryFromJar("/debian-amd64/libwhisper.so", "libwhisper.so", options.logger); + LibraryUtils.extractLibraryFromJar("/debian-amd64/libwhisper.so.1", "libwhisper.so.1", options.logger); } } else { - LibraryUtils.copyFromSystem(options.whisperLib, "libwhisper.so", options.logger); + LibraryUtils.copyFromSystem(options.whisperLib, "libwhisper.so.1", options.logger); } if(options.whisperJNILib == null){ LibraryUtils.extractLibraryFromJar("/debian-amd64/libwhisper-jni.so", "libwhisper-jni.so", options.logger); @@ -157,12 +157,12 @@ public static void loadLibrary(WhisperJNI.LoadOptions options) throws IOExceptio options.logger.log("Compatible arm64 architecture detected."); if(options.whisperLib == null){ if(cpuInfo.contains("fphp")) { - LibraryUtils.extractLibraryFromJar("/debian-arm64/libwhisper+fp16.so", "libwhisper.so", options.logger); + LibraryUtils.extractLibraryFromJar("/debian-arm64/libwhisper+fp16.so.1", "libwhisper.so.1", options.logger); } else if(cpuInfo.contains("crc32")) { - LibraryUtils.extractLibraryFromJar( "/debian-arm64/libwhisper+crc.so", "libwhisper.so", options.logger); + LibraryUtils.extractLibraryFromJar( "/debian-arm64/libwhisper+crc.so.1", "libwhisper.so.1", options.logger); } } else { - LibraryUtils.copyFromSystem(options.whisperLib, "libwhisper.so", options.logger); + LibraryUtils.copyFromSystem(options.whisperLib, "libwhisper.so.1", options.logger); } if(options.whisperJNILib == null){ LibraryUtils.extractLibraryFromJar("/debian-arm64/libwhisper-jni.so", "libwhisper-jni.so", options.logger); @@ -173,12 +173,12 @@ public static void loadLibrary(WhisperJNI.LoadOptions options) throws IOExceptio options.logger.log("Compatible arm architecture detected."); if(options.whisperLib == null){ if(cpuInfo.contains("crc32")) { - LibraryUtils.extractLibraryFromJar("/debian-armv7l/libwhisper+crc.so", "libwhisper.so", options.logger); + LibraryUtils.extractLibraryFromJar("/debian-armv7l/libwhisper+crc.so.1", "libwhisper.so.1", options.logger); } else { - LibraryUtils.extractLibraryFromJar("/debian-armv7l/libwhisper.so", "libwhisper.so", options.logger); + LibraryUtils.extractLibraryFromJar("/debian-armv7l/libwhisper.so.1", "libwhisper.so.1", options.logger); } } else { - LibraryUtils.copyFromSystem(options.whisperLib, "libwhisper.so", options.logger); + LibraryUtils.copyFromSystem(options.whisperLib, "libwhisper.so.1", options.logger); } if(options.whisperJNILib == null){ LibraryUtils.extractLibraryFromJar("/debian-armv7l/libwhisper-jni.so", "libwhisper-jni.so", options.logger); @@ -194,9 +194,9 @@ public static void loadLibrary(WhisperJNI.LoadOptions options) throws IOExceptio if(osArch.contains("amd64") || osArch.contains("x86_64")) { options.logger.log("Compatible amd64 architecture detected."); if(options.whisperLib == null){ - LibraryUtils.extractLibraryFromJar( "/macos-amd64/libwhisper.dylib", "libwhisper.dylib", options.logger); + LibraryUtils.extractLibraryFromJar( "/macos-amd64/libwhisper.1.dylib", "libwhisper.1.dylib", options.logger); } else { - LibraryUtils.copyFromSystem(options.whisperLib, "libwhisper.dylib", options.logger); + LibraryUtils.copyFromSystem(options.whisperLib, "libwhisper.1.dylib", options.logger); } if(options.whisperJNILib == null){ LibraryUtils.extractLibraryFromJar("/macos-amd64/libwhisper-jni.dylib", "libwhisper-jni.dylib", options.logger); @@ -206,9 +206,9 @@ public static void loadLibrary(WhisperJNI.LoadOptions options) throws IOExceptio } else if(osArch.contains("aarch64") || osArch.contains("arm64")) { options.logger.log("Compatible arm64 architecture detected."); if(options.whisperLib == null){ - LibraryUtils.extractLibraryFromJar( "/macos-arm64/libwhisper.dylib", "libwhisper.dylib", options.logger); + LibraryUtils.extractLibraryFromJar( "/macos-arm64/libwhisper.1.dylib", "libwhisper.1.dylib", options.logger); } else { - LibraryUtils.copyFromSystem(options.whisperLib, "libwhisper.dylib", options.logger); + LibraryUtils.copyFromSystem(options.whisperLib, "libwhisper.1.dylib", options.logger); } if(options.whisperJNILib == null){ LibraryUtils.extractLibraryFromJar("/macos-arm64/libwhisper-jni.dylib", "libwhisper-jni.dylib", options.logger); diff --git a/src/main/native/whisper b/src/main/native/whisper index 0b9af32..08981d1 160000 --- a/src/main/native/whisper +++ b/src/main/native/whisper @@ -1 +1 @@ -Subproject commit 0b9af32a8b3fa7e2ae5f15a9a08f5b10394993f5 +Subproject commit 08981d1bacbe494ff1c943af6c577c669a2d9f4d