voice-command-android/download-models.sh

42 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# Download Whisper models for bundling with the Android app
set -e
MODEL_DIR="app/src/main/assets/models"
TEMP_DIR=$(mktemp -d)
echo "Downloading Whisper models for sherpa-onnx..."
# Base URL for sherpa-onnx models
BASE_URL="https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models"
# Download tiny.en model package (~40MB compressed)
echo "Downloading tiny.en model package..."
curl -L -o "$TEMP_DIR/whisper-tiny.en.tar.bz2" \
"$BASE_URL/sherpa-onnx-whisper-tiny.en.tar.bz2"
echo "Extracting model files..."
cd "$TEMP_DIR"
tar xjf whisper-tiny.en.tar.bz2
# Create target directory
mkdir -p "/home/jeffe/Github/voice-command-android/$MODEL_DIR"
# Copy int8 quantized models (smaller, faster)
cp sherpa-onnx-whisper-tiny.en/tiny.en-encoder.int8.onnx "/home/jeffe/Github/voice-command-android/$MODEL_DIR/"
cp sherpa-onnx-whisper-tiny.en/tiny.en-decoder.int8.onnx "/home/jeffe/Github/voice-command-android/$MODEL_DIR/"
cp sherpa-onnx-whisper-tiny.en/tiny.en-tokens.txt "/home/jeffe/Github/voice-command-android/$MODEL_DIR/tokens.txt"
# Cleanup
rm -rf "$TEMP_DIR"
echo ""
echo "Models downloaded to $MODEL_DIR/"
ls -lh "/home/jeffe/Github/voice-command-android/$MODEL_DIR/"
echo ""
echo "Next steps:"
echo "1. Build the APK: ./gradlew assembleDebug"
echo "2. Install on device: adb install app/build/outputs/apk/debug/app-debug.apk"