Turning an Amazon Echo Show 5 (1st gen, 2019, codename checkers) into a
self-hosted, Google-Gemini-powered assistant: a clock that never needs the
network, a voice terminal you talk to, a camera Gemini can see through, and a
Spotify speaker.
Status: work in progress. The software side is built and tested; the hardware side is done on one unit and not generalised. Nothing here is a polished, installable product β expect to read code, and expect the Gemini model id and librespot flags to need checking against whatever is current when you try it. See Known limitations.
- An ambient display. A clock by default, plus arbitrary content pushed over an HTTP API. It keeps working when the backend is down β that is a hard requirement, not a nice-to-have.
- A Gemini voice terminal. Wake word, or tap anywhere, then talk.
- A Gemini Live view. The camera streams frames so Gemini can see what the device sees, with an unmistakable on-screen indicator while it does.
- A Spotify speaker. librespot runs on the host and streams PCM down the same socket, so "play some lofi" works by voice and the phone sees a Connect device called Jarvis.
The Echo Show 5 has 1 GB of RAM, a 32-bit ARM userspace and one weak microphone, so it does none of the thinking. It captures, it renders, and it holds one socket open.
The device runs a custom LineageOS 18.1 build with a kiosk app in Kotlin. A small Python server on any always-on machine does the audio, video and inference work. The two are joined by a single WebSocket over a private network (Tailscale in this build, but any WireGuard/WSS path works).
ββ Echo Show 5 (custom LineageOS 18.1, rooted, kiosk) βββββββββ
β β
β EchoTerminal.apk (Kotlin, minSdk 30, armeabi-v7a) β
β ββ Ambient layer LOCAL clock β zero network dependency β
β β + WebView overlay for pushed content β
β ββ AudioCapture 16 kHz mono PCM16 + gain + VAD gate β
β ββ AudioPlayback 24 kHz mono PCM16 + barge-in flush β
β ββ CameraSource 1 FPS JPEG β€768Β², single-client, β
β β opened on demand, closed cleanly β
β ββ Link ONE persistent outbound WebSocket β
β β
β Tailscale (sideloaded APK, armeabi-v7a, no Play Services) β
βββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β private network (WireGuard)
β β audio, video β audio, display
βββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββ
β Host machine β any always-on box (x86 Linux, Windows, a β
β small server; this build was developed on Windows) β
β β
β echo-server (Python) β
β ββ WebSocket hub device link, heartbeat, reconnect β
β ββ Wake word openWakeWord (ONNX) over audio stream β
β ββ Gemini Live google-genai SDK β Live API β
β ββ Display API POST /display β pushed to device β
β ββ GEMINI_API_KEY never leaves this machine β
βββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
βΌ wss:// β¦ BidiGenerateContent
Google Gemini Live API
Why the device dials out. One outbound WebSocket, kept alive, multiplexing audio up, video up, audio down and display commands down. No inbound ports on the device, no NAT problems, and reconnection logic lives in exactly one place.
Why a proxy rather than direct-to-Google. The API key stays on the host, the heavy lifting runs on real hardware, and the wake word can be retuned against logged audio without reflashing anything. The cost is one extra network hop on the local network.
echo-gemini/
βββ README.md # you are here
βββ .env.example # every server config var; copy to .env
βββ pytest.ini
βββ prompts/
β βββ jarvis-system.txt # the system instruction used for the demo unit
βββ server/
β βββ main.py # WebSocket hub + HTTP display API
β βββ protocol.py # wire schema (mirrored by the client)
β βββ config.py # environment-only configuration
β βββ wake.py # openWakeWord over the inbound audio
β βββ gemini_live.py # Live session lifecycle, audio + video
β βββ alarms.py # alarm/timer scheduling + acknowledgement
β βββ weather.py # Open-Meteo polling for the ambient card
β βββ govee.py # optional BLE light control
β βββ memory.py # small local memory store
β βββ spotify.py # librespot supervisor, arbitration, cards
β βββ spotify_api.py # the Spotify Web API calls, and only those
β βββ spotify_auth.py # OAuth (PKCE) + the gitignored token file
β βββ resample.py # 44.1 kHz stereo β 24 kHz mono PCM16
β βββ requirements.txt
β βββ install-service.ps1 # Windows Task Scheduler registration
β βββ tests/ # pytest: no hardware, no key, no network
β βββ tools/ # fake device, display demo, spotify login
βββ EchoTerminal/
βββ local.properties.example # server URL + shared secret
βββ app/src/main/java/com/echogemini/terminal/
ββ MainActivity.kt # launcher, layer switching
ββ AmbientClock.kt # local clock β no network dependency
ββ AmbientWeb.kt # WebView layer for pushed content
ββ PushSurface.kt # overlay surface
ββ StatusOverlay.kt # UI state + CAMERA ON indicator
ββ ScheduleScreen.kt # alarms and timers, rendered locally
ββ AlarmScheduler.kt # local scheduling, survives reboot
ββ Stopwatch.kt
ββ Link.kt # persistent WebSocket, backoff, heartbeat
ββ Protocol.kt # mirror of server/protocol.py
ββ AudioCapture.kt # AudioRecord + gain + VAD gate
ββ AudioPlayback.kt # AudioTrack + barge-in flush (the voice)
ββ MusicPlayback.kt # a SECOND AudioTrack, USAGE_MEDIA (Spotify)
ββ CameraSource.kt # single-owner, β€1 FPS, safe lifecycle
ββ BootReceiver.kt
Nothing below needs the Show, and nothing below needs a Gemini API key. With no
key the server starts, holds the device link, runs the wake word and serves
POST /display β it just logs that the Gemini leg is disabled. That is the
supported way to bring the software up before the hardware exists.
Python 3.11+. Every dependency installs from a prebuilt wheel; no compiler
needed. The commands below are PowerShell β on Linux/macOS substitute
python3 -m venv .venv && . .venv/bin/activate.
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r server\requirements.txtCopy-Item .env.example .envThen edit .env. The only required value is the shared secret β the server
refuses to start without one, because an unauthenticated WebSocket on a private
network is exactly what it guards against:
python -c "import secrets; print(secrets.token_urlsafe(32))"Paste that into ECHO_SHARED_SECRET. Leave GEMINI_API_KEY empty for now.
.env is gitignored. The API key lives only on the host β never in the repo,
never on the device.
python server\main.pyINFO echo.server echo-server starting: listen=0.0.0.0:8765 live=off (no GEMINI_API_KEY) wake=alexa vision=on_demand idle_close=120s
The first run downloads the openWakeWord ONNX models (~8 MB); startup is slower that once.
Three terminals.
# 1 β the server
python server\main.py
# 2 β a fake Echo Show: connects, streams a bundled TTS sample, prints
# everything the server sends
python server\tools\fake_device.py[ 0.00s] <- welcome protocol=v1 heartbeat=15s audio=16000->24000 Hz live=DISABLED (no API key)
[ 0.09s] <- mic OPEN gain=1
[ 0.41s] -> streaming wake-sample.wav: 5.0s x1 as 20 ms frames
[ 1.12s] <- state LISTENING <-- the wake word fired
[ 4.11s] <- ping 1 -> pong
# 3 β push each display type at it
python server\tools\test_display.pyTerminal 2 shows every push arriving on the device socket. Other useful flags:
python server\tools\fake_device.py --no-audio # just hold the link
python server\tools\fake_device.py --tap # tap-to-talk
python server\tools\fake_device.py --stop-tap 1 # tap-to-stop, once
python server\tools\fake_device.py --shutter # simulate the privacy latch
python server\tools\fake_device.py --save-reply out.wavpython -m pytestNo hardware, no API key, no network. Covers protocol round-trips, display API validation and routing with a device attached, wake-word gating, alarm scheduling, and session idle-close against a mocked Live client.
Get a key from https://aistudio.google.com/apikey, put it in .env as
GEMINI_API_KEY, and restart.
Confirm the model id before you do. The Live model line gets renamed
regularly β GEMINI_MODEL is configuration, not a constant. Check
https://ai.google.dev/api/live for the current id and set it in .env.
Then:
python server\tools\fake_device.py --tap --save-reply reply.wavSpeak to it and hear it back, entirely on the desktop. This proves key, quota and model id while debugging is still cheap.
| Route | Auth | Does |
|---|---|---|
GET /health |
none | status: link, session, wake word, vision |
GET /ws |
X-Echo-Secret |
the device link |
POST /display |
X-Shared-Secret |
push content; 503 if no device |
POST /display/clear |
X-Shared-Secret |
back to the clock |
POST /vision |
X-Shared-Secret |
manual camera override |
GET /spotify/art/{id} |
none | album art proxy for the device |
curl -X POST http://your-host:8765/display \
-H "X-Shared-Secret: $ECHO_SHARED_SECRET" \
-H 'Content-Type: application/json' \
-d '{"type":"text","payload":{"text":"Bus 62 in 4 min","subtitle":"Westcott"},"duration":30}'type is one of text | html | image | timer | panel. duration is seconds
(0 = until replaced). priority breaks ties. html is why "anything via API"
is true β weather, calendar, transit, dashboards, with no new APK.
Optional and off by default. librespot runs on the host as a subprocess, registers as a Spotify Connect speaker, and its PCM is resampled (44.1 kHz stereo β 24 kHz mono) and sent down the existing device link on its own audio channel β so the Show stays a speaker and a display, with no Spotify client, no DRM and no Google services on the device.
Needs Premium, a librespot binary on the host, and a one-time browser login
(server/tools/spotify_login.py). All the variables are documented in
.env.example.
Unproven end to end. Everything below the binary is covered by tests against
fakes, but upstream renames librespot flags between minor releases β confirm
--backend pipe writes PCM to stdout before expecting audio.
The debug APK builds with JDK 17 and the Android SDK. The Kotlin code also has JVM unit tests for local scheduling, persistence and time arithmetic.
| JDK | 17 (AGP 8.1 requires it) |
| Android SDK | Platform 34 (compile), build-tools 34 |
| Gradle | 8.4 β via the wrapper, committed |
| Android Studio | Hedgehog or later, if you want an IDE |
Copy-Item EchoTerminal\local.properties.example EchoTerminal\local.propertiesSet echo.serverUrl to the host's reachable address (a MagicDNS name survives
the host changing IP) and echo.sharedSecret to the same value as
ECHO_SHARED_SECRET in .env. Then:
cd EchoTerminal
.\gradlew.bat testDebugUnitTest assembleDebug
adb install -r app\build\outputs\apk\debug\app-debug.apkThe shared secret is compiled into
BuildConfigand is recoverable from the APK by anyone holding the device. That is acceptable: it is defence in depth behind the private network, not the security boundary. It is also exactly why theGEMINI_API_KEYnever goes near the device.
adb shell pm grant com.echogemini.terminal android.permission.RECORD_AUDIO
adb shell pm grant com.echogemini.terminal android.permission.CAMERA
adb shell cmd package set-home-activity com.echogemini.terminal/.MainActivity
adb rebootDeploy the app with the server stopped. The clock must render, survive a reboot, and show a clear disconnected state. Test it by making it fail.
server/install-service.ps1 registers an at-boot Windows Task Scheduler task
running as SYSTEM with auto-restart. It writes no secrets into the task
definition β those stay in .env. On Linux/macOS use systemd or launchd
instead; the script is Windows-only.
# from an ELEVATED PowerShell, at the repo root
.\server\install-service.ps1
.\server\install-service.ps1 -AddFirewallRule -Port 8765 # optional
.\server\install-service.ps1 -Uninstall
Get-Content server\data\service.log -Tail 50 -WaitAn always-on host that goes to sleep is not always-on. The script deliberately
does not touch your machine's power plan β do it yourself: disable sleep and
hibernate, disable USB selective suspend, disable fast startup, and scope the
firewall rule to your private network (better: set ECHO_HOST to a private-IP
address so the listener never binds anywhere else).
Every variable is documented in .env.example. The ones worth
knowing about:
| Variable | Default | Why you would change it |
|---|---|---|
ECHO_SHARED_SECRET |
(none β required) | Must match the client |
GEMINI_API_KEY |
(empty) | Empty = Live off, everything else on |
GEMINI_MODEL |
see .env.example |
Check https://ai.google.dev/api/live |
SESSION_IDLE_TIMEOUT |
120 |
Live bills by session duration |
POST_ANSWER_SILENCE_S |
8 |
Returns to the clock after the model stops talking |
WAKE_MODEL |
alexa |
hey_jarvis, hey_mycroft, or a custom .onnx |
WAKE_THRESHOLD |
0.5 |
Raise if the TV sets it off; lower if it misses you |
VISION_MODE |
on_demand |
off, or always |
MIC_GAIN |
1.0 |
A placeholder β tune it from recordings |
SPOTIFY_ENABLED |
false |
Music. Needs Premium + a one-time login |
The device side is the part that will cost you a weekend. Three things that break silently:
- Reinstalling the ROM breaks the camera until the
libcmdqeventshim is built and installed again, then rebooted. The only symptom isNumber of camera devices: 0β everything else looks normal. The patch source this build used is https://github.com/jxlarrea/lineageos-echo-show-camera. - Do not connect the device to Wi-Fi before the unlock phase completes. An OTA can patch the LK bootloader and permanently close the exploit window. The offline state is what is protecting it.
- Use amonet 2.0.1 or newer, branch
mt8163-checkers(https://github.com/R0rt1z2/amonet/tree/mt8163-checkers). The camera patches cannot run on a device unlocked with 1.x, and the partition layout differs.
The unlock and LineageOS build are upstream projects; this repo starts from a device that already boots a rooted LineageOS 18.1 with the camera and Bluetooth patches applied.
Each of these is in the code for a reason that cost something to learn.
- The clock has no network dependency.
AmbientClockdoes not importLink. If the host is off, the Show is still a clock. - Never force-kill
cameraserver. Doing so while streaming causes an IOMMU livelock that requires physically power-cycling the device.CameraSourcehas nokillProcess, no force-stop and no retry loop. On error it releases, reports, and latches off. - One camera owner, opened on demand. HAL1 is single-client. The camera opens only when the server asks for vision and is released the moment the session ends, on every exit path.
- The camera indicator sits above pushed content. A camera streaming to a cloud model must be visibly doing so.
- Idle-close is cost control, not polish. Gemini Live bills for the whole time a session is open.
- Tap-to-talk is permanent. The mic is weak enough that the wake word will sometimes miss.
- Half-duplex on purpose. Suppressing the uplink while the server speaks sidesteps acoustic echo cancellation on a device with one weak microphone.
- Music has its own audio channel and its own
AudioTrack. Merging it into the voice channel would still be wrong: that path reports speaking state, which closes the mic uplink, so an album playing would leave no way to say "pause". - Voice and vision processing stay on the host. The clock, alarms and timers run locally so they keep working with the host switched off.
- The microphone is the real risk. One mic of the array, low gain. Whether far-field wake word is viable is empirical and only answerable on the unit.
- The host is a single point of failure for voice and vision β deliberately not for the clock.
- You lose Alexa permanently. Only a full TWRP backup restores it.
- Camera frames go out at 720Γ720, not 768Γ768. The sensor's native capture is 1280Γ720 and its centre square is 720; the API recommends 768 rather than requiring it, and upscaling would invent detail.
- Spotify is written but unproven end to end β see above.
- One unit, one build. Nothing here has been validated on a second device, a second Android version, or a non-Windows host.
- Gemini Live API β https://ai.google.dev/api/live
- Live API capabilities (audio + video) β https://ai.google.dev/gemini-api/docs/live-api/capabilities
- openWakeWord β https://github.com/dscripka/openWakeWord
- amonet,
mt8163-checkersbranch β https://github.com/R0rt1z2/amonet/tree/mt8163-checkers - Camera and Bluetooth patches β https://github.com/jxlarrea/lineageos-echo-show-camera
- Tailscale APKs (
armeabi-v7a, no Play Services) β https://pkgs.tailscale.com
MIT β see LICENSE.