Inspiration

Every minute without CPR reduces cardiac arrest survival by 10%. But most bystanders freeze — not because they don't want to help, but because they're doing it alone, uncertain, and panicked. We asked: what if your phone could be your CPR coach and your emergency dispatcher at the same time?

CPR Super Phone is designed for the rescuer — the bystander, first responder, or caregiver who is already performing CPR and needs a hands-free assistant, not another thing to figure out.

What it does

CPR Super Phone is a mobile PWA that turns any smartphone into a full cardiac emergency response system:

Because Twilio trial accounts cannot directly dial 911, the call routes to a pre-verified demo number — but the AI-generated emergency report, GPS coordinates, and patient status are identical to what a real dispatch call would contain.

Real-time CPR coaching — the accelerometer tracks chest compression rate live; an AI voice agent gives spoken feedback in the moment ("compress faster," "good rhythm, keep going") Pulse monitoring — the rear camera samples full-frame red channel values and applies autocorrelation with real FPS estimation to calculate BPM; a median filter over 8 readings stabilizes output; values clamp to physiological range 55–100 and reset when the finger leaves the sensor Context-aware voice agent — three modes: PPG mode proactively announces BPM every 6 seconds; CPR mode responds only when compression-related speech is detected; idle mode handles general guidance Emergency dispatch — one tap on "CALL 911" packages GPS coordinates, compression rate, BPM, and active mode into a payload, triggers a Twilio outbound call simulating a dispatcher, and displays the AI-generated emergency report inline on the screen so the rescuer can see exactly what was communicated

How we built it

Built in a single 5-hour sprint (11 AM–4 PM). Stack is lean by design:

Frontend PWA (GitHub Pages) — Web Speech API for voice I/O, DeviceMotion API for compressions, getUserMedia for full-frame PPG sampling, GPS via watchPosition; WebSocket auto-connects on load with 3s auto-reconnect Backend — FastAPI + uvicorn on Windows, tunneled via ngrok, routes sensor snapshots to Claude on every voice message AI layer — Claude (claude-sonnet-4-5) with four modular prompts: compression analysis, heart rate judgment, voice interaction control, and 911 report generation Emergency dispatch — Twilio Programmable Voice for outbound calling (SMS attempted first but blocked by A2P 10DLC registration — no equivalent restriction on voice calls)

CPR mode (accelerometer) and Pulse mode (PPG) are mutually exclusive toggles — you physically can't compress a chest and measure a pulse simultaneously. GPS always runs in the background.

Challenges we ran into

Sensor access on mobile — DeviceMotion and camera APIs are blocked in sandboxed environments; GitHub Pages PWA was the only reliable workaround Twilio 911 restriction — trial accounts can't dial 911 directly; demo calls route to a Verified Caller ID with an AI-generated emergency script read aloud Twilio SMS dead end — SMS failed with "Undelivered" due to A2P 10DLC registration (a multi-day process); caught it from the Twilio Console warning banner and pivoted to voice calls mid-sprint PPG accuracy — naïve single-pixel sampling was too noisy; switching to full-frame getImageData(0,0,200,150) with finger detection (r > 90 && r > g * 1.3), standard deviation quality gating, real FPS estimation from timestamps, and median filter stabilization made a significant difference Voice feedback loop — STT had to be explicitly paused before TTS playback and restarted only after utterance.onend to prevent the agent from hearing itself WebSocket protocol mismatch — frontend was sending type:'voice' but backend expected type:'speech'; caught and fixed mid-sprint

Accomplishments that we're proud of

Shipping a full sensor-to-dispatch pipeline in 5 hours. Accelerometer → PPG → GPS → AI voice agent → Twilio outbound call, all wired together and working on a real phone by demo time. PPG heart rate detection that actually works. Getting reliable BPM from a phone camera in-browser is harder than it sounds. Full-frame pixel sampling, autocorrelation with real FPS estimation, finger detection, quality gating, and median filtering — the reading is stable enough to use in an emergency context. A voice agent that knows when to talk and when to shut up. The three-mode prompt design (proactive in PPG, passive in CPR, general in idle) was a small architectural decision that made the interaction feel natural rather than noisy. An AI that interrupts you mid-compression would be worse than no AI at all. Catching and recovering from every major failure mid-sprint. SMS blocked by A2P 10DLC → pivoted to voice calls. WebSocket protocol mismatch between frontend and backend → caught and fixed. TTS/STT feedback loop → resolved with explicit mic pause/resume. None of these were planned for, and all of them got resolved. One button that closes the loop. Tap CALL 911 → sensor data packaged → Twilio call placed → AI report generated → displayed on screen. The rescuer never has to describe the situation manually. That felt like the right product to build.

What we learned

Ship the core loop first. We validated voice interaction → sensor fusion → Twilio calling in that exact sequence and didn't touch UI polish until each layer was confirmed stable. In a 5-hour sprint, that discipline is the difference between a demo that works and one that crashes on stage.

What's next for CPR Super Phone

Real emergency dispatch integration. Right now the 911 call routes to a demo number due to Twilio trial restrictions. The next step is integrating with NG911 (Next Generation 911) APIs that accept structured data — so GPS coordinates, compression rate, and patient vitals arrive at the dispatcher's screen before the call even connects, shaving off the 30–60 seconds typically spent describing location and situation. Lower-latency voice with OpenAI Realtime API. The current Web Speech API + WebSocket pipeline has noticeable round-trip delay. Switching to a streaming audio model eliminates that gap — critical when someone is panicking and needs feedback on the compression they just did, not the one three seconds ago. Multi-bystander coordination. Cardiac arrest in public rarely has just one bystander. The next version should let the first responder broadcast a room code; a second person can join, take over compression coaching, while the first handles the 911 call and AED retrieval — with the AI orchestrating handoffs between them. AED locator overlay. GPS is already running. Surfacing the nearest AED on screen the moment CPR mode activates is a one-API-call addition that could meaningfully change outcomes. Clinical validation. The PPG and accelerometer readings need to be benchmarked against medical-grade equipment before this can be used in any real protocol. That's the work that turns a hackathon demo into something hospitals and first responder programs would actually deploy.

Built With

Share this project:

Updates