A full-stack project for detecting whether an audio sample is likely generated by AI or captured from a real human voice. The solution combines a Hugging Face audio-classification model with preprocessing, real-time capture, API serving, and a browser-based demo interface.
This repository brings together multiple entry points:
- backend API for audio upload and streaming analysis
- desktop GUI for live monitoring
- browser UI for testing the detection flow
- model download and evaluation utilities
- preprocessing and inference code for voice authenticity scoring
The project is designed to classify audio clips as either:
- AI voice / synthetic voice
- Human voice / natural voice
The model is based on a Wav2Vec2 audio classifier fine-tuned for deepfake voice detection and is intended for research, experimentation, and demo use rather than as a production-grade security system.
The repository is organized into a few complementary modules:
core/— model loading and inference logicdetector/— preprocessing and evaluation helpersaudio/— live microphone capture utilitiesbackend/— FastAPI API and audio-processing pipelinefrontend/— React + Vite demo applicationGUI/— Tkinter desktop-based detection apptest_data/— example audio folders used for testing
.
├── README.md
├── convert_to_onnx.py
├── download_model.py
├── test_model.py
├── Test_predict.py
├── backend/
│ ├── checking_audio_file.py
│ ├── converting_audio_file.py
│ └── server.py
├── core/
│ └── main.py
├── detector/
│ ├── detector.py
│ ├── onnx_model.py
│ ├── preprocessing.py
│ └── README.md
├── audio/
│ ├── README.md
│ ├── capture.py
│ └── captured_chunks/
├── frontend/
│ ├── README.md
│ ├── package.json
│ ├── package-lock.json
│ ├── index.html
│ ├── vite.config.js
│ └── src/
├── GUI/
│ └── app.py
├── test_data/
│ ├── ai/
│ └── human/
└── models/
└── wav2vec2-deepfake-voice-detector/
- Audio is captured or uploaded as a waveform.
- The audio is resampled to 16 kHz and cleaned/preprocessed.
- The Wav2Vec2 model produces logits for AI vs human voice classes.
- The backend or app converts the result into a probability-based verdict.
- The frontend or GUI displays the outcome and optionally triggers alerts.
The project downloads the model from Hugging Face:
wav2vec2-deepfake-voice-detectorwav2vec2-large-xlsr-53
The core inference is implemented in core/main.py and uses a two-class classifier:
- label 1 = AI voice
- label 0 = human voice
The inference function returns (ai_probability, human_probability) based on softmaxed model outputs.
Responsible for loading the model with transformers and running prediction on input audio arrays. It ensures the model is loaded once and reused for subsequent inference calls.
Handles the audio cleaning pipeline:
- resampling to 16 kHz
- background-noise reduction
- silence trimming
- amplitude normalization
- conversion to float32 tensor-friendly format
Provides a FastAPI backend with:
- POST upload endpoint for audio file detection
- WebSocket stream for real-time microphone or call monitoring
- response payloads such as
AI_VoiceandHuman_Voice
A React app that simulates a call interface, supports file upload, and connects to the backend to analyze audio inputs.
A Tkinter app for desktop usage. It captures microphone input, evaluates chunks, and shows a status value while notifying the user when AI-like speech is detected.
Records incoming audio into fixed-duration chunks and saves each chunk as .wav. This is useful for capturing and validating detection behavior in controlled testing scenarios.
- Python 3.9+
- Node.js 18+ for the frontend
- A working microphone or input device for live testing
- A GPU is optional; CUDA is automatically used when available
Install the main Python packages for the model pipeline, preprocessing, and API server:
pip install requirements.txtpython download_model.pyThis downloads the pretrained detection model into ./models/wav2vec2-deepfake-voice-detector.
python convert_to_onnx.pyThis exports the model to ONNX format for deployment or optimization workflows.
cd backend
python server.pyThe API listens on:
http://localhost:8000
Available detection route:
POST /detect-audio-fileWS /ws/detect-real-audio
cd frontend
npm install
npm run devThen open the local Vite URL shown in the terminal.
python GUI/app.pyThe GUI listens for audio input from a configured device and displays confidence values while running. It also raises desktop notifications when AI-like voice probability crosses a configured threshold.
python test_model.pyThis script loads the model and evaluates audio files found under the test dataset structure.