Summary
- Manipulation Recognition: Detects face swaps, compositing, and AI‑generated video/audio overlays.
- AI Model Detection: Identifies content associated with modern generative systems (e.g., Veo, Sana, Flux, voice cloning).
- Adaptive Sampling: Intelligently adjusts frame rate based on detection state—normal rate during clear states, burst rate when suspicious activity is detected.
- Realtime Alerts: Provides instant notification callbacks for ALERT and state transition events.
- Privacy by Design: No video or metadata is stored; frames are end‑to‑end encrypted in transit; results are ephemeral.
Installation
Prerequisites
- Python 3.10+ — Required for async/await features and type hints.
- Dataspike API Key — Set as an environment variable:
- Pipecat Cloud credentials (for cloud deployment):
Quick Start
The example below shows a ready-to-use Pipecat bot that integrates the Dataspike deepfake processor. It creates a pipeline that analyzes incoming video and audio streams in real-time.Basic Bot Setup
Create a.env file with your API key:
- Test video and audio in real-time with your webcam and microphone
- See the bot in action with live deepfake detection
- Monitor notifications and detection state transitions (CLEAR → SUSPICIOUS → ALERT)
- Experiment with configurations without deploying to production
- Start the bot:
uv run bot.py - Open http://localhost:7860 in your browser
- Grant camera/microphone permissions when prompted
- Click “Connect” to establish WebRTC connection
- Speak into your microphone and show your face to the camera
- Watch the console logs for real-time detection events
- Test different scenarios (different lighting, angles, voice tones)
Tip: Open your browser’s developer console to see detailed logs, WebSocket activity, and frame processing metrics.
Code Example
Default Alert Behavior
By default, the processor logs detection events to the console. When the system detects potential manipulation, it transitions through three states:- CLEAR — No manipulation detected (normal frame rate)
- SUSPICIOUS — Potential signs of manipulation (increased frame rate for verification)
- ALERT — High confidence manipulation detected (notification triggered)
Custom Notification Channels
Developers can override the default logging behavior to route alerts anywhere—for example, sending them to a webhook, Slack, a moderation API, database, or your own analytics pipeline. Provide a custom async callback (notification_cb) when creating the processor:
Flexible Integration: You have full control over how alerts are processed, logged, or relayed. Route detection events to monitoring systems, moderation queues, compliance logs, or real-time dashboards.
Configuration
Configure the processor via constructor parameters or environment variables.Video Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
burst_fps | float | 1.0 | Frame rate during SUSPICIOUS state (higher for verification) |
normal_fps | float | 0.2 | Frame rate during CLEAR state (lower to conserve resources) |
quality | int | 75 | JPEG compression quality (0–100, where 100 is highest) |
Audio Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
sample_rate | int | 16000 | Required sampling rate in Hz (must be 16000 for Dataspike API) |
sample_size | int | 48000 | Samples per chunk (48000 = 3 seconds at 16kHz) |
interval | int | 60 | Minimum seconds between audio sample transmissions |
Processor Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | env:DATASPIKE_API_KEY | Dataspike API key. Required unless set via environment. |
session | ClientSession | required | aiohttp ClientSession for WebSocket connections |
video_params | VideoParams | defaults | Video processing configuration |
audio_params | AudioParams | defaults | Audio processing configuration |
notification_cb | Callable | None | Optional async callback for detection events. Defaults to logging. |
How It Works
Development Flow (Local with Playground)
- Start Bot — Run
uv run bot.pyto launch the bot with the integrated Pipecat playground at http://localhost:7860 - Connect Browser — Open the playground in your browser and grant camera/microphone permissions
- WebRTC Handshake — The playground establishes a WebRTC connection to the bot
- Real-time Processing — Your video/audio streams through the pipeline for live deepfake analysis
- Instant Feedback — Detection results appear in console logs and trigger your notification callbacks
Production Flow (Architecture)
- WebRTC Connection — When a client connects via SmallWebRTC, the bot establishes a bidirectional media connection.
- Frame Capture — The processor intercepts
InputImageRawFrame(camera only) andInputAudioRawFramefrom the pipeline. - Adaptive Sampling — Video frames are sampled at
normal_fpsduring CLEAR state. When SUSPICIOUS events occur, sampling increases toburst_fpsfor rapid verification. - Audio Buffering — Audio is only processed when users are speaking (detected via VAD). Samples are accumulated into 3-second chunks and resampled to 16kHz PCM.
- Encoding & Queuing — Video frames are JPEG-encoded and queued (max 16 items). Stale frames are dropped to prevent blocking.
- Streaming — Frames stream via secure WebSocket to the Dataspike API. Detection results return in real-time.
- State Management — The processor maintains detection state (CLEAR/SUSPICIOUS/ALERT) and triggers notifications on state transitions.
- Auto-Reconnection — If the WebSocket drops, the processor reconnects with exponential backoff (1s → 10s max) and jitter.
Deployment
Pipecat Cloud
Deploy to Pipecat Cloud for production-grade scaling:- Update
pcc-deploy.toml:
- Build and push Docker image:
-
Create secret set in Pipecat Cloud dashboard with
DATASPIKE_API_KEY - Deploy:
Docker (Self-Hosted)
Privacy & Security
- No Storage — The processor and Dataspike API do not store video, audio, or metadata.
- E2E Encryption — All transmissions use TLS/WSS; only ephemeral detection signals are returned.
- Minimal Data — Only encoded frames and essential metadata (participant ID, track ID, timestamp) are transmitted.
- Key Management — Store
DATASPIKE_API_KEYin environment variables or secret managers. Never hard-code credentials. - Camera Only — The processor explicitly filters for camera feeds (
transport_source == "camera") and ignores screen sharing to minimize unnecessary data transmission.
Troubleshooting
WebSocket Connection Issues
Symptom: “Timeout waiting for WebRTC connection” errors Solutions:- Verify Pipecat Cloud configuration is correct
- Check that
session_managertimeout (120s) is sufficient - Ensure
DATASPIKE_API_KEYis set correctly - Review network connectivity to
wss://api.dataspike.io
Frame Rate / Performance Issues
Symptom: High CPU usage or detection lag Solutions:- Reduce
video_params.normal_fps(default: 0.2 fps) - Lower
video_params.qualityto reduce encoding overhead (default: 75) - Increase
audio_params.intervalto process audio less frequently (default: 60s) - Monitor queue size—frequent
QueueFullwarnings indicate overload
Audio Detection Not Working
Symptom: No audio analysis results Checklist:- User must be actively speaking (audio only processed during
UserStartedSpeakingFrame) - Audio buffer must reach
sample_size(48,000 samples = 3 seconds) - WebRTC connection must have active audio input track
- VAD (Voice Activity Detection) must be properly configured
Authentication Errors
Symptom: “DATASPIKE_API_KEY must be set” or 401 errors Solutions:- Verify environment variable is set:
echo $DATASPIKE_API_KEY - Check API key is valid at Dataspike Dashboard
- Ensure
.envfile is in the correct directory - For Docker: verify
-eflag or secret mount is correct
Local Playground Issues
Symptom: Can’t access http://localhost:7860 Solutions:- Ensure the bot is running (
uv run bot.pyorpython bot.py) - Check no other service is using port 7860
- Look for “Playground available at http://localhost:7860” in logs
- Try accessing from the same machine where the bot is running
- Grant browser permissions for camera and microphone access
- Ensure no other application is using your webcam/microphone
- Try a different browser (Chrome/Edge recommended for WebRTC)
- Check browser console for detailed error messages
Full Bot Example
Complete implementation showing all features:Reference Implementation
For a complete, production-ready implementation, see the official repository: 🔗 dataspike-io/pipecat-deepfake-bot The repository includes:- Complete bot implementation with comprehensive documentation
- Dockerfile and Pipecat Cloud deployment configuration
- Example custom notification handlers
- Environment configuration templates
- Integration tests and examples
API Reference
DataspikeDeepfakeProcessor
Constructor:async start()— Start WebSocket connection and processing loopasync stop()— Stop processor and close connections gracefullyset_participant_id(str)— Set participant identifier for trackingset_webrtc_connection(SmallWebRTCConnection)— Configure media track access
CLEAR→SUSPICIOUS— Potential manipulation detected, frame rate increasesSUSPICIOUS→ALERT— High confidence detection, notification triggeredALERT→CLEAR— Manipulation resolved, notification triggered
Support & Resources
- Dataspike API Documentation: docs.dataspike.io
- Dataspike Support: dataspike.io/contact-us
- Pipecat Framework: github.com/pipecat-ai/pipecat
- Pipecat Documentation: docs.pipecat.ai
- This Integration: github.com/dataspike-io/pipecat-deepfake-bot