w2v-BERT 2.0 + MHFA spoofed-speech detector: inference package
One neural network that scores a speech recording as bona fide or spoof: a w2v-BERT 2.0 encoder, an MHFA back-end (multi-head factorised attentive pooling) and a 2-class head. For every input wav file the code writes one score, P(spoof); a file is called spoof if its score is >= 0.5. No performance claims are made in this repository.
Files
| File | Content |
|---|---|
README.md, docs/RECIPE.md |
This card, and the full specification: forward pass, exact recipe, numerics, reproduction, installation. |
model.pt |
The checkpoint, 2.3 GB (2,327,583,187 bytes): a plain PyTorch state_dict with 790 tensors, fp32, holding every weight. |
config.yaml |
Inference configuration. The code reads the checkpoint name, the model sizes, the encoder configuration directory and the four lengths of the recipe; the other keys (names, label order, threshold) describe the model and are not read. |
infer.py |
The command line and the recipe: wav files in, score file out. |
rtcsdd_infer/ |
__init__.py (package marker), model.py (model definition and loading), echo.py (echo detector and echo removal). |
w2v_bert_2.0/ |
config.json and preprocessor_config.json: encoder and feature-extractor configuration of facebook/w2v-bert-2.0 (unmodified copies); its weight file is not needed. |
SHA256SUMS |
Checksums of model.pt and the two files in w2v_bert_2.0/. |
requirements.txt |
The library versions the model was checked with. |
THIRD_PARTY_NOTICES.md, LICENSES/Apache-2.0.txt |
Origin and licence of the code and files taken from elsewhere; the text of the Apache License 2.0, which applies to rtcsdd_infer/model.py and does not set the licence of this repository. |
.gitattributes, .gitignore |
Git LFS rules; keeps Python bytecode caches out of the repository. |
Install and run
pip install huggingface-hub==0.35.0
huggingface-cli download JYP2024/rtc-sdd-single-w2vbert-mhfa --local-dir rtc-sdd-single-w2vbert-mhfa
cd rtc-sdd-single-w2vbert-mhfa
pip install -r requirements.txt # Python 3.9 or 3.10
python infer.py INPUT OUT [--device DEVICE] # default device: a GPU if torch finds one, else the CPU
- Input:
INPUTis a directory (its*.wavfiles, sorted by name) or a text file with one wav path per line. The files must be 16 kHz, mono, 16-bit PCM wav. Only rate and channel count are checked: a floating-point wav file is read as silence and gets a meaningless score without a message (see docs/RECIPE.md). - Output:
OUTgets one line per file, in input order:<file name> <score>, with P(spoof) to 10 decimals.
Inference recipe
- Echo step: a file in which a signal-based detector finds a single echo at one of four delays is de-echoed first.
- Files of 4.0 to 12.0 s: the score is P(spoof) of the whole file, one forward pass.
- Files shorter than 4.0 s: mean of two views: the whole file, and the file tiled (repeated end to end) to 4.0 s.
- Files longer than 12.0 s: mean over 4.0 s windows (hop 1.0 s, the last one flush with the end of the file).
An earlier version of this code with the same numeric path reproduced 24,224 stored reference scores of this model within 1e-05 (same decisions); the reference scores are not part of this repository. Details and the exact definition of every step: docs/RECIPE.md.
Licence and third-party notices
The licence of the checkpoint and of the code written for this repository has not been set yet. rtcsdd_infer/model.py
contains excerpts of Apache-2.0 code and carries that licence header; the licence text is in LICENSES/Apache-2.0.txt.
See THIRD_PARTY_NOTICES.md: the code excerpts taken from the WeDefense toolkit
(Apache-2.0), the two configuration files of facebook/w2v-bert-2.0
and the libraries used at run time. The reference for the MHFA back-end is given in rtcsdd_infer/model.py.
- Downloads last month
- 6