mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2024-12-23 22:42:22 +00:00
19f8048139
* FetchContent * OpenCL * Documentation and make optional * Specify GGML build options in build.gradle * Use gradle properties * @ggerganov Co-authored-by: Georgi Gerganov <ggerganov@gmail.com> * @gpokat --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
2.3 KiB
2.3 KiB
A sample Android app using whisper.cpp to do voice-to-text transcriptions.
To use:
- Select a model from the whisper.cpp repository.1
- Copy the model to the "app/src/main/assets/models" folder.
- Select a sample audio file (for example, jfk.wav).
- Copy the sample to the "app/src/main/assets/samples" folder.
- Select the "release" active build variant, and use Android Studio to run and deploy to your device.
(PS: Do not move this android project folder individually to other folders, because this android project folder depends on the files of the whole project.)
CLBlast
Note
- OpenCL does not have the same level of support as CUDA or Metal.
- Turning on CLBlast may degrade OpenCL performance if your device isn't already tuned. See tuning.md for a list of devices that are already tuned and what to do if yours is missing.
Build CLBlast.
# In path/to/CLBlast (we assume OpenCL-Headers relative location)
$ANDROID_SDK_PATH/cmake/3.22.1/bin/cmake .. \
-DCMAKE_SYSTEM_NAME=Android \
-DCMAKE_SYSTEM_VERSION=33 \
-DCMAKE_ANDROID_ARCH_ABI=arm64-v8a \
-DCMAKE_ANDROID_NDK=$ANDROID_NDK_PATH \
-DCMAKE_ANDROID_STL_TYPE=c++_static \
-DOPENCL_ROOT=$(readlink -f ../../OpenCL-Headers) \
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=BOTH \
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH
# Build libclblast.so
make -j4
Pull libGLES_mali.so
to libOpenCL.so
.
# In path/to/whisper.android
mkdir lib/src/main/jniLibs/arm64-v8a
adb pull /system/vendor/lib64/egl/libGLES_mali.so lib/src/main/jniLibs/arm64-v8a/libOpenCL.so
In gradle.properties, set GGML_HOME
to the location of GGML, as well as
required options for turning on CLBlast.
GGML_HOME=/path/to/ggml
GGML_CLBLAST=ON
CLBLAST_HOME=/path/to/CLBlast
OPENCL_LIB=/path/to/libOpenCL.so
OPENCL_ROOT=/path/to/OpenCL-Headers
-
I recommend the tiny or base models for running on an Android device. ↩︎