How monke-sniper/second-ear works
Second Ear is a live phone-scam detection web app for an older caller and a family member. The main workflow streams microphone audio to the server, transcribes chunks, scores the running transcript, applies alert and code-warning rules, then presents events and sends a family push. A separate replay/evaluation branch supports recorded calls and held-out comparisons. The graph preserves the documented explanation and privacy capabilities; some internal wiring is inferred only from README descriptions, so those links use README evidence.
Main entry points: pipeline.py Call pipeline · live.py Live socket · explainer.py Scam explanation · app.py FastAPI app
Components 28
Browser experience
- Audio client
web/call.js - Audio capture
web/audio-worklet.js - Risk display
web/view.js - Web app
web/app.js
Live call processing
- FastAPI app
server/app.py - Live socket
server/live.py - Audio chunker
server/chunker.py - Speech recognition
server/stt.py - Call pipeline
server/pipeline.py - Risk scorer
server/scorer.py - Wire contracts
server/contracts.py
Alerts and response
- Alert rules
server/alerts.py - Code warning
server/danger.py - Number redaction
server/numbers.py - Scam explanation
server/explainer.py - Safe prompt
server/explainer_prompt.py
External services
- Push notifier
server/notify.py - Anthropic API
- Gemini client
server/gemini_client.py - Gemini API
- ntfy service
Evaluation
- Call replay
eval/replay.py - Evaluation runner
eval/run_eval.py - Held-out scoring
eval/score_heldout.py - Metrics
eval/metrics.py - Keyword baseline
eval/keyword_baseline.py
Other components
- Caller
- Family member
Connections 29
- Caller → Audio capture: speaks near
- Audio capture → Audio client: streams audio
- Audio client → FastAPI app: sends audio
- FastAPI app → Live socket: routes socket
server/app.py - Live socket → Audio chunker: chunks audio
server/live.py - Live socket → Speech recognition: transcribes chunks
server/live.py - Live socket → Call pipeline: processes text
server/live.py - Call pipeline → Risk scorer: scores transcript
server/pipeline.py - Call pipeline → Alert rules: decides alerts
server/pipeline.py - Call pipeline → Code warning: checks number risk
server/pipeline.py - Call pipeline → Scam explanation: enriches alert
server/pipeline.py - Call pipeline → Safe prompt: redacts outbound text
server/pipeline.py - Live socket → Push notifier: sends notification
server/live.py - Live socket → Wire contracts: emits events
server/live.py - Web app → Audio client: uses audio client
web/app.js - Web app → Risk display: renders events
web/app.js - Risk display → Caller: shows risk alert
- Push notifier → ntfy service: publishes push
server/notify.py - ntfy service → Family member: delivers alert
- Scam explanation → Anthropic API: requests explanation
server/explainer.py - Scam explanation → Gemini client: selects provider
server/explainer.py - Gemini client → Gemini API: calls API
server/gemini_client.py - Scam explanation → Number redaction: redacts numbers
- FastAPI app → Call replay: serves simulation
server/app.py - Evaluation runner → Call replay: replays calls
eval/run_eval.py - Call replay → Call pipeline: uses live pipeline
eval/replay.py - Evaluation runner → Metrics: summarizes results
eval/run_eval.py - Held-out scoring → Keyword baseline: compares baseline
eval/score_heldout.py - Held-out scoring → Metrics: computes scores
eval/score_heldout.py