Skip to content

API Reference

Jabberjay

Jabberjay.jabberjay.Jabberjay

Unified entry point for every synthetic voice detection model.

Construct once and call detect() with an audio file path or a pre-loaded (samples, sample_rate) tuple. Model weights are downloaded from Hugging Face Hub on first use and cached in memory for the lifetime of the process, so repeated calls for the same model skip both the download and the reload. Call clear_cache() to release them.

Example::

jj = Jabberjay()
result = jj.detect("audio.wav")            # default VIT model
result = jj.detect("audio.wav", model="HuBERT")

clear_cache() staticmethod

Release every loaded model and return its memory.

Models stay loaded after their first detect() call so later calls are fast. Running many different models in one process adds up — several GB each for DFArena1B and the Spectra family — so call this once you're done with a model (or between models in a sweep) to free RAM and GPU memory. The next detect() reloads from the local Hugging Face cache without re-downloading.

detect(audio, model=Model.VIT, visualisation=Visualisation.ConstantQ, dataset=Dataset.VoxCelebSpoof)

Detect whether audio is bonafide or spoofed.

Parameters:

Name Type Description Default
audio str | PathLike | Audio

Path to an audio file, or a pre-loaded (samples, sample_rate) tuple at any sample rate. Samples may be float or integer PCM, mono or multi-channel (downmixed to mono).

required
model Model | str

Model to use — a Model member or its name, case-insensitive (e.g. "VIT" or "vit").

VIT
visualisation Visualisation | str | None

Spectrogram type for VIT. Member or name.

ConstantQ
dataset Dataset | str | None

Training dataset for VIT and AST. Member or name.

VoxCelebSpoof

Returns:

Type Description
DetectionResult

DetectionResult with the label, its confidence, and the scores

DetectionResult

for both classes.

Raises:

Type Description
FileNotFoundError

If audio is a path that doesn't exist.

ValueError

If the audio is empty, non-finite, wrongly shaped or unreadable, a required argument is None, or a name is unrecognised (InvalidChoiceError, also a KeyError).

Note

VIT requires both visualisation and dataset; both default to ConstantQ and VoxCelebSpoof respectively so a bare jj.detect("audio.flac") works out of the box. AST requires dataset; defaults to VoxCelebSpoof. All other models (Classical, DFArena1B, RawNet2, Spectra0, SpectraAASIST, SpectraAASIST3, HuBERT, Wav2Vec2, WavLM) ignore both.

enable_logging(level='DEBUG') classmethod

Enable Jabberjay's built-in logging output to stderr.

Safe to call multiple times — the handler is only registered once. Subsequent calls with a different level are silently ignored.

Parameters:

Name Type Description Default
level str

Minimum log level to emit. One of "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL". Defaults to "DEBUG".

'DEBUG'

Example::

Jabberjay.enable_logging()          # all messages
Jabberjay.enable_logging("INFO")    # skip debug messages

list_datasets() staticmethod

Return all available datasets.

list_models() staticmethod

Return all available models.

list_visualisations() staticmethod

Return all available visualisations.

load(path) staticmethod

Load an audio file as mono at its native rate: (samples, sample_rate).

No resampling happens here; each model resamples to the rate it was trained at, so audio is only ever resampled once.


DetectionResult

Jabberjay.jabberjay.DetectionResult(label, is_bonafide, confidence, model, scores=list()) dataclass

Structured result returned by every call to Jabberjay.detect().

confidence instance-attribute

Confidence score for the top prediction (0.0-1.0).

is_bonafide instance-attribute

True if the audio was classified as genuine.

label instance-attribute

'Bonafide' or 'Spoof'.

model instance-attribute

The model used to produce this result.

scores = field(default_factory=list) class-attribute instance-attribute

Full label/score breakdown for both classes, sorted highest-first.


Enums

Model

Jabberjay.Utilities.enum_handler.Model

Bases: Enum

Dataset

Jabberjay.Utilities.enum_handler.Dataset

Bases: Enum

Visualisation

Jabberjay.Utilities.enum_handler.Visualisation

Bases: Enum