How awaazai/freeswitch_modules works
1. What this repo is
This is a collection of FreeSWITCH loadable modules that extend the media server with cloud speech capabilities: real-time transcription, text-to-speech, audio streaming/forking, VAD, and a few related utilities. The modules are mainly intended for drachtio-fsmrf-based apps, but they integrate at the FreeSWITCH module boundary and can be used in generic FreeSWITCH deployments.
2. Primary runtime boundary
The architectural center is FreeSWITCH itself. Each module is a plugin loaded into FreeSWITCH and invoked through FreeSWITCH’s module/API/event hooks. The repo does not contain a standalone server; instead, it adds capabilities inside the telephony/media runtime.
3. Main subsystem families
The modules cluster into a few functional families:
- Transcription modules: mod_google_transcribe, mod_deepgram_transcribe, mod_aws_transcribe, mod_aws_transcribe_ws, mod_azure_transcribe, mod_assemblyai_transcribe, mod_ibm_transcribe, mod_nuance_transcribe, mod_soniox_transcribe, mod_verbio_transcribe, mod_bodhi_transcribe, mod_cobalt_transcribe, mod_jambonz_transcribe, mod_nvidia_transcribe
- TTS modules: mod_google_tts, mod_deepgram_tts, mod_rimelabs_tts, mod_verbio_tts, mod_whisper_tts, mod_custom_tts
- Media/audio utilities: mod_audio_fork, mod_vad_detect, mod_dub
- Conversation/NLU integration: mod_dialogflow
- Vendor-specific glue/protocol support: several grpc_protobuf/* trees and FreeSWITCH config patches
4. Common implementation pattern
Most modules follow the same internal layering:
- A C module entrypoint (mod_*.c) that FreeSWITCH loads
- One or more C++ glue layers (*_glue.cpp/.h) that wrap the vendor SDK or protocol
- A small set of shared helpers such as audio_pipe, parser, simple_buffer, and sometimes base64, vector_math, or crc
This separation keeps the FreeSWITCH-facing code thin while isolating vendor-specific networking and serialization logic in the glue layer.
5. How audio flows through the system
The dominant data flow is:
FreeSWITCH channel audio -> module capture/pipe/buffer -> vendor SDK or streaming API -> transcription/TTS result -> FreeSWITCH callbacks/events/API response
For transcription, audio is usually streamed out of the call leg in near real time. For TTS, text or synthesis requests are sent to the provider and the returned audio is fed back into FreeSWITCH’s TTS or playback path. Modules like mod_audio_fork and mod_dub are about moving or transforming audio before it reaches the external service.
6. Streaming and transport choices
Different vendors use different wire protocols, and the repo mirrors that:
- gRPC for Google/other gRPC-based services and the protobuf-backed modules
- WebSockets for some streaming providers, including the AWS WebSocket variant and mod_audio_fork
- HTTP/SDK-based integrations for providers whose official SDKs are wrapped directly
The transport choice is not abstracted away globally; each module owns its own protocol adapter.
7. Special media-processing components
mod_audio_fork is the clearest “media fan-out” component: it captures audio and forwards it out over WebSockets, with local buffering and DSP helpers. mod_dub appears to be a playback/overlay/transcoding-oriented media module, with file/HTTP audio sources and MP3 decode support. mod_vad_detect is a lighter utility module that detects voice activity rather than forwarding to a cloud service.
8. FreeSWITCH customization and packaging
The conf/ directory contains FreeSWITCH config overlays, patches, service files, and build extras. There are patches against FreeSWITCH core/media code and module lists, which indicates some modules require a custom-built FreeSWITCH rather than a stock install. The README calls out that Google and gRPC-based modules need FreeSWITCH built with gRPC support, and mod_audio_fork needs libwebsockets.
9. Protocol schema artifacts
The grpc_protobuf/ tree vendors multiple vendor API definitions:
- Cobalt Speech gRPC API
- Nuance ASR gRPC API
- NVIDIA Riva gRPC API
- Soniox ASR gRPC API
These protobufs are part of the build-time contract for the gRPC-based modules. They define the request/response and streaming message boundaries between FreeSWITCH-side code and the external speech services.
10. Examples and integration points
The examples/ directory shows how the modules are consumed in practice:
- Node.js examples for audio fork, AWS transcription, Google transcription/TTS, Dialogflow, and a WebSocket server
- A Lua test/example
- A default JSON config
These examples are not core runtime components, but they document the expected orchestration from an application layer, especially for drachtio-style call control.
11. Configuration and credentials
Some modules rely on external credentials or config files rather than hardcoded settings. The README specifically mentions GOOGLE_APPLICATION_CREDENTIALS for Google modules. Several modules also ship their own FreeSWITCH XML snippets under conf/ or module-specific conf/ directories, showing that deployment is partly controlled through FreeSWITCH config, not only through runtime API calls.
12. Architecture summary for a diagram
A clear diagram should show:
- FreeSWITCH core in the center
- Multiple pluggable modules attached to it
- A split between audio capture/processing and vendor protocol adapters
- Outbound links from modules to cloud speech/TTS/NLU providers
- A build/config layer made of FreeSWITCH patches, XML config, and protobuf definitions
- Optional application consumers such as drachtio/fsrmf or the example Node/Lua scripts
Main entry points: examples Examples · modules TTS mods · conf FreeSWITCH config · mod_google_tts Google TTS
Components 18
Runtime
FreeSWITCH-loaded media modules and their internal families
- FreeSWITCH · Host media server that loads and invokes the modules
- Transcribe mods · Streaming speech-to-text plugins for multiple vendors
modules - TTS mods · Text-to-speech plugins for provider APIs and SDKs
modules - Media utils · Audio routing, fork, VAD, and playback-oriented modules
modules - Dialogflow · Conversation integration module built around Google/Dialogflow glue
modules/mod_dialogflow - Google STT · Google transcription module with multiple glue versions
modules/mod_google_transcribe - AWS WS · AWS transcription variant that streams over WebSockets
modules/mod_aws_transcribe_ws - Audio fork · Captures call audio and forwards it out to external consumers
modules/mod_audio_fork - VAD detect · Voice activity detection module
modules/mod_vad_detect - Dub · Media overlay and source handling module with decode support
modules/mod_dub - Google TTS · Google text-to-speech plugin
modules/mod_google_tts - Deepgram TTS · Deepgram text-to-speech plugin
modules/mod_deepgram_tts - Custom TTS · Pluggable text-to-speech bridge for custom providers
modules/mod_custom_tts
Build & config
Patches, XML overlays, and protobuf contracts
- gRPC protos · Vendored protobuf contracts for gRPC-based speech modules
grpc_protobuf - FreeSWITCH config · Patches, XML overlays, service files, and build extras
conf
Examples
Consumer scripts and integration samples
- Examples · Node.js and Lua scripts showing module usage
examples
Cloud services
Vendor speech, TTS, and NLU endpoints
- Cloud speech · External STT, TTS, and NLU providers
- App layer · Call-control applications that orchestrate FreeSWITCH modules
Connections 29
- FreeSWITCH → Transcribe mods: loads · FreeSWITCH loads transcription plugins as modules
- FreeSWITCH → TTS mods: loads · FreeSWITCH loads TTS plugins as modules
- FreeSWITCH → Media utils: loads · FreeSWITCH loads media utility plugins as modules
- FreeSWITCH → Dialogflow: loads · FreeSWITCH loads the Dialogflow module
- Transcribe mods → Google STT: includes · Representative Google streaming transcription implementation
- Transcribe mods → AWS WS: includes · Representative AWS WebSocket transcription implementation
- TTS mods → Google TTS: includes · Google TTS implementation
- TTS mods → Deepgram TTS: includes · Deepgram TTS implementation
- TTS mods → Custom TTS: includes · Custom TTS integration point
- Media utils → Audio fork: includes · Audio fan-out and streaming component
- Media utils → VAD detect: includes · Voice activity detection component
- Media utils → Dub: includes · Playback and overlay component
- Google STT → Cloud speech: uses · Connects to Google's speech APIs
- AWS WS → Cloud speech: uses · Connects to AWS streaming speech APIs
- Google TTS → Cloud speech: uses · Connects to Google TTS services
- Deepgram TTS → Cloud speech: uses · Connects to Deepgram TTS services
- Custom TTS → Cloud speech: adapts · Custom provider bridge
- Dialogflow → Cloud speech: uses · Connects to Dialogflow-related Google services
- gRPC protos → Transcribe mods: schemas · Build-time gRPC contracts consumed by speech modules
- FreeSWITCH config → FreeSWITCH: patches · Config overlays and patches for FreeSWITCH integration
- FreeSWITCH config → Audio fork: enables · Deployment and module configuration support
- FreeSWITCH config → Google TTS: enables · Module-specific FreeSWITCH XML config
- Examples → Audio fork: demonstrates · Example app usage of audio fork
- Examples → Google STT: demonstrates · Example app usage of Google transcription
- Examples → Google TTS: demonstrates · Example app usage of Google TTS
- Examples → AWS WS: demonstrates · Example app usage of AWS transcription
- Examples → Dialogflow: demonstrates · Example app usage of Dialogflow integration
- Examples → App layer: targets · Scripts are meant to be driven from call-control apps
- FreeSWITCH → FreeSWITCH config: configured by · Modules depend on FreeSWITCH build/config overlays