How wiringai/mod_earshot works
Earshot is a FreeSWITCH module that bridges call media and control with AI agents over WebSockets. A dialplan application starts a stream; the module configures a protocol adapter and transport, sends caller audio, and plays decoded agent audio back into the call. The same session supports turn detection, barge-in, agent-issued call actions, masking, fan-out, and typed events and metrics. The graph reflects documented capabilities, but source excerpts are partial, so uncertain internal wiring—especially fan-out and masking—is not drawn.
Main entry points: mod_earshot.c FreeSWITCH Module · es_proto.c Protocol Adapters · es_ws.c WebSocket Client · es_codec.c Audio Codecs
Components 16
Call Integration
- FreeSWITCH Module
src/mod_earshot.c
Media Processing
- Audio Codecs
src/es_codec.c - Pipecat Protobuf
src/es_pb.c - VAD and Turns
src/mod_earshot.c - Playback Buffer
src/mod_earshot.c - Audio Fan-out
src/mod_earshot.c - PCI / PII Masking
src/mod_earshot.c
Agent Transport
- Protocol Adapters
src/es_proto.c - WebSocket Client
src/es_ws.c
Control and Observability
- Command Dispatch
src/mod_earshot.c - Command Guards
src/es_cmdguard.c - Call Events
src/mod_earshot.c - Latency Metrics
src/mod_earshot.c
Other components
- Dialplan / Caller
- AI Agent
- ESL Subscriber
Connections 25
- Dialplan / Caller → FreeSWITCH Module: starts stream
- FreeSWITCH Module → WebSocket Client: starts connection
- FreeSWITCH Module → Protocol Adapters: creates adapter
- FreeSWITCH Module → VAD and Turns: detects speech
- FreeSWITCH Module → PCI / PII Masking: masks media
- FreeSWITCH Module → Audio Fan-out: fans out audio
- FreeSWITCH Module → Audio Codecs: converts media
- Protocol Adapters → WebSocket Client: sends frames
- WebSocket Client → AI Agent: exchanges frames
- AI Agent → WebSocket Client: returns audio / control
- WebSocket Client → FreeSWITCH Module: delivers callbacks
- FreeSWITCH Module → Protocol Adapters: parses inbound data
- Protocol Adapters → Audio Codecs: encodes / decodes
- Protocol Adapters → Pipecat Protobuf: handles Pipecat frames
- FreeSWITCH Module → Playback Buffer: queues agent audio
- Playback Buffer → FreeSWITCH Module: supplies call audio
- FreeSWITCH Module → Command Dispatch: dispatches actions
- Command Dispatch → Command Guards: validates arguments
- Command Dispatch → FreeSWITCH Module: executes call APIs
- FreeSWITCH Module → Call Events: fires typed events
- VAD and Turns → Call Events: reports turn events
- Command Dispatch → Call Events: audits actions
- FreeSWITCH Module → Latency Metrics: collects counters
- Latency Metrics → Call Events: publishes metrics
- Call Events → ESL Subscriber: delivers events