Recently Written · git

subread-android

SubRead for Android: times an audiobook against its ebook on the device

git clone https://github.com/equwal/subread-android

Log | Files | Refs


app/src/main/cpp/CMakeLists.txt (1484 bytes)

1 cmake_minimum_required(VERSION 3.22)
2 project(subread_whisper C CXX)
3 
4 set(CMAKE_C_STANDARD 11)
5 set(CMAKE_CXX_STANDARD 17)
6 
7 # Transcription is hours of matrix arithmetic. Unoptimised it is ten times
8 # slower, so optimise whatever Gradle thinks the build type is.
9 if (CMAKE_BUILD_TYPE STREQUAL "Debug")
10     add_compile_options(-O3)
11 endif ()
12 
13 set(WHISPER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../third_party/whisper.cpp)
14 
15 set(BUILD_SHARED_LIBS      OFF CACHE BOOL "" FORCE)
16 set(WHISPER_BUILD_TESTS    OFF CACHE BOOL "" FORCE)
17 set(WHISPER_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
18 set(WHISPER_BUILD_SERVER   OFF CACHE BOOL "" FORCE)
19 set(GGML_NATIVE            OFF CACHE BOOL "" FORCE)   # cross-compiling: never probe the build host
20 set(GGML_OPENMP            OFF CACHE BOOL "" FORCE)   # ggml's own thread pool; no libomp to ship
21 set(GGML_LLAMAFILE         OFF CACHE BOOL "" FORCE)
22 
23 # Half-precision and dot-product instructions are most of the speed on ARM.
24 # Everything since the Cortex-A55/A75 (2018) has them; MainActivity checks
25 # before loading this library, so an older CPU gets a message, not a SIGILL.
26 if (ANDROID_ABI STREQUAL "arm64-v8a")
27     set(GGML_CPU_ARM_ARCH "armv8.2-a+fp16+dotprod" CACHE STRING "" FORCE)
28 endif ()
29 
30 add_subdirectory(${WHISPER_DIR} whisper EXCLUDE_FROM_ALL)
31 
32 add_library(subread_whisper SHARED whisper_jni.c)
33 target_link_libraries(subread_whisper PRIVATE whisper log)
34 target_link_options(subread_whisper PRIVATE -Wl,--gc-sections -Wl,--exclude-libs,ALL)