SpeechExpert-Wav2Vec2-Deepfake
synthetic speech detector
2 min readupdated
A compact model designed to detect signs of artificial or generated speech in audio recordings. It is built on a 4-layer wav2vec2 encoder, mean and standard deviation pooling, and a binary classification head trained on real and synthetic voices with augmentation. The model outputs a synthesis probability score for a given phrase in ONNX format. This tool is useful for security developers, audio content moderators, and researchers verifying the authenticity of voice messages.
Key features
- Analysis of short speech phrases ranging from 25 milliseconds to 30 seconds.
- Compact size: the model contains about 6.45 million parameters and weighs around 25.9 MB.
- Runs via ONNX Runtime without complex dependencies for fast inference integration.
- Ready-to-use audio preprocessing script with 16 kHz resampling and normalization.
What you can do
- Integrate the model into an audio message verification pipeline in messengers or Python bots.
- Use it in anti-fraud systems to detect fake voices and calls.
- Apply it as a component for comprehensive media content authenticity verification services.
Example
import json
from pathlib import Path
import numpy as np
import onnxruntime as ort
import soundfile as sf
from huggingface_hub import snapshot_download
model_dir = Path(snapshot_download("Strij911/SpeechExpert-Wav2Vec2-Deepfake", allow_patterns=["config.json", "model.onnx"]))
config = json.loads((model_dir / "config.json").read_text(encoding="utf-8"))
session = ort.InferenceSession(str(model_dir / config["model_file"]), providers=["CPUExecutionProvider"])
audio, rate = sf.read("phrase.wav", dtype="float32", always_2d=True)
audio = audio.mean(axis=1, dtype=np.float32)
waveform = np.ascontiguousarray(audio[None, :], dtype=np.float32)
scores = session.run([config["output_name"]], {config["input_name"]: waveform})[0][0]
print(dict(zip(config["labels"], map(float, scores), strict=True)))
Read more
Details• Validation metrics (5999 records): 97.56% ROC AUC, 7.70% EER, 91.63% accuracy.
• Requirements: mono audio, 16 kHz sample rate.
• Limitations: unknown generators, codecs, and noise may affect detection accuracy.
• Format: ONNX IR 8, opset 17, weights saved in a single model.onnx file.










Comments