Railway service + TV UI #
Open the service URL on the television browser:
/(or/tv): live room display. Shows a QR and 4-character pairing code./pair: approve that screen from a phone or Mac (pasteASR_TOKENhere once)./?demo=1: explicitly labeled preview, with generated sound and sample entities./health: health check (unchanged).
Use Full screen or press F. For kiosk setups, the browser's own full-screen mode also works. The display is responsive through 720p, 1080p and 4K. Cards appear randomly in free space and remain across reloads. Repeated detections increment the card's ×N mention badge, pulse it, and bring the same card to the front without changing its position or color. No timer, capacity limit, or resize removes cards; when free space runs out, newer cards may overlap older ones. The latest transcript appears briefly beneath the waveform.
BUILD xxxxxxxx stays visible at the lower-left, including over the TV pairing
screen and on the phone approval page. This is an automatic fingerprint of the
shipped Python sources and static assets, not a manually maintained Git label.
Code changes produce a new ID; restarts of identical code keep the same ID.
Static responses also carry it in the X-Roombox-Version header.
Speech detection and hallucinations #
The ESP32's adaptive energy trigger can open for handling noise, clicks, and
other non-speech sounds. Before Whisper, speech_gate.py now checks the full
original burst with faster-whisper's bundled Silero ONNX classifier. It requires
100 ms of speech evidence at a 0.35 threshold. Rejected bursts never reach
Whisper or NER, and log audio_rejected / no_speech with duration, not audio.
The TV immediately stops showing processing when no text is returned.
This is a presence check, not a second segmentation pass: accepted audio keeps its word onsets/tails, then receives the existing quiet-edge trim. Whisper's own VAD cutting remains off to avoid losing short names. Decoding uses temperature 0 only, rather than retrying uncertain audio at higher, more inventive temperatures. No holiday/"thank you" phrase blacklist is used.
Tests run the real classifier on generated silence, noise, hum, tones, clicks, and synthetic half-second names with padding and attenuation. Existing mic recordings were also replayed locally. This reduces a demonstrated source of hallucination; it cannot guarantee Whisper never invents text, distinguish a TV voice from a person, or prove accuracy in this room without observation. No microphone audio is retained. Existing saved cards are not automatically erased; use Clear cards to remove previously hallucinated cards.
Entity history and precision #
Names/descriptions are saved to this browser's localStorage (roombox-entities-v1)
and restored on reload, even before new results arrive. Mention counts, Wikidata
IDs, and back-to-front ordering are saved too; reloading does not increment a
count. Legacy cards without counts start at one (old repeats weren't recorded),
and duplicate saved names merge their counts. Case, Unicode normalization, and
whitespace differences share a card; matching Wikidata IDs also merge linked
aliases. Distinct known IDs stay separate even if their names coincide. Counts
track received entity detections, not every spoken word occurrence within a
transcript. The footer counts unique cards, not total mentions.
Demo cards never read or modify that history. Clear cards deletes it on this TV without unpairing
or stopping new entities. Storage failures are displayed visibly; cards still
render but may not survive a reload. Audio and full transcripts aren't stored.
History stays on this device after disconnection/revocation until explicitly
cleared; pairing still gates the live feed. Cards from versions predating this
storage feature cannot be retroactively recovered from the old page.
The English NER pipeline rejects pronoun/function-word-only spans (shared rules
in static/entity-rules.json) before any Wikidata lookup. It also requires a
name-like capitalized span, an allowed NER category, sufficient confidence, and
whole-word grounding in the transcript. Names like Heather, YouTube, and WeWork
are not substring-blocked. This favors precision: ambiguous titles such as
'Her', entirely lowercase brands, and some acronym collisions are suppressed.
The TV independently rejects pronoun cards and removes them from saved history.
Wikidata's first fuzzy/prefix search result is not accepted as an identity. Only one unambiguous exact label/alias match among the returned candidates is linked; otherwise the entity remains unlinked. This prevents He → Hebrew, you → YouTube, and her → Hercules. It does not solve contextual disambiguation or guarantee all remaining entities are correct; real conversations remain the acceptance test.
LG keep-awake loop #
Vendored @ondafloor/tv-keep-awake experimental 0.1.0 from ../ondafloor:
static/vendor/tv-keep-awake/ contains the classic bundle, its 1,820-byte 64x64
H.264 MP4, and MIT license. No CDN or runtime dependencies are needed.
The host automatically starts the muted loop on page load (including the pairing screen), resumes it on visibility/pageshow, and retries failures with 3–60 second backoff while visible. Hidden/background pages release their video decoder. Ordinary pointer/key input supplies a gesture retry if autoplay is denied; the status button also retries but never disables a healthy loop. Fullscreen remains optional and requires user interaction, per browser policy.
The video stays on-screen at 1x1 CSS pixel, opacity 1, above the page; don't hide or cover it. Awake loop: on confirms advancing playback, not guaranteed screensaver suppression. The badge uses actual media-time progress, with a 15-second grace period for brief automatic recovery, rather than flashing a failure on each transient library error. If playback never starts or stops advancing for 15 seconds, the failure banner becomes visible while retries continue. A newer successful start cannot be overwritten by an older rejected start promise. No Wake Lock API or synthetic input is used. Automatic start/recovery passes Chrome tests; the LG's reported Media error 3 is not yet resolved or validated.
The tiny loop was reported working on the LG OLED42C5PSA in the source project; the combined Roombox integration still needs long-duration observation. Samsung S95F is explicitly unsupported. This is not an OLED protection override.
Live data and access #
The HTML/CSS/JS shell is public but contains no credentials or conversation data.
The TV connects to /live with {"pair":true} and shows a random four-character
code (5-minute expiry) and a locally generated QR linking to /pair?code=ABCD.
No room data is sent before approval. On a phone/Mac, paste the room's ASR_TOKEN
once and approve the matching code. The owner credential stays in that tab's
sessionStorage; it is never sent to the TV or included in any URL or QR.
Approval uses a separate /authorize WebSocket. It requires the room token,
consumes the code once, and issues a random viewer-only credential to the waiting
TV. The TV stores it in localStorage and reconnects using {"session":"..."}.
It cannot publish device audio or approve other screens. Credentials expire for
new connections after 7 days. Approved session hashes and expirations live in
SQLite on the attached Railway volume: server restarts/deploys do not require
re-pairing. Revocations are committed to the same database and survive restarts.
Only short-lived pending codes, connection handles, and rate limits are in-memory;
requests/approvals are bounded and disconnected/expired requests are cleaned up.
Production mounts the esp32-asr-volume at /data; the database defaults to
$RAILWAY_VOLUME_MOUNT_PATH/pairing.sqlite3. PAIRING_DB may override the filename
but must stay within that volume. Railway startup fails rather than silently
using ephemeral session storage. Local development/tests default to :memory:
unless a path is configured. No bearer credentials or room history are stored in
SQLite, only SHA-256 hashes of high-entropy viewer credentials and UTC expirations.
Deleting the volume or clearing browser storage still requires pairing again.
Sessions lost by versions predating durable storage cannot be recovered.
Use Pair TV to show a new code. On /pair, Disconnect all paired TVs
revokes their credentials and closes their active connections. Legacy direct
owner-token /live clients remain supported, but the TV UI never asks for it.
The feed reconnects with backoff and heartbeats. No microphone permission is needed.
Authenticated viewers receive:
ready/status: number of connected devices.waveform: 64 normalized signed peaks from the device PCM, not playable audio.processing: device has signaled end-of-utterance.utterance: the same text,proper_nouns, and linkedentitiesreturned to the ESP32. Cards use names/descriptions as plain text, never HTML.
The waveform is real speech-gated device input, so it settles to a flat line when the device is quiet. It is not a continuous idle-room microphone feed. Slow viewers keep only the latest waveform and a bounded event queue; they cannot block the device handler. The server retains no viewer history; new live events are combined with this TV's locally saved cards.
The existing device routes / and /ws still accept ?token=... and the
MIC3, eou, and ping protocol. Browser viewers cannot submit device audio.
Only the approving device needs the room's bearer token; don't share it publicly.
Verification #
From the repository root:
.venv/bin/python -m unittest discover -s tests -p 'test_*.py' -v
HTTP/WebSocket tests stub Whisper/NER inference (no model downloads). Speech-gate
regressions additionally exercise the real bundled Silero classifier when
faster-whisper and onnxruntime are installed (otherwise those cases skip).
They check
static assets, access controls, live PCM visualization, entity fan-out, device
compatibility, bounded buffers, pairing expiry/single-use, viewer-only sessions,
durable reconnect and revocation across server/store restarts, invalid credentials,
and rate limits. The explicit websockets.legacy API matches
production's pinned websockets==13.1 and also runs with newer local versions.
Optional Chrome smoke tests (requires Playwright, jsqr, and installed Google Chrome):
PLAYWRIGHT_MODULE=/path/to/node_modules/playwright JSQR_MODULE=/path/to/node_modules/jsqr node tests/tv_browser.cjs
These start a temporary local mock service, decode the actual QR image, approve
and revoke a TV, verify session/card persistence, history clearing and quota errors,
pronoun cleanup, mention counts and legacy migration, name/QID deduplication,
reload persistence, real overlap stacking without movement/recoloring,
automatic 1px media playback/recovery, transient-error grace and sustained-failure
reporting, and test
720p/1080p/4K/mobile layouts, and write screenshots to /tmp/roombox-tv-*.png.
They never connect to production.
Deploy from this directory with railway up --ci. The Docker image includes
app.py, live.py, pairing.py, entity_filter.py, session_store.py,
speech_gate.py, and static/; no frontend build or external CDN is needed.