Detect synthetic voices in real-time β before fraud happens.
VoiceGuard is a production-grade deepfake detection system that analyzes live call audio and identifies synthetic speech within the first 5β10 seconds of a call. It's designed to protect banking call centers from AI-powered voice cloning fraud.
Modern generative AI can clone a person's voice from only a few seconds of audio. Fraudsters use this to bypass voice biometric authentication or impersonate customers during phone calls. Traditional defenses (phone number verification, caller ID) are easily spoofed.
VoiceGuard provides audio-level deepfake detection using state-of-the-art pretrained anti-spoofing models:
- AASIST β Audio Anti-Spoofing using Integrated Spectro-Temporal Graph Attention Networks (primary detector)
- Wav2Vec2 β Fine-tuned deepfake audio classifier from HuggingFace (optional ensemble verifier)
Live Call Audio (SIP/RTP/WebSocket)
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β Audio Stream Buffer (ring buffer, 5-10s) β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β Preprocessor β
β ββ Resample to 16kHz β
β ββ Normalize [-1, 1] β
β ββ Voice Activity Detection β
β ββ Spectral-gating noise reduction β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ
β
βββββββββββ΄βββββββββββ
βΌ βΌ
ββββββββββββββββ ββββββββββββββββββββ
β AASIST Model β β Wav2Vec2 Model β
β (85K params) β β (optional) β
β Primary β β Ensemble β
ββββββββ¬ββββββββ ββββββββββ¬ββββββββββ
β β
ββββββββββ¬ββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β Ensemble Scorer β
β ββ Weighted average (0.7ΓAASIST + 0.3ΓW2V2) β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β Risk Classifier β
β ββ score < 0.3 β π’ LOW β ALLOW β
β ββ 0.3 β€ s < 0.7 β π‘ MEDIUM β FLAG_FOR_REVIEWβ
β ββ score β₯ 0.7 β π΄ HIGH β BLOCK_AND_ALERT β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ
β
βββββββββΌββββββββ
βΌ βΌ βΌ
REST WebSocket Webhook
API Alert Callback
cd deepfake
pip install -r requirements.txtpython scripts/download_weights.py
# Include Wav2Vec2 for ensemble mode:
python scripts/download_weights.py --include-wav2vec2uvicorn api.app:app --host 0.0.0.0 --port 8000curl -X POST http://localhost:8000/api/v1/analyze \
-F "file=@test_audio.wav" \
-F "call_id=TEST-001"Open http://localhost:8000/docs for interactive Swagger documentation.
# CPU mode
docker-compose up -d
# GPU mode (requires NVIDIA Container Toolkit)
docker-compose --profile gpu up -d
# Check health
curl http://localhost:8000/health| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Service information |
GET |
/health |
Health check |
GET |
/health/ready |
Readiness probe (K8s) |
GET |
/health/metrics |
Inference statistics |
POST |
/api/v1/analyze |
Analyze uploaded audio file |
Connect to ws://localhost:8000/api/v1/stream/{call_id} for real-time analysis.
Client β Server:
{"type": "audio_chunk", "data": "<base64 PCM>", "seq": 1}
{"type": "end_stream"}Server β Client:
{"type": "buffer_status", "buffered_seconds": 3.2, "target_seconds": 6.0, "is_ready": false}
{"type": "analysis_result", "data": {"deepfake_score": 0.87, "risk_level": "HIGH", ...}}{
"call_id": "CALL-2026-04-11-001",
"deepfake_score": 0.87,
"risk_level": "HIGH",
"recommended_action": "BLOCK_AND_ALERT",
"risk_description": "High probability of synthetic speech detected (score: 0.870)...",
"confidence": 0.92,
"inference_latency_ms": 34.5,
"models_used": ["aasist"],
"model_scores": {"aasist": 0.87},
"spectral_analysis": {
"spectral_centroid_hz": 1523.45,
"pitch_mean_hz": 142.3,
"pitch_stability": 0.0456,
"harmonic_ratio": 2.34
}
}Configuration via environment variables or .env file:
cp .env.example .env
# Edit .env with your settings| Variable | Default | Description |
|---|---|---|
MODEL_VARIANT |
aasist_l |
aasist (297K params) or aasist_l (85K params) |
ENABLE_ENSEMBLE |
false |
Enable Wav2Vec2 ensemble |
DEVICE |
auto |
auto, cuda, or cpu |
BUFFER_DURATION_SEC |
6.0 |
Audio buffer duration (seconds) |
RISK_THRESHOLD_LOW |
0.3 |
Below = LOW risk |
RISK_THRESHOLD_HIGH |
0.7 |
At/Above = HIGH risk |
WEBHOOK_URL |
Fraud alert webhook URL | |
API_KEY |
API authentication key |
Latency benchmarks (P95):
| Configuration | GPU (V100) | GPU (RTX 3060) | CPU (i7-12700) |
|---|---|---|---|
| AASIST-L only | ~25ms | ~40ms | ~160ms |
| AASIST full | ~50ms | ~80ms | ~300ms |
| AASIST-L + preprocessing | ~40ms | ~60ms | ~190ms |
| AASIST-L + Wav2Vec2 ensemble | ~120ms | ~180ms | ~500ms+ |
Run your own benchmark:
python scripts/benchmark.py --model aasist_l --device auto --iterations 100# Unit tests
pytest tests/ -v
# Specific test module
pytest tests/test_audio_buffer.py -v
pytest tests/test_inference.py -vdeepfake/
βββ config/ # Configuration
β βββ settings.py # Pydantic settings
β βββ aasist.json # AASIST model config
β βββ aasist_l.json # AASIST-L model config
βββ models/
β βββ aasist.py # AASIST architecture
β βββ weights/ # Pretrained weights (.pth)
βββ core/
β βββ audio_buffer.py # Streaming audio buffer
β βββ preprocessor.py # Audio preprocessing
β βββ feature_extractor.py # Spectral diagnostics
β βββ inference_engine.py # Model inference
β βββ ensemble.py # Multi-model scoring
β βββ risk_classifier.py # Risk level classification
βββ api/
β βββ app.py # FastAPI application
β βββ schemas.py # Pydantic models
β βββ middleware.py # Auth & logging
β βββ routes/
β βββ health.py # Health endpoints
β βββ analyze.py # File upload analysis
β βββ stream.py # WebSocket streaming
βββ services/
β βββ alert_service.py # Fraud alert dispatch
β βββ audit_logger.py # Compliance logging
βββ scripts/
β βββ download_weights.py # Download pretrained weights
β βββ benchmark.py # Latency benchmarking
βββ tests/ # Unit & integration tests
βββ Dockerfile # Production container
βββ docker-compose.yml # Orchestration
βββ requirements.txt # Dependencies
- Paper: Audio Anti-Spoofing using Integrated Spectro-Temporal Graph Attention Networks (ICASSP 2022)
- Repository: clovaai/aasist
- Trained on: ASVspoof 2019 LA dataset
- Performance: EER 0.83% (AASIST), EER 0.99% (AASIST-L)
- Model: Hemgg/Deepfake-audio-detection
- Base: facebook/wav2vec2-base
- Accuracy: 95.5% on evaluation set
MIT License. See LICENSE for details.
AASIST model code is Β© 2021-present NAVER Corp., used under MIT license.