Skip to content

VoiceStudio is the open-source, fully-local ElevenLabs alternative — voice cloning, voice design, video dubbing, dictation, transcription & audiobook creation in 646 languages.

ci(mobile): real on-device inference in CI; contract tests resolve services lazily

debpalashec0258d02bc2
diff --git a/.github/workflows/mobile.yml b/.github/workflows/mobile.yml
index 24cfda14e..02c6be661 100644
--- a/.github/workflows/mobile.yml
+++ b/.github/workflows/mobile.yml
@@ -147,3 +147,75 @@ jobs:
name: VoiceStudio-ios-unsigned
path: ${{ runner.temp }}/VoiceStudio-unsigned.ipa
retention-days: 7
+
+ # SPEC.md M2 "Tests": real on-device inference in CI — TTS output is
+ # transcribed back by ASR with the smallest pinned models, using the same
+ # native code the phones run. Models are user-started downloads in the app;
+ # here they are fetched for the test with its explicit test-licence flag.
+ ios-inference:
+ runs-on: macos-15
+ timeout-minutes: 60
+ steps:
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
+ with:
+ persist-credentials: false
+
+ - name: Cache native runtimes and smoke models
+ uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
+ with:
+ path: |
+ mobile/native/ios/build/macos
+ mobile/ios/.cache/inference-models
+ key: ios-inference-${{ hashFiles('mobile/native/pins.json', 'mobile/native/ios/build.py', 'mobile/contract/models.json') }}
+
+ - name: Fetch smallest models
+ run: python3 mobile/ios/scripts/fetch-smoke-models.py --accept-test-licences
+
+ - name: Real TTS -> ASR
+ run: mobile/ios/scripts/real-inference.sh
+
+ android-inference:
+ runs-on: ubuntu-24.04
+ timeout-minutes: 75
+ defaults:
+ run:
+ working-directory: mobile/android
+ steps:
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
+ with:
+ persist-credentials: false
+
+ - uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
+ with:
+ distribution: temurin
+ java-version: "21"
+
+ - uses: gradle/actions/setup-gradle@42ebad84b0585498c0413b0967cf4e80ec0e1d19 # v4.4.1
+
+ - name: SDK, NDK and CMake
+ run: |
+ printf 'sdk.dir=%s\n' "$ANDROID_HOME" > local.properties
+ yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" "ndk;27.1.12297006" "cmake;3.22.1" > /dev/null
+
+ - name: Cache native runtimes
+ uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
+ with:
+ path: mobile/native/android/build
+ key: android-native-${{ hashFiles('mobile/native/pins.json', 'mobile/native/android/**', '!mobile/native/android/build/**') }}
+
+ - name: Enable KVM
+ run: |
+ echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
+ sudo udevadm control --reload-rules
+ sudo udevadm trigger --name-match=kvm
+
+ - name: Real TTS -> ASR on an x86_64 emulator
+ uses: ReactiveCircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0
+ with:
+ api-level: 34
+ target: google_apis
+ arch: x86_64
+ ram-size: 4096M
+ disk-size: 6G
+ working-directory: mobile/android
+ script: ./gradlew --no-daemon connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.voicestudio.mobile.LocalInferenceTest#smallestModelsProduceSpeechAndRecognizeItOffline -Pandroid.testInstrumentationRunnerArguments.localInferenceSmoke=true -Pandroid.testInstrumentationRunnerArguments.downloadSmokeModels=true -Pandroid.testInstrumentationRunnerArguments.acceptModelLicencesForSmoke=true
diff --git a/tests/test_mobile_contract.py b/tests/test_mobile_contract.py
index b51096001..82bb11274 100644
--- a/tests/test_mobile_contract.py
+++ b/tests/test_mobile_contract.py
@@ -76,7 +76,14 @@ def test_openapi_contract_is_version_neutral():
# M2: the catalogue is a source contract consumed by both native decoders.
import export_mobile_models as mobile_models # noqa: E402
-from services import model_acceptance, model_licenses # noqa: E402
+
+
+def _services():
+ # Resolved at run time: other suites purge services.* after collection, so a
+ # module-level binding could point at a stale module.
+ import importlib
+
+ return importlib.import_module("services.model_acceptance"), importlib.import_module("services.model_licenses")
def _mobile_models_source():
@@ -120,6 +127,7 @@ def test_mobile_models_are_pinned_and_have_complete_manifests():
def test_mobile_models_registry_licence_gates_and_fingerprints():
+ model_acceptance, model_licenses = _services()
registry = model_licenses.load_registry()
rows = {row["id"]: row for row in registry["models"]}
projected = {row["id"]: row for row in _mobile_licenses()["models"]}