SAVRN
Search Contact SAVRN

Open-weight model · Audio classification

wav2vec2-deepfake-voice-detector

by Gary Stafford garystafford/wav2vec2-deepfake-voice-detector

Fine-tuned Wav2Vec2 model for detecting AI-generated speech. Determines if audio was spoken by a human or created by AI text-to-speech/voice cloning software. Fine-tuned Wav2Vec2 transformer for binary audio classification (real vs AI-generated speech).

Parameters316M
Context
Weights1.3 GB
Licenseapache-2.0
AccessOpen weights
Monthly Downloads12.2k

Runs On

What it takes to serve wav2vec2-deepfake-voice-detector (316M parameters): the memory its weights need at each precision, and the cheapest way to rent enough data-center GPUs to hold them.

PrecisionWeightsMemory neededCheapest setupPer hourAlso fits
16-bit 0.6 GB 0.8 GB 1x MI300X (192 GB)
Vultr
$1.85 1x H100 $1.99 · 1x MI325X $2.00
8-bit 0.3 GB 0.4 GB 1x MI300X (192 GB)
Vultr
$1.85 1x H100 $1.99 · 1x MI325X $2.00
4-bit 0.2 GB 0.2 GB 1x MI300X (192 GB)
Vultr
$1.85 1x H100 $1.99 · 1x MI325X $2.00

Memory is the weights at that precision plus 20% for the runtime and a short context; a long context needs more. Prices are the lowest on-demand hourly rates in the SAVRN Index, read Sep 18, 2026.

Model Card

By Gary Stafford, published under apache-2.0, revision c66306024a7e.

Fine-tuned Wav2Vec2 model for detecting AI-generated speech. Determines if audio was spoken by a human or created by AI text-to-speech/voice cloning software. Fine-tuned Wav2Vec2 transformer for binary audio classification (real vs AI-generated speech). Trained to distinguish authentic human speech from synthetic audio generated by AI text-to-speech and voice cloning services including: Note: This model uses transfer learning from a base model already trained for deepfake detection. Fast convergence is expected due to task similarity and TTS engine overlap with the base model's training data. The model outputs logits (raw, unnormalized scores) for two classes: Apply softmax to convert raw…

Read Gary Stafford's full model card

Deepfake Audio Detection Model

Fine-tuned Wav2Vec2 model for detecting AI-generated speech. Determines if audio was spoken by a human or created by AI text-to-speech/voice cloning software.

Model Details

Model Description

Fine-tuned Wav2Vec2 transformer for binary audio classification (real vs AI-generated speech). Trained to distinguish authentic human speech from synthetic audio generated by AI text-to-speech and voice cloning services including:

  • ElevenLabs
  • Amazon Polly
  • Hexgrad Kokoro
  • Hume AI
  • Speechify
  • Luvvoice

Developed by: Gary A. Stafford

Note: This model uses transfer learning from a base model already trained for deepfake detection. Fast convergence is expected due to task similarity and TTS engine overlap with the base model's training data.

How to Use

Installation

Install the required dependencies:

pip install transformers torch librosa

Optional: For GPU acceleration (recommended):

# For CUDA 11.8
pip install torch --index-url https://download.pytorch.org/whl/cu118

# For CUDA 12.1
pip install torch --index-url https://download.pytorch.org/whl/cu121

Quick Start

import torch
import librosa
from transformers import AutoModelForAudioClassification, AutoFeatureExtractor

# Load model and feature extractor
model_name = "garystafford/wav2vec2-deepfake-voice-detector"
model = AutoModelForAudioClassification.from_pretrained(model_name)
feature_extractor = AutoFeatureExtractor.from_pretrained(model_name)

# Move to GPU if available
device = "cuda" if torch.cuda.is_available() else "cpu"
model.to(device)
model.eval()

# Load and preprocess audio (automatically resamples to 16kHz)
audio, sr = librosa.load("path/to/audio.wav", sr=16000, mono=True)
inputs = feature_extractor(audio, sampling_rate=16000, return_tensors="pt", padding=True)
inputs = {k: v.to(device) for k, v in inputs.items()}

# Run inference
with torch.no_grad():
    outputs = model(**inputs)
    logits = outputs.logits
    probs = torch.nn.functional.softmax(logits, dim=-1)

# Get prediction
prob_real = probs[0][0].item()
prob_fake = probs[0][1].item()
prediction = "fake" if prob_fake > 0.5 else "real"

print(f"Prediction: {prediction}")
print(f"Confidence: {max(prob_real, prob_fake):.2%}")
print(f"Probabilities - Real: {prob_real:.2%}, Fake: {prob_fake:.2%}")

Expected Input

  • Audio format: WAV, MP3, FLAC, or any format supported by librosa
  • Sample rate: Automatically resampled to 16kHz
  • Channels: Converted to mono
  • Duration: Optimal performance on 2.5-13 second clips (model training range)

Output

The model outputs logits (raw, unnormalized scores) for two classes:

  • Class 0: Real (human) audio
  • Class 1: Fake (AI-generated) audio

Converting Logits to Probabilities:

Apply softmax to convert raw logits into interpretable probability scores:

probs = torch.nn.functional.softmax(logits, dim=-1)
  • Single sample: logits.shape = (1, 2)probs.shape = (1, 2) where probs[0] contains [prob_real, prob_fake] summing to 1.0
  • Batch processing: logits.shape = (N, 2)probs.shape = (N, 2) where each sample's probabilities sum to 1.0 independently
  • dim=-1: Applies softmax across classes for each sample, not across samples

Batch Processing Example

import glob

audio_files = glob.glob("audio_folder/*.wav")

for audio_path in audio_files:
    audio, _ = librosa.load(audio_path, sr=16000, mono=True)
    inputs = feature_extractor(audio, sampling_rate=16000, return_tensors="pt", padding=True)
    inputs = {k: v.to(device) for k, v in inputs.items()}

    with torch.no_grad():
        outputs = model(**inputs)
        probs = torch.nn.functional.softmax(outputs.logits, dim=-1)

    prediction = "fake" if probs[0][1] > 0.5 else "real"
    print(f"{audio_path}: {prediction} ({probs[0][1]:.2%} fake)")

Training Details

Dataset

Source: garystafford/deepfake-audio-detection

Composition:

  • Real audio: YouTube recordings from 14 source videos, human speech samples
  • Synthetic audio: Generated using 6 TTS platforms (ElevenLabs, Amazon Polly, Hexgrad Kokoro, Hume AI, Speechify, Luvvoice)
  • Format: FLAC, 16kHz mono, 2.5-13 second chunks
  • Total samples: 1,866 (balanced: 933 real, 933 fake)
  • Processing: Two-pass audio splitting with silence detection, concatenation of short segments, and VAD-based sub-chunking

Split:

Split Real Fake Total Percentage
Train 746 746 1,492 80%
Validation 93 94 187 10%
Test 94 93 187 10%

Stratified splitting applied to ensure balanced class distribution across all splits.

Training Approach

Base Model: Gustking/wav2vec2-large-xlsr-deepfake-audio-classification - A Wav2Vec2-XLSR model pre-trained on 53 languages and already fine-tuned for deepfake audio detection.

Method: Transfer learning with selective layer freezing:

  • Frozen:
  • Wav2Vec2 feature extractor (convolutional layers)
  • Bottom 12 transformer encoder layers
  • Trained:
  • Top 12 transformer encoder layers (upper half)
  • Classification head (256-dimensional projection + linear classifier)
  • ~160M trainable parameters (approximately half the model)
  • Rationale: Freezing low-level acoustic features while training high-level semantic layers allows the model to adapt to this dataset's specific TTS characteristics and speaker patterns while preserving general audio understanding.

Hyperparameters

Parameter Value
Learning rate 3e-5
Epochs (max) 5
Early stopping patience 3 evaluations
Evaluation frequency Every 30 steps
Per-device batch size 4
Gradient accumulation steps 4
Effective batch size 16
Optimizer AdamW
Warmup ratio 0.1 (10%)
Weight decay 0.01
Save strategy Every 30 steps
Metric for best model ROC-AUC
Precision FP16

Training Statistics:

  • Training samples: 1,492 (746 real, 746 fake)
  • Validation samples: 187 (93 real, 94 fake)
  • Trainable parameters: 160,336,770 (~160M parameters, approximately 50% of full model)
  • Training approach: Freeze feature extractor and bottom 12 transformer layers; train top 12 transformer layers + classification head
  • Convergence: Efficient convergence (typically ~3-4 epochs) due to base model's existing deepfake detection capabilities
  • Why high performance? Transfer learning from a specialist deepfake detector allows rapid adaptation to this dataset while training substantial portions of the model to capture dataset-specific patterns

Architecture

The model uses AutoModelForAudioClassification with a two-class output (0=real, 1=fake):

  • Feature Extractor (Frozen): 7 convolutional layers extract acoustic features from raw audio
  • Transformer Encoder:
  • Layers 0-11 (Frozen): Preserve low-level acoustic and phonetic representations
  • Layers 12-23 (Trained): Adapt high-level semantic features to deepfake patterns
  • Classification Head (Trained): 256-dimensional projection + linear classifier

This architecture balances efficiency with adaptability—frozen layers preserve general audio understanding while trained layers (~160M parameters) learn dataset-specific deepfake detection patterns.

Model Performance

IMPORTANT CONTEXT: These high-performance metrics reflect fine-tuning a specialist model on its own domain. The base model (Gustking/wav2vec2-large-xlsr-deepfake-audio-classification) was already trained for deepfake detection, likely on similar TTS engines. These results demonstrate successful adaptation to this specific dataset of 1,866 samples, NOT general deepfake detection capability from scratch. The excellent ROC-AUC (0.998) indicates near-perfect class separation, though 4 samples (2.1%) are still misclassified at the default 0.5 threshold.

Validation Set Performance

The model performs well on the validation set of 187 audio clips (94 real, 93 fake):

Validation Results (at threshold 0.5):

  • Accuracy: 97.9% (183 out of 187 samples correctly classified)
  • ROC-AUC: 0.998 (near-perfect class separation)
  • Balanced Accuracy: 97.9%

Per-Class Metrics (threshold 0.5):

Class Precision Recall F1-Score Support
Real 1.00 0.96 0.98 94
Fake 0.96 1.00 0.98 93

Confusion Matrix (threshold 0.5):

Pred Real Pred Fake
True Real 90 4
True Fake 0 93

Note: Best balanced accuracy of 98.4% achieved at threshold 0.9 (96.8% real recall, 100% fake recall).

Important Notes on Performance

Context for High Performance:

  1. Moderate validation set: 187 samples provides reasonable evaluation, though larger test sets recommended for production validation
  2. Transfer learning: Base model already trained for deepfake detection on similar TTS engines - fine-tuning adapts existing knowledge
  3. Dataset characteristics: TTS-generated audio has distinctive artifacts (prosody patterns, spectral signatures) that differentiate it from human speech
  4. ROC-AUC of 0.998: Indicates near-perfect ranking/separation of classes; 4 real samples misclassified as fake at threshold 0.5, while all fake samples correctly identified
  5. Recommended validation: Test on TTS engines NOT in training data (e.g., OpenAI TTS, Azure Neural, advanced voice cloning systems) for true generalization assessment

Generalization Limitations:

  • Model may not generalize well to:
  • Novel TTS engines not represented in training data
  • Advanced voice cloning/conversion systems
  • Real-time voice manipulation
  • Low-quality recordings with significant noise

Inference Performance

Estimated based on model architecture:

  • Latency: ~50-100ms per sample (varies by hardware)
  • Recommended use: Batch processing for efficiency

Configuration

Architecture
Wav2Vec2ForSequenceClassification
Layers
24
Hidden size
1,024
Feed-forward size
4,096
Attention heads
16
Vocabulary size
32
Model type
wav2vec2

Identity and Version

Repository
garystafford/wav2vec2-deepfake-voice-detector
Publisher
Gary Stafford
Task
Audio classification
Modality
Audio
Library
transformers
Parameters
316M parameters
Languages
en
Revision
c66306024a7ede0be291e9c4558b37634782dc4e
First published
2025-12-24
Last updated
2025-12-28

Files and Weights

5 files, 1.3 GB in total. The weights are 1 file totalling 1.3 GB in safetensors.

Weights1 file · 1.3 GB
Configuration2 files · 2.5 KB
Documentation1 file · 11.2 KB
Repository1 file · 1.5 KB
Every file
FileTypeSizeSHA-256
model.safetensorsWeights1.3 GB 905e330265c4
config.jsonConfiguration2.3 KB
preprocessor_config.jsonConfiguration221 B
README.mdDocumentation11.2 KB
.gitattributesRepository1.5 KB

License and Download

License
apache-2.0
Access
Open weights, no gate
Download size
1.3 GB
Download from Gary Stafford

Released by Gary Stafford through its official repository on Hugging Face. Read the license.

Built From

Memory Requirements

PrecisionWeights in memory
As published1.3 GB
16-bit0.6 GB
8-bit0.3 GB
4-bit0.2 GB

Weights only, from the published parameter count; the key-value cache and runtime add to this.

Questions About wav2vec2-deepfake-voice-detector

How much GPU memory does wav2vec2-deepfake-voice-detector need?

About 0.8 GB at 16-bit and 0.2 GB at 4-bit: the weights (316M parameters) plus a working margin. A long context needs more.

What is the cheapest GPU to run wav2vec2-deepfake-voice-detector on?

At 16-bit, 1x MI300X from $1.85 an hour; at 4-bit, 1x MI300X from $1.85 an hour, at the lowest on-demand prices the SAVRN Index lists.

Can I use wav2vec2-deepfake-voice-detector commercially?

Yes. wav2vec2-deepfake-voice-detector is released under Apache License 2.0. The Apache License 2.0 is a permissive open-source license. It permits commercial use, modification and redistribution. It requires keeping the license and copyright notices and any NOTICE file, stating significant changes, and it includes an express patent grant from contributors.

Similar Models

This model is a fine-tuned version of facebook/wav2vec2-xls-r-300m on Librispeech-clean-100 for gender recognition. It achieves the following results on the evaluation set: The Librispeech-clean-100 dataset was used to train the model, with 70% of the data used for training, 10% for validation, and 20% for testing. The following hyperparameters were used during training: - learningrate: 3e-05 - trainbatchsize: 4 - evalbatchsize: 4 - gradientaccumulationsteps: 4 - totaltrainbatchsize: 16 - lrschedulertype: linear - lrschedulerwarmupratio: 0.1 - numepochs: 1 - mixedprecisiontraining: Native AMP - Transformers 4.28.0 - Pytorch 2.0.0+cu118 - Tokenizers 0.13.3

Open weights apache-2.0 316M parameters transformers

Model · Audio classification

wav2vec-vm-finetune

Jake Downie

This model is a fine-tuned version of facebook/wav2vec2-xls-r-300m for voicemail detection. It is trained on a dataset of call recordings to distinguish between voicemail greetings and live human responses. This model builds on wav2vec2-xls-r-300m, a self-supervised speech model trained on large-scale multilingual data. We fine-tuned it on the first two seconds of a call. - Automated voicemail detection in AI-powered call assistants. - Filtering voicemail responses in customer service and sales call automation. - Only trianed on the English language. - Assumes the voicemail track is isolated and contains no audio from the caller. - Designed for the first two seconds of audio when calling a…

Open weights apache-2.0 316M parameters transformers

The pre-trained model is this one - facebook/hubert-large-ls960-ft The DUSHA dataset used can be found here Fine-tuned in Google Colab using Pro account with A100 GPU Freezed all layers exept projector, classifier and all 24 HubertEncoderLayerStableLayerNorm layers Used half of the train dataset - 2 epochs - train batch size = 8 - eval batch size = 8 - gradient accumulation steps = 4 - learning rate = 5e-5 without warm up and decay Achieved - accuracy = 0.86 - balanced = 0.76 - macro f1 score = 0.81 on test set, improving accucary and f1 score compared to dataset baseline

Open weights apache-2.0 316M parameters transformers

Speech emotion recognition for Russian over seven classes: anger, disgust, enthusiasm, fear, happiness, neutral, sadness. Fine-tuned from jonatasgrosman/wav2vec2-large-xlsr-53-russian on Aniemore/resd. Audio resampled to 16 kHz mono, clips capped at 12 s, normalized per utterance, padding masked. UA is macro-averaged recall, WA is accuracy, F1 is macro-averaged. All three test sets went through the same harness, so the rows are comparable to each other. The RESD split matches fold 1 of EmoBox bit for bit. The top entry there is WavLM-large at WA 56.47 / UA 55.87 / F1 55.82. These numbers are higher, but the training protocol differs — EmoBox freezes the encoder and trains a probe, this is a…

Open weights mit 316M parameters transformers

The model is a fine-tuned version of jonatasgrosman/wav2vec2-large-xlsr-53-english for a Speech Emotion Recognition (SER) task. The dataset used to fine-tune the original pre-trained model is the RAVDESS dataset. This dataset provides 1440 samples of recordings from actors performing on 8 different emotions in English, which are: It achieves the following results on the evaluation set: The following hyperparameters were used during training: - learningrate: 0.0001 - trainbatchsize: 4 - evalbatchsize: 4 - gradientaccumulationsteps: 2 - totaltrainbatchsize: 8 - lrschedulertype: linear - numepochs: 3 - mixedprecisiontraining: Native AMP Any doubt, contact me on Twitter. - Transformers 4.8.2…

Open weights apache-2.0 316M parameters transformers