Audio Awareness V1: live audio → Hearer brain → HUD#2
Draft
wdwd720 wants to merge 1 commit into
Draft
Conversation
Add a real (semi-real) audio pipeline alongside the existing simulator:
audio source → features → classifier → cooldown → signal mapper →
liveAudioDecision → existing priority/cue/action engines → HudOutputAdapter.
Audio layer (src/audio/):
- audioTypes.ts AudioFrame, AudioFeatures, AudioClassification,
AudioDetectionEvent, LiveContextOverride, snapshot
- audioSource.ts Web Audio mic + getDisplayMedia tab/system audio +
decodeAudioData file path with offline Goertzel
spectrum so file uploads use the same features
- audioFeatureExtractor RMS, peak, ZCR, dominant freq, energy bands,
tonality, beep/siren/speech/transient scores
- audioClassifier.ts Pluggable interface + RuleBasedAudioClassifier
(frequency-variation tracker for siren detection,
burst tracker for timer beeps) + PretrainedAudio
ClassifierStub hook for a future YAMNet swap
- audioSignalMapper.ts Per-label routing thresholds, maps to Hearer
AudioSignal (knock/speech_nearby added)
- audioController.ts Stateful orchestrator: source mgmt, cooldown,
debounce, auto-route toggle, manual route
- audioFixtures.ts Synthetic beeps/sirens/horn/knock/doorbell/
applause/speech-like buffers + WAV encoder so
fixtures run through the same decode pipeline
Glasses boundary (src/glasses/):
- hudOutputAdapter.ts interface
- simulatorHudAdapter.ts active in this build
- evenG2AdapterStub.ts wire-format only (no BLE/SDK in this build)
Engine extensions:
- types.ts: AudioEvent now includes "knock" and "speech_nearby"
- liveAudioDecision.ts: single-AudioSignal + override → DecisionResult
using the existing scenario engines; never
hallucinates a transcript from speech-like audio
- cueCompressor.ts: new live-audio compressors (timer-unknown, alarm,
loud-alert-unknown, doorbell-unknown, knock,
speech-nearby, applause, laughter)
- priorityEngine.ts: live_* scenario rules
- actionRouter.ts: live_* scenario routing (vibration sims for
physical alerts; awareness only for speech/crowd)
UI (src/components/audio/):
- AudioAwarenessPanel source controls, level meter, classifier status,
live context override, fixtures, last detection,
auto-route toggle, manual route button, log
- AudioLevelMeter, AudioFileDropzone, AudioClassifierStatus,
AudioDetectionLog
App wiring:
- App.tsx: refs for memory and override so the AudioController always sees
the latest state; subscribes to its decisions and routes them through
both the simulator HUD adapter and the Even G2 stub. Existing scenario
panel, auto-demo, and reset still work.
Tests (Vitest): 23 / 23 passing across cue compressor, priority engine,
action router, audio signal mapper, rule-based classifier, and the live
audio decision pipeline (kitchen vs unknown context, siren on street,
knock at home, speech_nearby never hallucinates a transcript).
Co-authored-by: wdwd720 <wdwd720@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Audio Awareness V1
Adds a real (semi-real) audio pipeline on top of the existing Hearer simulator brain. Same priority engine, same cue compressor, same action router, same HUD — fed now by mic / tab+system audio / file uploads / synthetic fixtures instead of only scripted scenarios.
The simulator, scenario panel, auto-demo, and engine layer from the merged MVP PR are untouched.
What's in here
Audio layer (
src/audio/)audioTypes.tsAudioFrame,AudioFeatures,AudioClassification,AudioDetectionEvent,LiveContextOverride, controller snapshot.audioSource.tsgetDisplayMediatab/system audio (audio-track required, video track dropped immediately),decodeAudioDatafor files plus an offline Goertzel-based coarse spectrum so file uploads exercise the same feature path.audioFeatureExtractor.tsAnalyserNode.getFloatFrequencyDatadBFS magnitudes.audioClassifier.tsAudioClassifierinterface.RuleBasedAudioClassifier(always available) tracks inter-frame frequency variation for siren detection and a burst counter for timer beeps.PretrainedAudioClassifierStubis the YAMNet plug point — intentionally not wired to TF.js / a remote model in this build.audioSignalMapper.tsAudioSignal(addedknockandspeech_nearby).audioController.tsaudioFixtures.tsGlasses boundary (
src/glasses/)hudOutputAdapter.ts— interface.simulatorHudAdapter.ts— active in this build.evenG2AdapterStub.ts— wire-format only:{ text, priority, actionType, ttlMs }. No BLE / SDK / device integration in this build. The stubsendCue()only logs the payload it would send. The boundary exists so a future Even Hub / Even G2 SDK swap is a one-file change.Engine extensions
types.ts—AudioEventnow includes"knock"and"speech_nearby".liveAudioDecision.ts— new entry point that takes a singleAudioSignalplus aLiveContextOverrideand runs the same priority engine / cue compressor / action router. Never hallucinates a transcript from speech-like audio.cueCompressor.ts— new live-audio compressors: timer-unknown, alarm, loud-alert-unknown, doorbell-unknown, knock, speech-nearby, applause, laughter.priorityEngine.ts—live_*scenario rules.actionRouter.ts—live_*routing (vibration sims for physical alerts; awareness only for speech/crowd).UI (
src/components/audio/)AudioAwarenessPanel— source controls (mic / tab+system / stop / file drop), test fixtures, audio level meter, classifier status chip, live context override (location + activity dropdowns and toggles for cooking routine / delivery expected / event mode), auto-route toggle, manual route button, last-detection card, error banner.AudioLevelMeter,AudioFileDropzone,AudioClassifierStatus,AudioDetectionLog.App wiring
App.tsxkeeps refs for memory and override so the audio controller always sees the latest state, subscribes to its decisions, and fans them out through both the simulator HUD adapter and the Even G2 stub. Reset stops audio capture.Live → HUD examples
Kitchen timer beeping. / Check stove.Timer beeping. / Check nearby.Road alert: / siren nearby.Loud alert nearby. / Look around.Doorbell. / Possible delivery.Knock detected. / Check door.Speech nearby. / Stay aware.Tests
npm test→ 23 / 23 passing across cue compressor, priority engine, action router, audio signal mapper, rule-based classifier, and the live audio decision pipeline (kitchen vs unknown context, siren on street, knock at home, speech_nearby never hallucinates a transcript).npm run build→ success (~207 kB JS gzipped to ~64 kB).Privacy & safety
Constraints honoured