Downloads · 30 days
1.7K
26% of all-time downloads
Vansh180/deepfake-audio-wav2vec2
deepfake-audio-wav2vec2 is a audio classification model from Vansh180. Use it for the audio classification task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as mit.
Downloads · 30 days
1.7K
26% of all-time downloads
All-time downloads
6.7K
Public
Parameters
94.6M
378 MB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors378 MB · 100%
From the Hugging Face model README
Deepfake-Audio-Wav2Vec2 is a fine-tuned audio classification model trained to detect real vs spoofed (deepfake) speech audio.
The model is built on top of facebook/wav2vec2-base, a self-supervised speech representation model, and adapted for binary deepfake audio detection.
It learns subtle acoustic artifacts and synthetic speech patterns that differentiate genuine human recordings from AI-generated or manipulated audio samples.
This model is intended for:
| Parameter | Value |
|---|---|
| Base Model | facebook/wav2vec2-base |
| Framework | Hugging Face Transformers |
| Training Hardware | GPU (CUDA) |
| Task Type | Audio Classification |
| Classes | bonafide / spoof |
| Audio Sample Rate | 16 kHz |
| Input Duration | Fixed audio segments |
| Optimization | AdamW |
| Loss Function | Cross Entropy |
| Metric | Score |
|---|---|
| Accuracy | 92.8% |
| Precision | 89.7% |
| Recall | 88.0% |
| F1 Score | 88.4% |
✅ The model demonstrates strong detection performance across real and spoofed samples.
The model was trained on a balanced subset of the ASVspoof 2021 PA dataset for binary anti-spoofing classification.
The dataset includes:
Training was performed on balanced class samples to improve robustness across both labels.
import torch
import torchaudio
import numpy as np
from transformers import AutoFeatureExtractor, AutoModelForAudioClassification
model_id = "Vansh180/deepfake-audio-wav2vec2"
feature_extractor = AutoFeatureExtractor.from_pretrained(model_id)
model = AutoModelForAudioClassification.from_pretrained(model_id)
model.eval()
def predict_audio(audio_path):
wav, sr = torchaudio.load(audio_path)
if wav.shape[0] > 1:
wav = wav.mean(dim=0, keepdim=True)
inputs = feature_extractor(
wav.squeeze().numpy(),
sampling_rate=16000,
return_tensors="pt"
)
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)
prediction = torch.argmax(probs, dim=1).item()
confidence = probs[0][prediction].item()
return {
"prediction": model.config.id2label[prediction],
"confidence": confidence
}
print(predict_audio("sample.wav"))