Skip to content

Instantly share code, notes, and snippets.

@JCGoran
Last active September 27, 2023 10:29
Show Gist options
  • Save JCGoran/30c7d0f17505ba9dcb2dad2643ef70e3 to your computer and use it in GitHub Desktop.
Save JCGoran/30c7d0f17505ba9dcb2dad2643ef70e3 to your computer and use it in GitHub Desktop.
Building whisper.android using Docker
  1. install Docker on your platform.
  2. clone the whisper.cpp repo somewhere: git clone https://github.com/ggerganov/whisper.cpp
  3. change dir to the repo: cd whisper.cpp
  4. download one of the models from here (any of the .bin files should do the trick) and put them in the examples/whisper.android/app/src/main/assets/models directory (if that one doesn't exist, create it)
  5. copy the Dockerfile below to the current (whisper.cpp) directory
  6. run docker build -t android-app-builder .
  7. run the following command (while in the whisper.cpp directory):
    docker run -v "$(pwd)":/app/ android-app-builder /app/examples/whisper.android/gradlew -p /app/examples/whisper.android/ assembleRelease
  8. if the build is successful (which, as of the time of writing, seems to be the case), you can find your apk file under examples/whisper.android/app/build/outputs/apk/release/app-release.apk

Now just copy the apk file to your Android device and install it (you'll probably need to check Install from unknown sources somewhere).

If you want to re-do the build with different settings/models/whatever, just re-run step 7 above.

# Use an official Android SDK image as the base image.
FROM openjdk:17-bullseye
# Set environment variables for Android SDK
ENV ANDROID_HOME /opt/android-sdk
ENV PATH $PATH:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools
# Needed for the `sdkmanager` package as it's not available in bullseye
RUN echo 'deb http://deb.debian.org/debian bullseye-backports main contrib non-free' >> /etc/apt/sources.list
# Install Android SDK tools and dependencies
RUN apt-get update -qq && \
apt-get install -t bullseye-backports -y --no-install-recommends sdkmanager wget unzip
RUN wget -q https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip -O android-commandline-tools.zip && \
unzip -qq android-commandline-tools.zip -d $ANDROID_HOME && \
rm android-commandline-tools.zip
RUN yes | sdkmanager --licenses
# Set up the workspace directory
WORKDIR /app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment