Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
dependencies ▾

Modern-Apps.git / speech / build.gradle.kts

build.gradle.kts70 lines · 3.4 KiBRaw
1plugins {
2 id("common-conventions-app")
3 // Listing screenshots come from Compose previews (src/screenshotTest), not from an
4 // instrumented test on a device. Same `:speech:metadata` task name either way.
5 id("common-conventions-preview-metadata")
6 alias(libs.plugins.ksp)
7}
8
9launcherIcon {
10 symbol = "record_voice_over"
11}
12
13android {
14 defaultConfig {
15 applicationId = "com.vayunmathur.speech"
16 }
17
18 androidResources {
19 // Load-bearing, not an optimisation. `AssetManager.openFd` throws for a deflated entry,
20 // and the fd is how Supertonic's ~105 MB and whisper-base's 70.6 MiB of weights reach the
21 // GPU without being copied through the Java heap three times - see
22 // SupertonicSynthesizer.inAssets and WhisperHandle.inAssets. It costs nothing on download
23 // size either: int8 and fp16 weights are already incompressible.
24 noCompress += "maml"
25 }
26}
27// This module has no rustNativeLib of its own: the native load arrives
28// transitively from :library:ml (libmodelrunner via MlNative), which is
29// what puts this module's tests on the forkEvery = 1 path at all. Only
30// the classes below actually load it: WhisperModelAndEngineTest and
31// SupertonicEngineAndBundleTest drive the real engines' ensure() paths
32// (WhisperHandle.inAssets / SupertonicSynthesizer.inAssets, both gated
33// on MlNative.isAvailable), and the two service tests build the real
34// services, whose onCreate threads call engine.preload() on the real
35// engine (the fake-engine tests in the same files never reach ensure,
36// but a class cannot be split below class granularity). Quarantine
37// those loaders into testDevUnitTestNative (forkEvery = 1); the
38// remaining classes batch 20-per-JVM in testDevUnitTest, which depends
39// on the quarantine task so the usual invocation still runs everything.
40// No isolatedClasses: this app has no DataStore and no ViewModel (see
41// the dependencies note below), the WhisperRecognitionSessionTest fake
42// engine overrides every native entry point, and SupertonicBundle's
43// process-wide isPresent cache returns the same asset-derived answer
44// for every caller — its own test already tolerates a warm cache.
45rustNativeTests {
46 nativeClasses.addAll(
47 listOf(
48 "com.vayunmathur.speech.platform.SupertonicEngineAndBundleTest",
49 "com.vayunmathur.speech.platform.WhisperModelAndEngineTest",
50 "com.vayunmathur.speech.service.SupertonicTtsServiceTest",
51 "com.vayunmathur.speech.service.WhisperRecognitionServiceTest",
52 )
53 )
54}
55
56dependencies {
57 // Both directions run on :library:ml, our own Vulkan compute runtime, and this app links no
58 // third-party inference runtime at all.
59 //
60 // Text-to-speech is Supertonic 3: four networks for all 31 languages, every one of them on the
61 // GPU - the duration predictor, the text encoder, a flow-matching sampler and a ConvNeXt
62 // vocoder. Speech-to-text is whisper-base, one 70.6 MiB `.maml` holding a 6-layer audio encoder
63 // and a 6-layer KV-cached decoder, with the decode loop in `post::whisper`.
64 //
65 // Both bundles ship in `assets/` and are streamed from a file descriptor, which is what
66 // `noCompress += "maml"` above is for.
67 implementation(project(":library:ml"))
68 // No `:library:downloadservice` and no DataStore: both models ship in the APK, so this app
69 // downloads nothing and stores no preferences. They went when Piper's 1,834 MB of voices did.
70}