FluidAudio ASR runs inside an iOS keyboard extension (CPU and ANE): how, and numbers

Aperta
#1,179 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
ios, swift

Direzione di ricerca

Read the issue's iOS keyboard extension probe details and the two questions about ANE reliability and sharing compiled CoreML caches through an App Group. The payload names no FluidAudio source files or tests to start from; first check the relevant CoreML and iOS extension APIs, then verify whether either approach is supported. Done means providing evidence-backed answers to both questions; the issue is exploratory and needs iOS/CoreML expertise.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Edited 2026-11-19: on-device probe results added; earlier version assumed the memory cap was the blocker, which turned out wrong.

Following up on a Discord thread. This is a case study / FYI with a couple of narrow questions at the end, not a bug report. FluidAudio tdtCtc110m loads and transcribes inside a custom keyboard extension on iOS 27, on both CPU and the ANE (confirmed with MLComputePlan), at well under the extension memory cap.

How: audio capture in a keyboard extension

Keyboard extensions don't get record entitlements. audiomxd logs that the process "is an extension and doesn't have entitlements to record audio". Hex (anomalyco/hex#1999, ios/HEXKeyboard/KeyboardLocalDictation.swift) gets around this with no entitlement:

  • A hidden 2×2 px WKWebView (alpha 0.02) loads an inline page that calls navigator.mediaDevices.getUserMedia({audio}).
  • WKUIDelegate.requestMediaCapturePermissionFor auto-grants .microphone. WebKit's media process captures under the containing app's mic permission.
  • A ScriptProcessor sends Int16 PCM as base64 to Swift through webkit.messageHandlers.
  • The keyboard's Info.plist adds NSMicrophoneUsageDescription and NSSpeechRecognitionUsageDescription.

Hex then transcribes with Apple SpeechTranscriber (out of process). I used the same capture, but with FluidAudio in-process instead.

On-device probe (iPhone 16, iOS 27)

The containing app stages tdtCtc110m in the App Group container. The keyboard loads it with AsrModels.load(from:) and runs it in-process, with the containing app not running. The probe logs phys_footprint and os_proc_available_memory at each step.

Capture works at 48 kHz with healthy levels (peak 0.9998, rms 0.11).

CPU (.cpuOnly) ANE (.cpuAndNeuralEngine)
First load ≈30 s (one-time CoreML compile, then cached) 6.2 s
Later loads 0.6 s —
Audio → transcription time 10.3 s → 231 ms (≈45× RT) 27.0 s → 294 ms (≈92× RT)
Output correct text inserted into Notes correct text
phys_footprint peak 23 MB 25 MB
  • Cap: footprint + os_proc_available_memory ≈ 177 MB, which matches Hex's ~176 MB on iPhone 17 Pro / iOS 27.2.

  • Memory headroom: even five accidental concurrent loads peaked at 34 MB.

  • What counts against the cap: the model's ~217 MB on-disk size is not charged to the extension. The compiled CoreML weights are clean, file-backed pages.

  • iOS 27 ANE attribution: the iOS 27.0 notes say Neural Engine memory is now attributed to the app process (174796039, background ANE gated by 179282606, see #738 / FB23457001). Even so, the ANE run stayed at 25 MB.

  • ANE confirmed: MLComputePlan run inside the keyboard:

    Model .cpuAndNeuralEngine .cpuOnly
    Preprocessor (fused 110M encoder) ANE 988 ops / CPU 55 CPU 1043
    Decoder (19 ops) CPU CPU
    JointDecision (24 ops) CPU CPU

    The phys_footprint peak in that run was 29 MB (ANE) / 32 MB (CPU) of the ~177 MB cap.

For contrast, my full app (Parakeet v2 + CTC-110M spotter + CPU fallback twins) peaks at 657 MB during load. That heavier load path is a different case and doesn't predict the extension numbers.

Mac bake-off (accuracy context)

M4 Mac mini, macOS 27.2, FluidAudio 0.18.4. 11 of my own dictation clips, 270 s of audio / 731 reference words. WER ignores case and punctuation. RTFx is measured on warm models.

Engine WER RTFx First load + warm-up
Parakeet v2 2.60% (19/731) 266× 14.0 s
tdtCtc110m 4.38% (32/731) 482× 4.9 s
Phonon-2 4.92% (36/731) 124× n/a (196 s, includes ~360 MB download)
Apple SpeechTranscriber 6.02% (44/731) 73× 0.7 s (out of process)

On my speech, tdtCtc110m beats Apple's on-device model (4.4% vs 6.0% WER) and is ~6.5× faster. Since it now runs inside the keyboard, it's a real upgrade over the out-of-process approach.

Questions

  1. Is there any known reason ANE-in-extension would break later, e.g. aned limits, compile-cache location/eviction, or per-process ANE quotas once iOS 27 attribution applies?
  2. The first CPU load compiled for ~30 s inside the extension. Is there a supported way to compile in the containing app and share the compiled cache with the extension via the App Group, so the keyboard never pays the compile?
Lingua principale
Swift
Stelle
3k
Fork
451
Merge medio
1g 19h
PR unite (30g)
87

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di FluidInference/FluidAudio

Tutte le issue di FluidInference/FluidAudio

Issue simili

Altre issue su Swift

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.