Sign inSign up

rajunify123/freeswitch-voicebot

By rajunify123

β€’Updated 4 months ago

All-in-one FreeSWITCH AI VoiceBot with real-time VAD, Whisper STT, and smart semantic intent flows.

Image
Networking
Machine learning & AI
Developer tools
0

414

rajunify123/freeswitch-voicebot repository overview

β πŸ€– FreeSWITCH Automated AI VoiceBot

GitHub Repository Docker Pulls Platform

An automated, real-time IVR VoiceBot that handles inbound telephone calls via FreeSWITCH, transcribes caller speech, and navigates a dynamic JSON-defined conversation flow. Powered by Silero VAD, DeepFilterNet2 neural noise cancellation, and Whisper STTβ€”all in a single, ready-to-run container!


⁠🌟 Why This VoiceBot?

This image is a complete, production-ready solution that turns any standard SIP/VoIP telephone line into an interactive AI voice conversation. It is designed to handle high-fidelity audio streams, clean background noise in real-time, and route callers through conversational trees with high semantic accuracy.

β πŸš€ Key Technical Highlights
  • πŸ“¦ All-in-One Container: Includes FreeSWITCH, Redis, FastAPI WebSocket Server, and an ESL (Event Socket Library) orchestrator agent, all pre-configured and managed cleanly by supervisord.
  • ⚑ Sub-Second Latency: Uses Silero VAD for ultra-fast, local speech detection. No roundtrips to the cloud just to figure out if someone is talking!
  • 🧠 Deep Noise Cancellation: Integrates DeepFilterNet2 neural networks to filter out street noise, wind, and background static before sending audio for transcription.
  • πŸ—£οΈ Whisper STT Integration: Streams chunked audio and issues ultra-fast transcription queries directly to a high-speed Whisper backend.
  • 🎯 Smart Router (Fuzzy + Semantic): Custom JSON IVR Engine that matches user intent using hybrid matching:
    • Pass 1: Fast fuzzy matching for keyword shortcuts and standard synonym expansions (e.g., yes/no).
    • Pass 2: Semantic cosine-similarity matching (via sentence-transformers) to capture intent even when callers use different wording.
  • πŸ“ž Enterprise Ready: Supports concurrent channels (up to 5 in default settings) with dedicated per-call audio pipelines, sound buffers, and full state locking using Redis.

β πŸ—οΈ How It Works

πŸ“ž Caller β†’ FreeSWITCH (SIP) β†’ WebSocket Audio Stream β†’ AI Pipeline β†’ Voice Response

+-----------------------------------------------------------+
|                   FreeSWITCH Container                     |
|                                                            |
|   +--------------+          +------------------------+     |
|   |  mod_sofia   |--------->|    mod_audio_fork      |     |
|   |  (SIP Stack) |          |  (WebSocket Streamer)  |     |
|   +--------------+          +-----------+------------+     |
+----------------------------------------|------------------+
                                         |
                                         v  WebSocket: 16kHz Mono PCM
+-----------------------------------------------------------+
|                   Python VoiceBot Engine                    |
|                                                            |
|   +---------------------------------------------------+    |
|   |            Per-Call Audio Pipeline                 |    |
|   |                                                   |    |
|   |   1. Silero VAD        - Speech detection         |    |
|   |   2. DeepFilterNet2    - Neural noise cancellation|    |
|   |   3. Whisper STT       - Speech-to-Text          |    |
|   |   4. JSON IVR Engine   - Intent matching         |    |
|   +-------------------------+-------------------------+    |
|                             |                              |
|                             v                              |
|                  [Broadcast Response Audio]                 |
+-----------------------------------------------------------+

β πŸƒ Quick Start Guide

You can launch the complete stack using Docker Compose or as a Standalone Container.

  1. Clone the project files:

    git clone https://github.com/rajshahunify/freeswitch_voicebot.git
    cd freeswitch_voicebot
    
  2. Spin up the entire environment:

    docker compose up -d
    
⁠Option B: Running Standalone Container

Run the image directly with custom environment variables:

docker run -d \
  --name freeswitch-voicebot \
  -p 5060:5060/udp \
  -p 5080:5080/udp \
  -p 8021:8021 \
  -p 16384-16484:16384-16484/udp \
  -e VOICEBOT_EXTENSION=5000 \
  -e EXTERNAL_IP=127.0.0.1 \
  rajunify123/freeswitch-voicebot:latest
β πŸ“ž Making Your First Test Call
  1. Download and open any SIP softphone (e.g., Zoiper, MicroSIP, or Linphone).
  2. Configure a new account and point it to your Docker host IP (e.g., 127.0.0.1:5060).
  3. Log in with Username: 1000 and Password: 1234.
  4. Dial 5000 (or your custom VOICEBOT_EXTENSION).
  5. Start talking! The voice bot will answer immediately and engage in a real-time conversation.

⁠πŸ–₯️ Choose Your Deployment Mode

This project ships with three Docker Compose files optimized for different platforms and use cases:

Compose FilePlatformUse CaseCommand
docker-compose.ymlβœ… Windows, macOS, LinuxDefault / Production β€” Bridge networking, works everywheredocker compose up -d
docker-compose.dev.ymlβœ… Windows, macOS, LinuxDevelopment β€” Volume mounts for live code editing without rebuilddocker compose -f docker-compose.dev.yml up -d
docker-compose.host.yml⚠️ Linux onlyHigh-Performance β€” Host networking, zero NAT overheaddocker compose -f docker-compose.host.yml up -d
⁠πŸͺŸ Windows / 🍎 macOS Users

Use the default docker-compose.yml (bridge mode). Docker Desktop on Windows and macOS does not support host networking.

docker compose up -d

Tip: Set EXTERNAL_IP=127.0.0.1 when testing locally from the same machine.

⁠🐧 Linux Users

You have two options:

Standard (bridge mode) β€” same as Windows/macOS:

docker compose up -d

High-performance (host networking) β€” recommended for production servers with many concurrent calls:

docker compose -f docker-compose.host.yml up -d

Note: With host networking, set EXTERNAL_IP to your server's public or LAN IP address.

β πŸ”§ Development Mode (Any Platform)

For active development with live code reloading (source code is volume-mounted into the container):

docker compose -f docker-compose.dev.yml up -d

After editing Python code, restart the services without rebuilding:

docker exec freeswitch-voicebot supervisorctl restart voicebot-server voicebot-agent

After editing FreeSWITCH XML configs:

docker exec freeswitch-voicebot fs_cli -x "reloadxml"

β βš™οΈ Configuration Reference

Customize the behavior of the voicebot using these environment variables:

VariableDefaultDescription
VOICEBOT_EXTENSION5000The extension dialed on your softphone to trigger the bot.
EXTERNAL_IP127.0.0.1Public or host IP address for proper SDP negotiation.
WEBSOCKET_URLws://127.0.0.1:8000/mediaTarget websocket endpoint for streaming call audio.
STT_URLhttp://164.52.203.140:8890/transcribeTranscription endpoint of your Whisper instance.
NC_ENABLEDfalseSet to true to enable DeepFilterNet2 noise cancellation.
VAD_THRESHOLD0.3Sensitivity threshold for speech detection (lower = more sensitive).
MAX_CONCURRENT_CALLS5Maximum number of active voice calls allowed simultaneously.
LOG_LEVELINFOOutput verbosity level (DEBUG, INFO, WARNING, ERROR).

β πŸ› οΈ Deploying Custom Conversational Flows

To change how the voice bot answers, simply define your custom dialog steps in your JSON conversation file. You can mount your own custom configurations and audio soundboards into the container:

  • Flow Configuration: Mount your custom JSON flow file to /app/ivr/flow.json.
  • Audio Assets: Place your .wav prompts in the mounted FreeSWITCH sounds directory at /usr/local/freeswitch/sounds/custom/.

β πŸ”— Code & Support

Tag summary

Content type

Image

Digest

sha256:06f4d2f1e…

Size

5 GB

Last updated

4 months ago

docker pull rajunify123/freeswitch-voicebot