// Cotton Voice's binder contract: the one app on the phone that holds the speech runtime (sherpa-onnx) and the model // store, served to every other Cotton app (they are signed alike: the service asks com.cottondb.permission.VOICE, a // signature permission, and checks the caller's signature again on bind). Every argument and answer that carries // structure is JSON, as the core's own methods are, so the core's shapes (voice.plan, voice.heard, voice.model) cross // unchanged: the calling app hands the plan the core gave it and hands each answer straight back to the core. // // Audio is the calling app's: it holds the microphone and its permission and feeds 16 kHz mono 16-bit little-endian // PCM; Cotton Voice keeps nothing after a session ends. package com.cottondb.voice; import com.cottondb.voice.ICottonVoiceListener; interface ICottonVoice { /** The contract's version (1). A caller that needs more than the service offers falls back as if it were absent. */ int contract(); /** The store as it stands: {"models":[{"model","state":"absent|downloading|ready|failed","bytes","bytes_done","path"?,"why"?}]}. */ String store(); /** * Fetch models: downloadsJson is voice.plan's `downloads` ([{"model","url","sha256","bytes","file"?,"why"?}], one entry * per file; entries sharing a model make one model). Resumable; each file checked against its sha256. mobileData * false waits for an unmetered network. Progress arrives as listener.model, in voice.model's shape. */ oneway void fetch(String downloadsJson, boolean mobileData, ICottonVoiceListener listener); /** Delete a model's files; listener-less, the next store() says absent. */ oneway void remove(String model); /** * Open a dictation: session is voice.plan's, planJson its whole answer (languages, live, second, vocabulary). The * listener hears ready (engines loaded) or failed (code "missing_model", "no_engine", ...), then heard for every * live and second result, and ended after finish once every pass has spoken. */ oneway void open(String session, String planJson, ICottonVoiceListener listener); /** Audio for an open session, in order: 16 kHz mono PCM, 16-bit little-endian. */ oneway void feed(String session, in byte[] pcm); /** The audio has ended: the live pass settles, the last sentence gets its second pass, then ended. */ oneway void finish(String session); /** Drop the session now: nothing more is heard and its audio is forgotten. */ oneway void cancel(String session); }