Getting Started
Installation
Requires Python ≥ 3.12. Models are downloaded from Hugging Face Hub on first use and cached locally — no manual setup required.
Your first detection
Pass a file path directly. The default model is VIT with the ConstantQ visualisation on the VoxCelebSpoof dataset.
from Jabberjay import Jabberjay
jj = Jabberjay()
result = jj.detect("interview.wav")
print(result) # Bonafide ✔️ (94.1% confidence, model=VIT)
print(result.label) # "Bonafide" or "Spoof"
print(result.is_bonafide) # True / False
print(result.confidence) # 0.0 – 1.0
Choosing a model
Pass a model name as a string, or use the Model enum for IDE autocomplete.
from Jabberjay import Jabberjay
jj = Jabberjay()
# Self-contained models — no extra arguments needed
jj.detect("audio.wav", model="Classical")
jj.detect("audio.wav", model="RawNet2")
jj.detect("audio.wav", model="DFArena1B")
jj.detect("audio.wav", model="Spectra0")
jj.detect("audio.wav", model="SpectraAASIST")
jj.detect("audio.wav", model="SpectraAASIST3")
jj.detect("audio.wav", model="Wav2Vec2")
jj.detect("audio.wav", model="HuBERT")
jj.detect("audio.wav", model="WavLM")
# AST — uses a dataset (defaults to VoxCelebSpoof if not specified)
jj.detect("audio.wav", model="AST")
jj.detect("audio.wav", model="AST", dataset="VoxCelebSpoof")
# VIT — requires a dataset and a visualisation
jj.detect("audio.wav", model="VIT", dataset="VoxCelebSpoof", visualisation="ConstantQ")
Pre-loading audio
If you want to run multiple models against the same clip, load the audio once with jj.load() and reuse the result. This avoids redundant disk reads. load() keeps the file's own sample rate; each model resamples to the rate it needs.
You can also pass audio you loaded yourself as a (samples, sample_rate) tuple. Float or integer PCM (e.g. int16 from soundfile) and mono or multi-channel arrays are all accepted — detect() scales integers to [-1, 1], downmixes to mono, and rejects empty, NaN or wrongly-shaped input with a clear ValueError.
Each model is also cached in memory after its first detect() call, so calling the same model again later in the process (even with a different clip) reuses the already-loaded weights instead of reloading them. Running many different models adds up — DFArena1B alone needs ~5 GB — so call Jabberjay.clear_cache() once you're finished with a model.
from Jabberjay import Dataset, Jabberjay, Model, Visualisation
jj = Jabberjay()
# Load once …
audio = jj.load("interview.wav")
# … run as many models as you like
results = [
jj.detect(audio, model=Model.Classical),
jj.detect(audio, model=Model.RawNet2),
jj.detect(audio, model=Model.DFArena1B),
jj.detect(audio, model=Model.Spectra0),
jj.detect(audio, model=Model.SpectraAASIST),
jj.detect(audio, model=Model.SpectraAASIST3),
jj.detect(audio, model=Model.Wav2Vec2),
jj.detect(audio, model=Model.HuBERT),
jj.detect(audio, model=Model.WavLM),
jj.detect(audio, model=Model.AST, dataset=Dataset.VoxCelebSpoof),
jj.detect(audio, model=Model.VIT, dataset=Dataset.VoxCelebSpoof,
visualisation=Visualisation.ConstantQ),
]
print(f"{'Model':<15} {'Label':<10} {'Confidence':>10}")
print("-" * 41)
for r in results:
print(f"{r.model.value:<15} {r.label:<10} {r.confidence:>10.1%}")
Working with results
Every detect() call returns a DetectionResult with the same fields regardless of model.
result = jj.detect("audio.wav", model="WavLM")
# Branch on the verdict
if result.is_bonafide:
print(f"Genuine voice ({result.confidence:.1%} confidence)")
else:
print(f"Synthetic voice detected ({result.confidence:.1%} confidence)")
# Full score breakdown for both labels, highest first
for entry in result.scores:
bar = "█" * int(entry["score"] * 30)
print(f" {entry['label']:<10} {entry['score']:.3f} {bar}")
Enabling logging
Jabberjay is silent by default. Call enable_logging() to see model load and inference messages.
Discovering available options
jj.list_models() # returns all Model enum values
jj.list_datasets() # returns all Dataset enum values
jj.list_visualisations() # returns all Visualisation enum values
Hardware acceleration
Models run on the best available device automatically: CUDA if present, then
Apple Silicon (mps), otherwise CPU. No configuration is needed.
If a model hits an operation the MPS backend does not implement yet, set
PYTORCH_ENABLE_MPS_FALLBACK=1 in your environment to fall back to CPU for
those ops.