Equal AI raised $30M to screen phone calls for Indians who get 20 spam calls a week
Back to Tutorials
techTutorialbeginner

Equal AI raised $30M to screen phone calls for Indians who get 20 spam calls a week

June 11, 20268 views5 min read

Learn how to build a basic AI-powered call screening system using Python and speech recognition technologies, similar to Equal AI's spam call filtering solution.

Introduction

In today's digital age, spam calls have become a major annoyance, especially in India where people receive an average of 20 spam calls per week. Equal AI, an Indian startup, has developed an AI-powered solution that can screen and handle phone calls automatically. In this beginner-friendly tutorial, we'll explore how to build a simple AI call screening system using Python and speech recognition technologies. This project will teach you the fundamentals of voice processing, AI integration, and automated call handling.

Prerequisites

Before starting this tutorial, you'll need:

  • A computer with Python installed (version 3.7 or higher)
  • Basic understanding of Python programming concepts
  • Internet connection for downloading packages
  • Audio input device (microphone) for testing
  • Optional: A Twilio account for actual phone call handling (free trial available)

Step-by-Step Instructions

Step 1: Setting Up Your Python Environment

Install Required Packages

First, we need to install the necessary Python packages for speech recognition and text processing. Open your terminal or command prompt and run:

pip install speechrecognition pyaudio pyttsx3

Why we do this: These packages provide the core functionality for recognizing speech, processing audio, and generating text-to-speech responses. SpeechRecognition handles the audio processing, PyAudio enables microphone input, and pyttsx3 allows text-to-speech output.

Step 2: Creating a Basic Voice Recognition System

Write the Core Recognition Code

Create a new Python file called call_screening.py and add the following code:

import speech_recognition as sr
import pyttsx3

# Initialize the speech recognizer
recognizer = sr.Recognizer()

# Initialize text-to-speech engine
engine = pyttsx3.init()

# Function to speak text
def speak(text):
    engine.say(text)
    engine.runAndWait()

# Function to listen for voice input
def listen():
    with sr.Microphone() as source:
        print("Listening...")
        recognizer.adjust_for_ambient_noise(source)
        audio = recognizer.listen(source)
        
    try:
        # Recognize speech using Google's speech recognition
        text = recognizer.recognize_google(audio)
        print(f"You said: {text}")
        return text
    except sr.UnknownValueError:
        print("Sorry, I could not understand what you said.")
        return None
    except sr.RequestError:
        print("Could not request results from Google Speech Recognition service.")
        return None

# Main function
if __name__ == "__main__":
    speak("Hello! I am your call screening assistant.")
    user_input = listen()
    if user_input:
        speak(f"You said: {user_input}")

Why we do this: This code sets up the basic framework for voice input and output. The listen() function captures audio from your microphone and converts it to text using Google's speech recognition service.

Step 3: Adding Call Screening Logic

Enhance with Spam Detection Logic

Now we'll add simple spam detection logic to our system. Modify your code as follows:

import speech_recognition as sr
import pyttsx3

# Initialize the speech recognizer
recognizer = sr.Recognizer()

# Initialize text-to-speech engine
engine = pyttsx3.init()

# Common spam keywords (simplified for demo)
spam_keywords = ["offer", "free", "win", "prize", "urgent", "congratulations", "limited time"]

# Function to speak text
def speak(text):
    engine.say(text)
    engine.runAndWait()

# Function to detect spam keywords in text
def is_spam(text):
    if not text:
        return False
    text_lower = text.lower()
    for keyword in spam_keywords:
        if keyword in text_lower:
            return True
    return False

# Function to listen for voice input
def listen():
    with sr.Microphone() as source:
        print("Listening...")
        recognizer.adjust_for_ambient_noise(source)
        audio = recognizer.listen(source)
        
    try:
        # Recognize speech using Google's speech recognition
        text = recognizer.recognize_google(audio)
        print(f"You said: {text}")
        return text
    except sr.UnknownValueError:
        print("Sorry, I could not understand what you said.")
        return None
    except sr.RequestError:
        print("Could not request results from Google Speech Recognition service.")
        return None

# Function to handle call screening
def handle_call_screening():
    speak("Please speak your message.")
    user_input = listen()
    
    if user_input:
        if is_spam(user_input):
            speak("This appears to be a spam call. I will not forward this message.")
            print("Spam detected - call screening activated.")
        else:
            speak("This seems to be a legitimate call. I will forward this message.")
            print("Legitimate call - forwarding message.")
    else:
        speak("I couldn't understand your message.")

# Main function
if __name__ == "__main__":
    speak("Hello! I am your call screening assistant.")
    handle_call_screening()

Why we do this: This enhancement adds logic to identify potential spam calls by checking for common spam keywords. This mimics the basic filtering that Equal AI's system would perform.

Step 4: Testing Your Call Screening System

Run and Test Your Program

Save your file and run it using:

python call_screening.py

When prompted, speak clearly into your microphone. Try saying phrases that contain spam keywords like "free offer" or "limited time" to test the spam detection. Speak normal phrases like "I need to discuss my account" to test legitimate call handling.

Why we do this: Testing helps you understand how your system responds to different inputs and ensures the basic functionality works before adding more complex features.

Step 5: Expanding Your System

Adding More Advanced Features

For a more advanced system, consider adding:

  • Integration with cloud APIs for better speech recognition
  • Database storage for call logs
  • Web interface for managing settings
  • Machine learning models for better spam detection

You could also connect this system to Twilio to handle actual phone calls:

# Example of connecting to Twilio (requires twilio package)
# pip install twilio

from twilio.rest import Client

def handle_twilio_call():
    # This would connect to Twilio's API
    # to receive and process actual phone calls
    pass

Why we do this: These enhancements would make your system more realistic and closer to what Equal AI has developed, allowing it to handle real phone calls and scale to production use.

Summary

In this tutorial, you've learned how to create a basic AI-powered call screening system using Python. You've built a system that can:

  • Listen to voice input from a microphone
  • Convert speech to text using Google's speech recognition
  • Detect potential spam calls based on keyword matching
  • Respond appropriately to different types of calls

This simple implementation demonstrates the core concepts behind Equal AI's technology. While this version is basic and meant for learning purposes, it provides a foundation for understanding how AI call screening systems work. In real-world applications, such systems would use more sophisticated machine learning models, cloud-based APIs, and integration with telecommunications networks to handle actual phone calls.

As you continue learning, consider exploring:

  • Advanced machine learning models for better spam detection
  • Integration with cloud services like AWS or Google Cloud
  • Building web interfaces for user management
  • Developing mobile apps for on-the-go call screening

Source: TNW Neural

Related Articles