From 514b355f6c2e02fdadb0b5bc4e2261a4d70351b7 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 25 Mar 2025 06:41:09 +0100 Subject: [PATCH 1/2] whisper.android.java : update build with ggml source changes This commit updates the whisper.android.java build to include the new ggml source files and directories. The gradle build configuration is also updated to include the aliyun maven repository. --- .../app/src/main/jni/whisper/CMakeLists.txt | 11 +++++++++-- examples/whisper.android.java/build.gradle | 3 ++- examples/whisper.android.java/gradlew | 0 3 files changed, 11 insertions(+), 3 deletions(-) mode change 100644 => 100755 examples/whisper.android.java/gradlew diff --git a/examples/whisper.android.java/app/src/main/jni/whisper/CMakeLists.txt b/examples/whisper.android.java/app/src/main/jni/whisper/CMakeLists.txt index 91007252f52..a69458d34e0 100644 --- a/examples/whisper.android.java/app/src/main/jni/whisper/CMakeLists.txt +++ b/examples/whisper.android.java/app/src/main/jni/whisper/CMakeLists.txt @@ -2,15 +2,21 @@ cmake_minimum_required(VERSION 3.10) project(whisper.cpp) -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) set(WHISPER_LIB_DIR ${CMAKE_SOURCE_DIR}/../../../../../../../) set(SOURCE_FILES ${WHISPER_LIB_DIR}/ggml/src/ggml.c - ${WHISPER_LIB_DIR}/ggml/src/ggml-aarch64.c + ${WHISPER_LIB_DIR}/ggml/src/ggml-cpu/ggml-cpu.c + ${WHISPER_LIB_DIR}/ggml/src/ggml-cpu/ggml-cpu-aarch64.cpp + ${WHISPER_LIB_DIR}/ggml/src/ggml-cpu/ggml-cpu-traits.cpp + ${WHISPER_LIB_DIR}/ggml/src/ggml-cpu/ggml-cpu-quants.c + ${WHISPER_LIB_DIR}/ggml/src/ggml-cpu/ggml-cpu.cpp ${WHISPER_LIB_DIR}/ggml/src/ggml-alloc.c ${WHISPER_LIB_DIR}/ggml/src/ggml-backend.cpp + ${WHISPER_LIB_DIR}/ggml/src/ggml-backend-reg.cpp ${WHISPER_LIB_DIR}/ggml/src/ggml-quants.c + ${WHISPER_LIB_DIR}/ggml/src/ggml-threading.cpp ${WHISPER_LIB_DIR}/src/whisper.cpp ${CMAKE_SOURCE_DIR}/jni.c ) @@ -57,3 +63,4 @@ include_directories(${WHISPER_LIB_DIR}/src) include_directories(${WHISPER_LIB_DIR}/include) include_directories(${WHISPER_LIB_DIR}/ggml/include) include_directories(${WHISPER_LIB_DIR}/ggml/src) +include_directories(${WHISPER_LIB_DIR}/ggml/src/ggml-cpu) diff --git a/examples/whisper.android.java/build.gradle b/examples/whisper.android.java/build.gradle index 450441ac909..cc32112cf61 100644 --- a/examples/whisper.android.java/build.gradle +++ b/examples/whisper.android.java/build.gradle @@ -16,9 +16,10 @@ allprojects { repositories { google() jcenter() + maven { url "https://maven.aliyun.com/repository/gradle-plugin" } } } task clean(type: Delete) { delete rootProject.buildDir -} \ No newline at end of file +} diff --git a/examples/whisper.android.java/gradlew b/examples/whisper.android.java/gradlew old mode 100644 new mode 100755 From d1d63a23c4ee04274d9f098c6f959c70e1bac300 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 25 Mar 2025 15:15:47 +0100 Subject: [PATCH 2/2] whisper.android.java: Add GGML_USE_CPU to whisper library This commit adds GGML_USE_CPU to whisper library in order to enable the CPU backend to work. I'm not currently sure about the aproach to take with regards to the backends on Android. I went down the dynamic library route, but it was a struggle and perhaps not the best way to go. I'm still looking how to enable GPU backends and which ones are available. --- .../whisper.android.java/app/src/main/jni/whisper/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/whisper.android.java/app/src/main/jni/whisper/CMakeLists.txt b/examples/whisper.android.java/app/src/main/jni/whisper/CMakeLists.txt index a69458d34e0..1ea30917a62 100644 --- a/examples/whisper.android.java/app/src/main/jni/whisper/CMakeLists.txt +++ b/examples/whisper.android.java/app/src/main/jni/whisper/CMakeLists.txt @@ -31,6 +31,7 @@ function(build_library target_name) ) target_link_libraries(${target_name} ${LOG_LIB} android) + target_compile_definitions(${target_name} PUBLIC GGML_USE_CPU) if (${target_name} STREQUAL "whisper_v8fp16_va") target_compile_options(${target_name} PRIVATE -march=armv8.2-a+fp16)