How kaizer-1/respondr works
1. Top-level split: The repo is divided into a Python backend (backend/whisper_asr) that ingests and analyzes emergency calls, and a Next.js frontend (frontend/emergency-response-frontend) that presents operator and station workflows. The architecture is centered on moving a phone call from raw audio into a structured incident record.
2. Telephony ingress boundary: twilio_server/app.py is the backend entrypoint for Twilio webhooks. Twilio posts call and recording events to this service, so the backend must be reachable over a public HTTPS URL in production; locally the README assumes ngrok in front of port 8080.
3. Call recording and storage: Incoming recordings are kept on disk under backend/whisper_asr/recordings/, with temporary audio chunks in tmp_chunks/. Structured incident data is persisted in SQLite at backend/whisper_asr/data/respondr.db, making the backend both the processing engine and the system of record.
4. Speech-to-text subsystem: src/asr/offline_transcriber.py performs transcription using Whisper-based offline ASR. The README’s setup requirements (torch, openai-whisper, ffmpeg, soundfile, numpy, scipy) indicate audio decoding and model inference are local and compute-heavy, not SaaS-backed.
5. Call analysis pipeline: src/pipeline/process_call.py is the core orchestration layer. It likely coordinates audio normalization, transcription, NLP extraction, location inference, and database writes, turning one call recording into an incident object suitable for dashboards.
6. Emergency triage logic: The NLP layer (src/nlp/emergency_classifier.py, keyword_sets.py, location_extractor.py, semantic_fallback.py) classifies the incident into emergency type and priority, and extracts location cues from transcript text. This is the main intelligence boundary between raw transcript and dispatch-ready metadata.
7. Location enrichment subsystem: src/location/geocoder.py, metadata_provider.py, semantic_location.py, and location_fusion.py combine explicit place names with inferred or metadata-derived location context. This means location is not purely text extraction; it is fused from multiple signals before being shown to operators.
8. Streaming/near-real-time path: src/streaming/ contains live_pipeline.py, audio_chunker.py, transcript_buffer.py, state.py, and audio_utils.py, which support incremental processing while a call is still active. This is the real-time path that complements the offline recording pipeline and enables “live incoming calls” behavior.
9. Backend service boundaries: src/asr_service.py, src/db/call_repository.py, and src/db/database.py form the service/data-access boundary. The repository abstraction isolates incident persistence from the processing logic, which is important for diagramming the system as “analysis engine” feeding a “durable incident store.”
10. Frontend dashboards: The frontend is a role-based operator/station client built with Next.js App Router (app/operator/page.tsx, app/station/page.tsx). components/operator-dashboard.tsx, components/station-dashboard.tsx, and components/emergency-map.tsx indicate the UI is organized around live incident lists, dispatch actions, and incident context rather than generic pages.
11. Frontend-to-backend integration: lib/api.ts is the client-side API boundary used by the dashboards to read incidents and issue dispatch/resolution actions. The frontend is a presentation and workflow layer; the backend owns transcription, analysis, and persistence.
12. Operational scripts and test assets: migrate_database.py handles schema evolution, while run_call_analysis.py suggests an offline/batch analysis mode for replaying audio. The test_audio/ samples and stored recordings/ show the repo supports both live call handling and repeatable local testing.
Main entry points: process_call.py Call pipeline · live_pipeline.py Live pipeline · call_repository.py Call repository · operator-dashboard.tsx Operator dashboard
Components 20
Backend
Twilio ingress, audio processing, analysis, and persistence.
- Twilio webhook · Receives call and recording events from Twilio and starts backend processing.
backend/whisper_asr/twilio_server/app.py - Call pipeline · Coordinates normalization, transcription, analysis, and incident creation for a call.
backend/whisper_asr/src/pipeline/process_call.py - ASR service · Backend service layer that exposes transcription and processing capabilities.
backend/whisper_asr/src/asr_service.py - Offline ASR · Local Whisper-based speech-to-text engine for recordings and chunks.
backend/whisper_asr/src/asr/offline_transcriber.py - Normalizer · Prepares audio into a form suitable for transcription and downstream analysis.
backend/whisper_asr/src/normalizer.py - Live pipeline · Incrementally processes audio while a call is still active.
backend/whisper_asr/src/streaming/live_pipeline.py - Chunker · Splits live audio into smaller pieces for near-real-time handling.
backend/whisper_asr/src/streaming/audio_chunker.py - Transcript buffer · Accumulates partial transcripts during live call handling.
backend/whisper_asr/src/streaming/transcript_buffer.py - Emergency NLP · Classifies incident type and priority from transcript text.
backend/whisper_asr/src/nlp/emergency_classifier.py - Location NLP · Extracts place cues and location hints from the transcript.
backend/whisper_asr/src/nlp/location_extractor.py - Location fusion · Combines extracted, semantic, and metadata-based location signals.
backend/whisper_asr/src/location/location_fusion.py - Geocoder · Resolves location text into geospatial or structured address context.
backend/whisper_asr/src/location/geocoder.py - Call repository · Persistence abstraction for incident and call records.
backend/whisper_asr/src/db/call_repository.py - SQLite DB · Durable incident store backing the backend.
backend/whisper_asr/src/db/database.py
Frontend
Next.js operator and station workflows.
- Operator page · Role-based dashboard entry for call handling and incident review.
frontend/emergency-response-frontend/app/operator/page.tsx - Station page · Role-based station workflow entry for dispatch and station operations.
frontend/emergency-response-frontend/app/station/page.tsx - Operator dashboard · Shows live incidents, triage context, and operator actions.
frontend/emergency-response-frontend/components/operator-dashboard.tsx - Station dashboard · Supports station-facing dispatch and incident resolution workflows.
frontend/emergency-response-frontend/components/station-dashboard.tsx - Incident map · Visualizes incident location context for operators.
frontend/emergency-response-frontend/components/emergency-map.tsx - API client · Client-side interface used by dashboards to read and update backend state.
frontend/emergency-response-frontend/lib/api.ts
Connections 22
- Twilio webhook → Call pipeline: starts analysis · Twilio webhook events enter the call processing pipeline.
- Twilio webhook → Live pipeline: live calls · Active call audio can be routed into the near-real-time pipeline.
- Call pipeline → Normalizer: prepares audio · Recorded call audio is normalized before transcription.
- Call pipeline → Offline ASR: transcribes · The pipeline invokes offline Whisper ASR on call audio.
- Call pipeline → Emergency NLP: triages · Transcript text is classified into emergency type and priority.
- Call pipeline → Location NLP: extracts location · The pipeline pulls location cues from transcript text.
- Call pipeline → Location fusion: enriches location · Location signals are fused before incident creation.
- Call pipeline → Call repository: persists incident · Processed call output is stored through the repository boundary.
- ASR service → Offline ASR: uses ASR · The service layer delegates speech-to-text work to the transcriber.
- Live pipeline → Chunker: splits audio · Live audio is divided into chunks for incremental processing.
- Live pipeline → Transcript buffer: accumulates text · Partial transcripts are buffered during the live session.
- Live pipeline → Offline ASR: incremental ASR · Chunked audio is transcribed as it arrives.
- Location fusion → Geocoder: resolves places · Fused location handling can call into geocoding resolution.
- Location NLP → Location fusion: feeds cues · Extracted place hints flow into location enrichment.
- Emergency NLP → Call repository: writes triage · Classification output contributes to the stored incident record.
- Call repository → SQLite DB: stores in · Repository operations persist to the SQLite database.
- Operator page → Operator dashboard: renders · The route loads the operator workflow component.
- Station page → Station dashboard: renders · The route loads the station workflow component.
- Operator dashboard → API client: reads/updates · Operator actions and incident views go through the API client.
- Station dashboard → API client: reads/updates · Station workflows use the same backend API boundary.
- Operator dashboard → Incident map: shows context · Operator UI includes mapped incident context.
- API client → Call repository: backend calls · Frontend API operations ultimately target incident persistence and workflow endpoints.