Ir para o conteúdo
ModelListadosExterno
Browse files

Wav2vec2

> Improved version available: caa-speech-detection-asvspoof2019/wav2vec2-v2-unfrozen — wav2vec2v2 (top-4 transformer blocks unfrozen) achieves 1.55% eval EER (vs 7.53% here) and 0.3966 tandem min t-DCF.

TipoOtherVersãoBestCnota

Fonte do modelo

Tipo
Other
Tamanho do arquivo
362 MB
Versão
vBest
Atualizado
25 de out. de 2026
Fonte
Hugging Face

Descrição da fonte

Improved version available: caa-speech-detection-asvspoof2019/wav2vec2-v2-unfrozen — wav2vec2_v2 (top-4 transformer blocks unfrozen) achieves 1.55% eval EER (vs 7.53% here) and 0.3966 tandem min t-DCF.

wav2vec2 — ASVspoof 2019 LA Binary Anti-Spoofing Detector

Binary bonafide-vs-spoof classifier built on facebook/wav2vec2-base with a frozen encoder and a lightweight classification head, trained on the ASVspoof 2019 Logical Access scenario.

Model Details

PropertyValue
Base modelfacebook/wav2vec2-base
EncoderFrozen during training
Classification headLinear(768→256) → GELU → Dropout(0.1) → Linear(256→2)
InputRaw waveform, 16 kHz, padded/truncated to 64 000 samples (4 s)
Parameters~95 M total (~300 k trainable head only)
Checkpoint size362 MB (best.pt)
Local version tagwav2vec2

The encoder masking used during wav2vec 2.0 self-supervised pretraining (mask_time_prob, mask_feature_prob) is disabled at load time, following Tak et al. (2022) who showed masking hurts countermeasure performance.

Training Data

ASVspoof 2019 Logical Access

SplitUtterancesAttacks
Train~25 000A01–A06 (known)
Dev~25 000A01–A06 (known)
Eval~71 000A07–A19 (unseen)
  • No data augmentation was applied (baseline experiment).
  • Class-weighted cross-entropy ([8.837, 1.0] for bonafide/spoof) compensates for the ~8.84:1 spoof-heavy imbalance in the training split.
  • Hyperparameters: seed=17245921, lr=1e-5, batch_size=8, 20 epochs, no early stopping.

Results

Baseline to beat: EER 8.09% (LFCC+GMM system from the ASVspoof 2019 paper).

SplitEERtandem min t-DCFIn-the-Wild EER
Dev (baseline → improved)4.199% → 0.197%——
Eval7.53%0.999427.68%
Eval (improved: wav2vec2_v2)1.55%0.396627.68%

Note on t-DCF: The eval t-DCF of ≈ 1 for this baseline indicates a calibration failure — the model's score distribution is not well aligned with the cost function's operating point despite achieving reasonable EER. t-DCF values use the normalized [0, 1] convention with tandem ASV scores.

For comparison, lcnn_v7_cqt achieves 3.26% eval EER with a t-DCF of 0.4930, making it the recommended model for applications that weight calibration alongside raw detection rate. The improved wav2vec2_v2 achieves the best eval EER (1.55%) and the best t-DCF (0.3966) across all models.

Usage

Download

huggingface-cli download caa-speech-detection-asvspoof2019/wav2vec2

Load

Clone the training repository and install dependencies, then:

import torch
from src.models.wav2vec2.model import Wav2Vec2Model

config = {
    "pretrained_model": "facebook/wav2vec2-base",
    "hidden_dim": 256,
    "dropout": 0.1,
    "freeze_encoder": True,
}

model = Wav2Vec2Model(config)
state = torch.load("best.pt", map_location="cpu")
model.load_state_dict(state)
model.eval()

Inference

from transformers import Wav2Vec2FeatureExtractor
from src.data.audio import load_audio, pad_or_trim
import torch

extractor = Wav2Vec2FeatureExtractor.from_pretrained("facebook/wav2vec2-base")
waveform = load_audio("audio.flac", target_sr=16000)
waveform = pad_or_trim(waveform, 64000)

inputs = extractor(waveform, sampling_rate=16000, return_tensors="pt")
frames = inputs.input_values.float()

with torch.no_grad():
    logits = model({"frames": frames})["logits"]
    pred = logits.argmax(dim=-1).item()
    # 0 = bonafide, 1 = spoof

Intended Use & Limitations

  • Intended use: detecting AI-generated / synthesised speech in the ASVspoof 2019 LA scenario as a countermeasure (CM) module.
  • Domain: Trained and evaluated on the LA (logical access) partition only. Not validated on physical access (PA) or in-the-wild recordings.
  • Unseen attacks: The eval set (A07–A19) contains attack types not seen during training. The 7.53% eval EER demonstrates reasonable generalisation, though the t-DCF ≈ 1 signals that score calibration is poor and the model should not be used directly as a calibrated likelihood ratio.
  • Deployment caveat: The 362 MB checkpoint size makes this unsuitable for edge or real-time deployment. For resource-constrained scenarios, lcnn_v4_cqt (3.5 MB, 3.03% eval EER) is recommended.

Citation

ASVspoof 2019 dataset and challenge:

@inproceedings{wang2020asvspoof,
  title     = {{ASVspoof} 2019: A Large-Scale Public Database of Synthesized,
               Converted and Replayed Speech},
  author    = {Wang, Xin and Yamagishi, Junichi and Todisco, Massimiliano and
               Delgado, H{\'e}ctor and Nautsch, Andreas and Evans, Nicholas and
               Shim, Md Sahidullah Hector and Kinnunen, Tomi and Lee, Kong Aik and
               Patino, Jose and others},
  booktitle = {Computer Speech \& Language},
  volume    = {64},
  year      = {2021},
}

wav2vec 2.0:

@inproceedings{baevski2020wav2vec,
  title     = {wav2vec 2.0: A Framework for Self-Supervised Learning of Speech Representations},
  author    = {Baevski, Alexei and Zhou, Henry and Mohamed, Abdelrahman and Auli, Michael},
  booktitle = {Advances in Neural Information Processing Systems (NeurIPS)},
  year      = {2020},
}

Fontes

1 fonte
Hugging FacePrimárioVersão a414eea4cf2a52bf6ba68377c57c8142ecbde25c
huggingface.co/caa-speech-detection-asvspoof2019/wav2vec2/tree/a414eea4cf2a52bf6ba68377c57c8142ecbde25c

Verificado 25 de out.

Download files

Artefatos de modelo

2 artefatos

best.pt

pt · 362 MB · SHA-256 4dd4d323a5f7…dfcc · Hugging Face

Download file

last.pt

pt · 362 MB · SHA-256 13785db561cf…8d3e · Hugging Face

Download file

Trechos de fonte

2 trechos

--- license: mit language: en library_name: pytorch tags: - audio-classification - anti-spoofing - asvspoof - speech - deepfake-detection datasets: - asvspoof2019 pipeline_tag: audio-classification metrics: - eer - t-dcf model-index: - name: wav2vec2 results: - task: type: audio-classification name: Anti-Spoofing / Deepfake Detection dataset: name: ASVspoof 2019 LA type: asvspoof2019 split: dev metrics: - type: eer value: 4.2 name: Dev EER (%) - type: t-dcf value: 0.5992 name: Dev min t-DCF - task: type: audio-classification name: Anti-Spoofing / Deepfake Detection dataset: name: ASVspoof 2019 LA type: asvspoof2019 split: eval metrics: - type: eer value: 7.53 name: Eval EER (%) - type: t-dcf value: 0.9994 name: Eval min t-DCF --- > **Improved version available:** [caa-speech-detection-asvspoof2019/wav2vec2-v2-unfrozen](https://huggingface.co/caa-speech-detection-asvspoof2019/wav2vec2-v2-unfrozen) — wav2vec2_v2 (top-4 transformer blocks unfrozen) achieves **1.55% eval EER** (vs 7.53% here) and **0.3966 tandem min t-DCF**. # wav2vec2 — ASVspoof 2019 LA Binary Anti-Spoofing Detector Binary bonafide-vs-spoof classifier built on `facebook/wav2vec2-base` with a frozen encoder and a lightweight classification head, trained on the ASVspoof 2019 Logical Access scenario. ## Model Details | Property | Value | |---|---| | Base model | `facebook/wav2vec2-base` | | Encoder | Frozen during training | | Classification head | Linear(768→256) → GELU → Dropout(0.1) → Linear(256→2) | | Input | Raw waveform, 16 kHz, padded/truncated to 64 000 samples (4 s) | | Parameters | ~95 M total (~300 k trainable head only) | | Checkpoint size | 362 MB (`best.pt`) | | Local version tag | `wav2vec2` | The encoder masking used during wav2vec 2.0 self-supervised pretraining (`mask_time_prob`, `mask_feature_prob`) is disabled at load time, following Tak et al. (2022) who showed masking hurts countermeasure performance. ## Training Data **ASVspoof 2019 Logical Access** | Split | Utterances | Attacks | |---|---|---| | Train | ~25 000 | A01–A06 (known) | | Dev | ~25 000 | A01–A06 (known) | | Eval | ~71 000 | A07–A19 (unseen) | - No data augmentation was applied (baseline experiment). - Class-weighted cross-entropy (`[8.837, 1.0]` for bonafide/spoof) compensates for the ~8.84:1 spoof-heavy imbalance in the training split. - Hyperparameters: seed=1...

Source context: 0 downloads · 0 likes · Pipeline audio-classification · Library pytorch · Repo caa-speech-detection-asvspoof2019/wav2vec2