A fully local, Celery-backed WhatsApp bot that detects AI-generated voice notes and audio clips using PyTorch, AASIST, and Wav2Vec2 models.
This guide explains how to spin up the entire infrastructure locally on your own computer.
- Python 3.10+
- FFmpeg (
sudo dnf install ffmpegorsudo apt install ffmpeg) - Ngrok Account (to expose your local bot to Meta)
- Upstash Account (for a free, serverless Redis queue)
- Meta Developer Account (to use the WhatsApp Business API)
Clone the repository, create a virtual environment, and install the dependencies:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtDownload the AASIST model weights (if you haven't already):
git clone https://github.com/clovaai/aasist /tmp/aasist
cp /tmp/aasist/models/weights/AASIST.pth ./weights/AASIST.pth
cp /tmp/aasist/models/AASIST.py ./models/AASIST.pyCopy the example environment file to .env:
cp .env.example .envOpen .env and fill in the following three critical values:
WA_TOKEN: Go to your Meta Developer Dashboard -> WhatsApp -> API Setup. Click Generate access token. (Note: This token expires every 24 hours. If your bot stops replying withHTTP 401 Unauthorized, you need to generate a new one and paste it here).PHONE_NUMBER_ID: Found on the same Meta API Setup page.REDIS_URL: Go to Upstash.com, create a free Redis database, copy the URL, and ensure it begins withrediss://.
Because this bot is built for heavy AI processing, it is split into a web server (FastAPI) and a background worker (Celery). You need three separate terminal windows open simultaneously.
This server catches incoming messages from Meta and instantly puts them into the Upstash Redis queue.
source .venv/bin/activate
uvicorn webhook.main:app --host 0.0.0.0 --port 8000 --env-file .envThis worker pulls messages out of Redis, downloads the audio, runs the PyTorch models, and sends the final verdict back to WhatsApp.
source .venv/bin/activate
celery -A processor.tasks worker --loglevel=infoThis exposes your local Port 8000 to the public internet securely so Meta can reach it.
ngrok http 8000Once your 3 terminals are running, look at Terminal 3 (Ngrok) and copy the Forwarding URL (it looks like https://random-words.ngrok-free.dev).
- Bypass Ngrok Warning: Open a web browser and paste your Ngrok URL. Click the blue "Visit Site" button. (If you skip this, Meta will fail to verify the webhook).
- Go to the Meta Developer Dashboard -> WhatsApp -> Configuration.
- Under the Webhook section, click Edit.
- Callback URL: Paste your Ngrok URL and append
/webhookto the end. (e.g.,https://random-words.ngrok-free.dev/webhook). - Verify Token: Type in the exact
VERIFY_TOKENyou set in your.envfile. - Click Verify and Save.
- Directly below that, in the "Webhook fields" section, click Manage and subscribe to
messages.
You are completely live! Message your Meta Test Phone Number via WhatsApp.
- You can record a Voice Note.
- You can attach a
.wavor.oggfile as a Document.
The bot will automatically download, convert, analyze, and reply with a trust score.