How akiani/aidialer works
Project type and purpose
• This is a full-stack, streaming AI phone-call application (“AI Dialer”) built around Twilio’s voice API, a FastAPI back end, a Streamlit front end, and multiple AI services (STT, LLM, TTS) working in concert to deliver low-latency, interruptible calls.
• The goal is to place or receive calls via Twilio, stream audio to/from callers over WebSocket, transcribe speech in real time, feed text to an LLM (OpenAI or Anthropic), synthesize voice responses (Deepgram or ElevenLabs), and send them back to the caller.
File structure
Top-level files and directories:
• app.py – FastAPI server entrypoint
• services/ – modules that wrap external APIs and internal event handling
• call_context.py – per-call state management
• event_emmiter.py – pub/sub for audio & control events
• llm_service.py – text-to-text LLM orchestration
• transcription_service.py – real-time speech-to-text
• tts_service.py – text-to-speech output
• stream_service.py – audio chunk management over WS
• functions/ – Twilio webhook “function calls” invoked by the LLM for actions like end_call and transfer_call
• ui/streamlit_app.py – lightweight Streamlit UI to initiate calls and watch progress
• logger_config.py, settings.json, .env.example – configuration and logging
• examples/ – sample audio and screenshot
Key points from the README
• FastAPI exposes endpoints for Twilio ML webhooks and WebSockets.
• Twilio both triggers incoming-call webhooks and streams audio bi-directionally via WS attachments.
• The system is built for streaming→interruptibility: it handles “end of utterance” events, mid-sentence interruptions, and dynamic function calls.