Optimize APK size

Removes unused keyword-spotting model. Makes on-device voice model a
runtime download rather than bundling it. Removes native-code library
versions for 32-bit and x86_64 processors.
This commit is contained in:
James Babcock committed 2026-08-22 23:04:01 -07:00
1 parent 69ec828cb7
commit 2b71eddab5
27 files changed
+313 -1283

No files matched your search

+6 -21
View File
@@ -16,10 +16,8 @@ dependencies {
def faceclawSherpaOnnxVersion = "1.13.0"
def faceclawLibLc3Version = "1.1.3"
def faceclawAsrModelName = "sherpa-onnx-moonshine-base-en-quantized-2026-02-27"
def faceclawAbi = "arm64-v8a"
def faceclawJniLibsDir = file("$projectDir/src/main/jniLibs/$faceclawAbi")
def faceclawAssetsDir = file("$projectDir/src/main/assets/faceclaw-voice-asr")
def faceclawNativeBuildDir = file("$buildDir/faceclaw-native")
def faceclawDownload = { String url, File destination ->
@@ -67,15 +65,11 @@ tasks.register("prepareFaceclawNativeLibs") {
outputs.files(
file("$faceclawJniLibsDir/libonnxruntime.so"),
file("$faceclawJniLibsDir/libsherpa-onnx-jni.so"),
file("$faceclawJniLibsDir/libfaceclaw_lc3.so"),
file("$faceclawAssetsDir/$faceclawAsrModelName/encoder_model.ort"),
file("$faceclawAssetsDir/$faceclawAsrModelName/decoder_model_merged.ort"),
file("$faceclawAssetsDir/$faceclawAsrModelName/tokens.txt")
file("$faceclawJniLibsDir/libfaceclaw_lc3.so")
)
doLast {
faceclawJniLibsDir.mkdirs()
faceclawAssetsDir.mkdirs()
def downloadsDir = file("$faceclawNativeBuildDir/downloads")
def sherpaArchive = file("$downloadsDir/sherpa-onnx-v${faceclawSherpaOnnxVersion}-android.tar.bz2")
@@ -92,20 +86,6 @@ tasks.register("prepareFaceclawNativeLibs") {
into faceclawJniLibsDir
}
def asrArchive = file("$downloadsDir/${faceclawAsrModelName}.tar.bz2")
faceclawDownload(
"https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/${faceclawAsrModelName}.tar.bz2",
asrArchive
)
copy {
from tarTree(resources.bzip2(asrArchive))
include "$faceclawAsrModelName/encoder_model.ort"
include "$faceclawAsrModelName/decoder_model_merged.ort"
include "$faceclawAsrModelName/tokens.txt"
includeEmptyDirs = false
into faceclawAssetsDir
}
def lc3Archive = file("$downloadsDir/liblc3-v${faceclawLibLc3Version}.tar.gz")
faceclawDownload(
"https://github.com/google/liblc3/archive/refs/tags/v${faceclawLibLc3Version}.tar.gz",
@@ -281,6 +261,11 @@ android {
minSdkVersion 24
targetSdkVersion 35
ndk {
// The NativeScript platform build.gradle has already added all four
// ABIs by the time app.gradle is applied, and abiFilters is additive,
// so the set must be cleared for this filter to take effect. Only
// arm64 devices are supported (all our own JNI libs are arm64-only).
abiFilters.clear()
abiFilters "arm64-v8a"
}