Sign inSign up

rajunify123/freeswitch-mod-audio-fork

By rajunify123

•Updated 7 months ago

FreeSWITCH 1.10 + mod_audio_fork: real-time L16 audio streaming via WebSocket for AI & ASR.

Image
0

438

rajunify123/freeswitch-mod-audio-fork repository overview

⁠FreeSWITCH with mod_audio_fork

A production-ready FreeSWITCH 1.10 Docker image pre-built with mod_audio_fork — a module that forks live call audio and streams it in real-time over a WebSocket connection to any remote server. Ideal for AI voice agents, speech recognition (ASR) pipelines, real-time transcription, and conversational IVR applications.


⁠What is mod_audio_fork?

mod_audio_fork attaches a media bug to a FreeSWITCH channel and streams raw L16 (16-bit PCM) audio over a WebSocket (ws:// or wss://) to your backend in real-time. Audio is never written to disk, making this ideal for privacy-sensitive or "no data at rest" deployments.

It also supports receiving audio back from the WebSocket server and playing it to the caller — enabling full-duplex AI-driven conversations.


⁠Quick Start

docker pull rajunify123/freeswitch-mod-audio-fork:v1

docker run -d \
  --name freeswitch \
  --network host \
  -e EXT_SIP_IP=<your-public-ip> \
  -e EXT_RTP_IP=<your-public-ip> \
  -v /path/to/your/conf:/usr/local/freeswitch/conf \
  rajunify123/freeswitch-mod-audio-fork:v1

Note: --network host is recommended for SIP/RTP to avoid NAT issues in most deployments.


⁠Exposed Ports

PortProtocolPurpose
5060UDP/TCPSIP signalling
5061TCP/TLSSIP over TLS (SIPS)
8021TCPFreeSWITCH Event Socket (ESL)
5080UDP/TCPSIP (outbound profile)
16384–32768UDPRTP media streams

⁠Environment Variables

VariableDefaultDescription
EXT_SIP_IPautoPublic IP for SIP signalling
EXT_RTP_IPautoPublic IP for RTP media
DOMAINlocalhostFreeSWITCH domain
ESL_PASSWORDClueConEvent Socket password (change in prod!)

⁠Using mod_audio_fork

Once a call is established, trigger audio forking via the FreeSWITCH API:

uuid_audio_fork <uuid> start <wss-url> <mix-type> <sampling-rate> [metadata-json]

Parameters:

  • uuid — FreeSWITCH channel UUID
  • wss-url — WebSocket endpoint (ws:// or wss://)
  • mix-type — mono | mixed | stereo
  • sampling-rate — 8k or 16k
  • metadata-json — Optional JSON sent as the first frame before audio begins

Example:

uuid_audio_fork 8cf9eb-... start wss://my-asr-server.com/stream stereo 8k {"caller":"12125551234"}

Stop streaming:

uuid_audio_fork <uuid> stop

⁠Audio Playback from WebSocket Server

The WebSocket server can send audio back to play to the caller:

{
  "type": "streamAudio",
  "data": {
    "audioDataType": "raw",
    "sampleRate": 8000,
    "audioData": "<base64-encoded-pcm>"
  }
}

⁠Events Fired by the Module

Event NameDescription
mod_audio_fork::connectWebSocket connection established
mod_audio_fork::disconnectWebSocket connection closed
mod_audio_fork::transferData received from WebSocket server
mod_audio_fork::errorConnection or streaming error occurred

⁠Environment Variables for mod_audio_fork (build-time)

VariableDefaultDescription
MOD_AUDIO_FORK_SUBPROTOCOL_NAMEaudio.drachtio.orgWebSocket sub-protocol name
MOD_AUDIO_FORK_SERVICE_THREADS1libwebsocket service threads (max 5)

⁠Volumes

PathPurpose
/usr/local/freeswitch/confFreeSWITCH configuration
/usr/local/freeswitch/soundsSound files
/usr/local/freeswitch/recordingsCall recordings
/usr/local/freeswitch/logLogs

⁠Tags

TagDescription
latestLatest stable build
v1First stable release

⁠License

FreeSWITCH is licensed under the MPL 1.1⁠. mod_audio_fork is open-source (drachtio project).

Tag summary

Content type

Image

Digest

sha256:788a1ec1d…

Size

922.7 MB

Last updated

7 months ago

docker pull rajunify123/freeswitch-mod-audio-fork