How hamza-eldefrawy/arabic-voice-agent works
This is an Arabic voice customer-service agent. Its main turn flow receives audio, recognizes speech, streams an LLM response, splits it into speakable sentences, synthesizes audio, and returns speech; the server also supports browser sessions over WebSocket. The Brain can invoke search and prepare email or Telegram actions, but sending requires a later spoken confirmation. The README says the PostgreSQL conversation layer is not used by the current Brain. Some server and pipeline internals were not excerpted, so only documented or indexed connections are shown.
Main entry points: server.py WebSocket Server · brain.py Conversation Brain · main.py Local Voice Loop · llm.py Streaming LLM
Components 30
Speech I/O
- Audio Sources
src/asr/sources.py - Speech Detection
src/asr/vad.py - Segmented Recognition
src/asr/segmented.py - Whisper ASR
src/asr/whisper.py - HuBERT ASR
src/asr/hubert.py - ASR Selection
src/asr/factory.py - Speech Synthesis
src/tts/tts_engine.py - Text Normalizer
src/tts/normalizer.py
Conversation Brain
- Conversation Brain
src/brain/brain.py - Prompt Builder
src/brain/prompt_builder.py - Streaming LLM
src/brain/llm.py
Tools and Actions
- Tool Registry
src/brain/tools/__init__.py - Web Search
src/brain/tools/web_search.py - Email Action
src/brain/tools/email.py - Telegram Action
src/brain/tools/telegram.py - Human Escalation
src/brain/tools/human_escal.py
Session Serving
- Local Voice Loop
src/main.py - WebSocket Server
src/server.py - Turn Pipeline
src/pipeline.py
Conversation Storage
- Conversation Repository
src/brain/database/repository.py - Conversation Models
src/brain/database/models.py - PostgreSQL
Other components
- Speaker / Browser
- Shared Contracts
src/interfaces/schema.py - Runtime Settings
src/config.py - OpenAI API
- Tavily Search
- SMTP Service
- Telegram API
- Edge TTS Service
Connections 37
- Speaker / Browser → Local Voice Loop: speaks to
README.md - Local Voice Loop → Audio Sources: captures audio
src/main.py - Audio Sources → Segmented Recognition: provides frames
src/asr/segmented.py - Segmented Recognition → Speech Detection: detects speech
src/asr/segmented.py - Segmented Recognition → Whisper ASR: decodes segments
src/asr/whisper.py - Segmented Recognition → HuBERT ASR: decodes segments
src/asr/hubert.py - ASR Selection → Whisper ASR: selects engine
src/asr/factory.py - ASR Selection → HuBERT ASR: selects engine
src/asr/factory.py - Local Voice Loop → Conversation Brain: submits text
README.md - Conversation Brain → Prompt Builder: builds messages
src/brain/brain.py - Conversation Brain → Streaming LLM: streams response
src/brain/brain.py - Streaming LLM → OpenAI API: requests completions
src/brain/llm.py - Streaming LLM → Tool Registry: dispatches tools
src/brain/llm.py - Tool Registry → Web Search: registers tool
src/brain/tools/__init__.py - Tool Registry → Email Action: registers tool
src/brain/tools/__init__.py - Tool Registry → Telegram Action: registers tool
src/brain/tools/__init__.py - Streaming LLM → Human Escalation: uses escalation
src/brain/llm.py - Web Search → Tavily Search: searches web
src/brain/tools/web_search.py - Conversation Brain → Email Action: sends after approval
src/brain/brain.py - Conversation Brain → Telegram Action: sends after approval
src/brain/brain.py - Email Action → SMTP Service: sends email
src/brain/tools/email.py - Telegram Action → Telegram API: posts message
src/brain/tools/telegram.py - Local Voice Loop → Speech Synthesis: synthesizes sentences
README.md - Speech Synthesis → Text Normalizer: normalizes text
src/tts/tts_engine.py - Speech Synthesis → Edge TTS Service: generates speech
src/tts/tts_engine.py - Local Voice Loop → Speaker / Browser: plays audio
README.md - Speaker / Browser → WebSocket Server: streams browser audio
src/server.py - WebSocket Server → ASR Selection: builds recognizer
src/server.py - WebSocket Server → Conversation Brain: creates session brain
src/server.py - WebSocket Server → Turn Pipeline: runs turns
src/server.py - WebSocket Server → Speech Synthesis: creates synthesizer
src/server.py - WebSocket Server → Speaker / Browser: returns audio
src/server.py - Conversation Repository → Conversation Models: uses models
src/brain/database/repository.py - Conversation Repository → PostgreSQL: reads and writes
- Runtime Settings → ASR Selection: configures engines
src/asr/factory.py - Runtime Settings → Streaming LLM: configures client
src/brain/llm.py - Shared Contracts → Local Voice Loop: defines message types
src/main.py