Initial import: Stitch 0.4.3 (versionCode 16)
The project's first commit, six days and 16 releases after it started. Everything up to this point existed only as files on one machine, with no history and no undo. Contents: single Gradle module, 62 Kotlin files (11,244 lines) and the Needle 2 JNI bridge, 70 tools, 87 passing unit tests, and the five documents in docs/ plus DEVELOPMENT_HISTORY.md and README.md. Not tracked: build outputs (build/, .cxx/, .gradle/), the release APKs in dist/ (~800 MB, rebuildable), local.properties, and .claude/settings.local.json — all machine-specific. The prebuilt libneedle.a files (38 MB) *are* tracked on purpose, so a checkout builds without depending on Hugging Face still serving them.
This commit is contained in:
commit
61409cb444
111 files changed
+15481
No files matched your search
@@ -0,0 +1,108 @@
|
||||
# Hotword & Assistant Surface — plan
|
||||
|
||||
> ⚠️ **HISTORICAL DOCUMENT.** This was the design plan for the wake phrase. **It shipped in Stitch 0.4.0**
|
||||
> and works as described here (teach-by-example, 5 recordings, MFCC + DTW, fully offline, bubble over any
|
||||
> app). The status line below is the original one and is no longer accurate. The one thing still untested
|
||||
> is detection with a real voice — the emulator has no microphone (see `DEVELOPMENT_HISTORY.md` §10 and
|
||||
> Stage A of `docs/UPGRADE_PLAN.md`).
|
||||
>
|
||||
> Status: planned, not built yet. Target: Stitch 0.4.0.
|
||||
> Goal: say your own wake phrase, Stitch pops up as a bubble and talks with you — and it can replace
|
||||
> Google Assistant when you hold the power button or swipe from the corner.
|
||||
|
||||
---
|
||||
|
||||
## 1. What you asked for
|
||||
|
||||
| Ask | How it will work |
|
||||
|---|---|
|
||||
| Call Stitch by a hotword | An always-ready listening service on the phone |
|
||||
| The hotword is **yours**, and changeable | You type the phrase, then say it a few times to teach it |
|
||||
| **Voice teaching** for accuracy | 5 recordings of your phrase; Stitch keeps the sound pattern, not the audio |
|
||||
| A **proper surface**, not the chat page | A floating bubble over whatever app you're in: what you said, what Stitch is doing, its answer, and a mic to keep talking |
|
||||
| Connect it **instead of Google Assistant** | Stitch registers as a digital assistant app, so you can pick it in Settings → Apps → Default apps → Digital assistant |
|
||||
| Proper conversation | Each reply is spoken and keeps the thread; follow-ups like "send it to him too" work |
|
||||
|
||||
---
|
||||
|
||||
## 2. How the hotword works
|
||||
|
||||
**Chosen approach: teach-by-example, fully on the phone.**
|
||||
|
||||
1. You type the phrase, e.g. "Hey Stitch", in Settings → Hotword.
|
||||
2. Stitch records you saying it **5 times**.
|
||||
3. Each recording is reduced to a compact sound fingerprint (MFCC features, ~13 numbers per 25 ms of audio). The audio itself is deleted; only the fingerprints are kept, in Stitch's private storage.
|
||||
4. A background service listens to short slices of the microphone and compares them with your fingerprints (DTW — the same technique older voice dialers used). A close enough match wakes Stitch.
|
||||
5. **Self-tuning:** the match threshold starts strict. You can adjust one slider ("wakes too easily ⟷ misses me") and re-record at any time.
|
||||
|
||||
**Why this and not the alternatives**
|
||||
|
||||
| Option | Verdict |
|
||||
|---|---|
|
||||
| **Teach-by-example (chosen)** | Any phrase, in your own voice and accent. Fully offline, no accounts, no keys. Fits "I say it a few times and it learns". Accuracy is good for one speaker, which is exactly this case |
|
||||
| Picovoice Porcupine | Most accurate and lightest on battery, but custom phrases need their website, an account and an access key in the app, and it isn't trained on your voice |
|
||||
| Continuous speech recognition | No training needed, but it runs Google's recognizer non-stop: heavy on battery, needs the network on many phones, and sends audio off the phone |
|
||||
|
||||
**Battery and privacy**
|
||||
- Listening runs in a foreground service with a permanent notification, as Android requires. Audio is processed in memory in small slices, never recorded to disk, never sent anywhere.
|
||||
- Default: listen **while the screen is on, or while charging**. Options: "always", "screen on or charging", "only when plugged in", "off".
|
||||
- Expected cost: roughly 2–4% of battery per hour of actual listening. The fingerprint check is cheap; the microphone is what costs.
|
||||
- A Quick Settings tile and the notification both have "pause listening".
|
||||
|
||||
---
|
||||
|
||||
## 3. The bubble
|
||||
|
||||
When the hotword fires (or you pick Stitch as your assistant and hold the power button):
|
||||
|
||||
```
|
||||
┌─────────────────────────────┐
|
||||
│ ● Listening… │ ← grows from a small circle, over any app
|
||||
├─────────────────────────────┤
|
||||
│ You: play believer on spotify│
|
||||
│ Stitch: ▶ Playing Believer │ ← action chips as steps run
|
||||
│ [mic] [✕ stop] │
|
||||
└─────────────────────────────┘
|
||||
```
|
||||
|
||||
- Built on the overlay Stitch already uses to show its steps in other apps, so no new permission beyond the one you granted.
|
||||
- Speaks replies aloud (can be turned off), listens again after a reply for a set number of seconds, so you can carry on without the hotword.
|
||||
- Tap the bubble to open the full chat with the same conversation.
|
||||
- It's the same agent underneath: same tools, same confirmations for calls and messages.
|
||||
|
||||
---
|
||||
|
||||
## 4. Replacing Google Assistant
|
||||
|
||||
- Stitch registers as a **voice interaction / assist** app. You then choose it in **Settings → Apps → Default apps → Digital assistant app**.
|
||||
- After that, the power-button hold or corner swipe opens Stitch's bubble instead of Google.
|
||||
- Google Assistant's own "Hey Google" keeps working; it's a separate system, and Stitch's hotword is independent of it.
|
||||
- Stitch will also offer a Quick Settings tile and the existing app icon, so nothing depends on this setting.
|
||||
|
||||
---
|
||||
|
||||
## 5. Work involved
|
||||
|
||||
| Piece | Detail |
|
||||
|---|---|
|
||||
| `voice/HotwordService.kt` | Foreground service, `AudioRecord` at 16 kHz, ring buffer, slice → fingerprint → match |
|
||||
| `voice/Fingerprint.kt` | MFCC + DTW; pure Kotlin, so it is unit-testable with recorded samples |
|
||||
| `voice/HotwordTraining.kt` + Settings page | Type the phrase, record 5 times, show a quality score per recording, re-record, delete |
|
||||
| `ui/AssistBubble.kt` | The bubble, built on the existing overlay: transcript, action chips, mic, stop |
|
||||
| `entry/AssistActivity.kt` + manifest | Assist/voice-interaction registration; a Quick Settings tile |
|
||||
| Settings | Hotword on/off, phrase, listening policy, sensitivity, speak replies, follow-up window |
|
||||
| Tests | Fingerprint matching against recorded samples (same phrase ≈ match, different phrase ≈ no match), policy logic |
|
||||
|
||||
**Risks and how they're handled**
|
||||
- *False wakes:* strict default threshold, a "pause listening" tile, and the bubble is silent until it hears a command.
|
||||
- *Missed wakes:* retrain with more samples; the slider helps; the phrase should be 2+ syllables (a warning appears for short phrases).
|
||||
- *OEM battery killers (Xiaomi, Samsung):* the setup page will link to the battery-optimisation exemption screen, as those systems stop background services aggressively.
|
||||
- *Phone calls / other mic users:* listening pauses whenever another app is using the microphone.
|
||||
|
||||
---
|
||||
|
||||
## 6. Not included in 0.4.0
|
||||
|
||||
- Speaker verification (only your voice can wake it) — possible later with the same fingerprints.
|
||||
- Wake phrase in multiple languages at once.
|
||||
- Listening while the phone is fully asleep on phones that stop background microphone use; where Android allows it, "always" mode covers it.
|
||||
Reference in new issue
Block a user