Views
No views yet
| Task | Audio Deepfake Detection (Binary Classification) |
| Labels | bonafide (genuine), spoof (AI-generated / replayed) |
| Base model | Wav2Vec2-XLS-R-1B + Conformer |
| Quantization | Dynamic Int8 (MatMul/Gemm layers) |
| Size | ~1.3 GB (vs 4.3 GB FP32) |
| Input | Raw PCM waveform, 16 kHz, mono, float32 |
pip install onnxruntime librosa numpy1import onnxruntime as ort
2import librosa
3import numpy as np
4
5MAX_LEN = 64600 # ~4 seconds at 16 kHz
6
7def preprocess(audio_path: str) -> np.ndarray:
8 wav, _ = librosa.load(audio_path, sr=16000, mono=True)
9 # Tile-repeat if shorter, truncate if longer
10 if len(wav) < MAX_LEN:
11 wav = np.tile(wav, MAX_LEN // len(wav) + 1)
12 return wav[:MAX_LEN].astype(np.float32)[np.newaxis, :] # (1, T)
13
14def softmax(x):
15 e = np.exp(x - x.max(axis=-1, keepdims=True))
16 return e / e.sum(axis=-1, keepdims=True)
17
18sess = ort.InferenceSession("df_arena_1b_quantized.onnx")
19audio = preprocess("your_audio.mp3")
20
21logits = sess.run(None, {"input_values": audio})[0] # (1, 2)
22probs = softmax(logits)[0]
23
24label = "bonafide" if probs[1] > probs[0] else "spoof"
25print(f"{label} — bonafide: {probs[1]:.2%}, spoof: {probs[0]:.2%}")input_values(batch, samples) — dynamic batch and sequence lengthfloat32Padding: for clips shorter than 64,600 samples, tile-repeat the audio instead of zero-padding. This matches training behavior and preserves audio statistics.
logits(batch, 2) — [spoof_logit, bonafide_logit]softmax to get probabilities| Model | Size | Latency | vs PyTorch |
|---|---|---|---|
| PyTorch FP32 | 4.3 GB | ~9,000 ms | baseline |
| ONNX FP32 | 4.3 GB | ~1,400 ms | 6.4× faster |
| ONNX Int8 (this) | 1.3 GB | ~600 ms | 15× faster |
MatMul and Gemm operators (all Linear / Attention projection layers), which account for >95% of the model's weights. Convolution layers in the Wav2Vec2 feature encoder are kept in FP32 to preserve audio feature extraction quality.