Presentation Attack Detection in Voice Biometrics

This package is an extension of the bob.pad.base presentation attack detection (PAD) framework package for voice biometrics.

Tools implemented in bob.pad.voice

Extractors

class bob.pad.voice.extractor.AudioTFExtractor(feature_layer='fc1', **kwargs)

Bases: bob.bio.base.extractor.Extractor

Parameters:

feature_layer: The layer to be used as features. Possible values are fc1 or ‘fc2’.

load(extractor_file)[source]
train(*args, **kwargs)[source]
class bob.pad.voice.extractor.DummyTF(**kwargs)

Bases: bob.bio.spear.preprocessor.Base, bob.bio.base.extractor.Extractor

This class can be used as a simple preprocessor (reads data only) and a dummy extractor (reads saved data)

class bob.pad.voice.extractor.GLCMs(features_processor, n_glcms=1, offset_vector=[[0, 1], [1, 0]], properties=True, **kwargs)

Bases: bob.pad.voice.extractor.Ratios

Extractor that computes histograms of LBP features from a textogram, which, in turn, is computed by a cepstral or spectral extractor passed as an argument.

compute_glcms(data)[source]
get_features(input_data, annotations)[source]
class bob.pad.voice.extractor.LBPHistograms(features_processor, n_lbp_histograms=2, lbp_neighbors=16, lbp_to_average=False, lbp_uniform=False, lbp_radius=1, lbp_circular=True, lbp_elbp_type='regular', histograms_for_rows=False, band_ratios=True, **kwargs)

Bases: bob.pad.voice.extractor.LBPs

Extractor that computes histograms of LBP features from a textogram, which, in turn, is computed by a cepstral or spectral extractor passed as an argument.

compute_histograms(lbp_wrapper, lbpimages)[source]
class bob.pad.voice.extractor.LBPs(features_processor, n_lbps=2, lbp_neighbors=16, lbp_to_average=False, lbp_uniform=False, lbp_radius=1, lbp_circular=True, lbp_elbp_type='regular', band_ratios=True, **kwargs)

Bases: bob.pad.voice.extractor.Ratios

Extractor that computes histograms of LBP features from a textogram, which, in turn, is computed by a cepstral or spectral extractor passed as an argument.

compute_lbps(data)[source]
get_features(input_data, annotations)[source]
class bob.pad.voice.extractor.Ratios(features_processor, n_bands=5, **kwargs)

Bases: bob.bio.base.extractor.Extractor

compute_ratios(data)[source]
class bob.pad.voice.extractor.SpectrogramExtended(win_length_ms=20.0, win_shift_ms=10.0, n_filters=40, f_min=0.0, f_max=4000, pre_emphasis_coef=1.0, mel_scale=True, rect_filter=False, inverse_filter=False, normalize_spectrum=False, log_filter=True, energy_filter=False, energy_bands=True, vad_filter='trim_silence', normalize_feature_vector=False, **kwargs)

Bases: bob.bio.base.extractor.Extractor

Extract energy bands from spectrogram and VAD labels based on the modulation of the energy around 4 Hz

compute_spectrogram(rate, data)[source]
normalize_features(features)[source]
class bob.pad.voice.extractor.VectorsRatios(features_processor, n_bands=5, feature_vector_length=50, vectors_overlap=5, **kwargs)

Bases: bob.pad.voice.extractor.Ratios

compute_ratios(data)[source]

Algorithms

class bob.pad.voice.algorithm.GMM(normalize_features=False, number_of_gaussians=512, kmeans_training_iterations=25, gmm_training_iterations=10, training_threshold=0.0005, variance_threshold=0.0005, update_weights=True, update_means=True, update_variances=True, responsibility_threshold=0, INIT_SEED=2015, requires_projector_training=False, **kwargs)

Bases: bob.pad.base.algorithm.Algorithm

Trains Logistical Regression classifier and projects testing dat on it.

load_projector(projector_file)[source]
project(feature) → projected[source]

Projects the given feature into GMM space.

Parameters:

feature : 1D numpy.ndarray
The 1D feature to be projected.

Returns:

projected : 1D numpy.ndarray
The feature projected into GMM space.
project_feature(feature)[source]
read_gmm_stats(gmm_stats_file)[source]

Reads GMM stats from file.

save_gmms(projector_file)[source]

Save projector to file

score(toscore)[source]

Returns the difference between log likelihoods of being real or attack

score_for_multiple_projections(toscore)[source]

Returns the difference between log likelihoods of being real or attack

train_gmm(array)[source]
train_projector(training_features, projector_file)[source]
class bob.pad.voice.algorithm.LogRegr(use_PCA_training=False, normalize_features=False, **kwargs)

Bases: bob.pad.base.algorithm.Algorithm

Trains Logistical Regression classifier and projects testing dat on it.

enroll(enroll_features)[source]

We do no enrollment here

load_projector(projector_file)[source]
project(feature) → projected[source]

Projects the given feature into Fisher space.

Parameters:

feature : 1D numpy.ndarray
The 1D feature to be projected.

Returns:

projected : 1D numpy.ndarray
The feature projected into Fisher space.
project_feature(feature)[source]
score(toscore)[source]

Returns the output of a classifier

score_for_multiple_projections(toscore)[source]
train_projector(training_features, projector_file)[source]
class bob.pad.voice.algorithm.TensorflowEval(architecture_name='mlp', input_shape=[200, 81], network_size=60, normalization_file=None, **kwargs)

Bases: bob.pad.base.algorithm.Algorithm

This class is for evaluating data stored in tensorflow tfrecord format using a pre-trained LSTM model.

load_projector(projector_file)[source]
normalize_data(features)[source]
project(feature) → projected[source]

This function will project the given feature. It is assured that the load_projector() was called once before the project function is executed.

Parameters:

feature : object
The feature to be projected.

Returns:

projected : object
The projected features. Must be writable with the write_feature() function and readable with the read_feature() function.
project_feature(feature)[source]
restore_trained_model(projector_file)[source]
score(toscore)[source]

Returns the evarage value of the probe

score_for_multiple_projections(toscore)[source]

scorescore_for_multiple_projections(toscore) -> score

Returns:

score : float
A score value for the object toscore.

Databases

class bob.pad.voice.database.ASVspoof2017PadDatabase(protocol='competition', **kwargs)

Bases: bob.pad.base.database.PadDatabase

Implements verification API for querying ASVspoof2017 database.

convert_purposes(names, low_level_names, high_level_names)[source]

Converts purposes names from a low level to high level API

objects(groups=None, protocol=None, purposes=None, model_ids=None, **kwargs)[source]

Returns a set of Files for the specific query by the user.

Keyword Parameters:

groups
One of the groups (‘dev’, ‘eval’, ‘train’) or a tuple with several of them. If ‘None’ is given (this is the default), it is considered the same as a tuple with all possible values.
protocol
The protocol for which the clients should be retrieved. The protocol is dependent on your database. If you do not have protocols defined, just ignore this field.
purposes
The purposes can be either ‘real’ or ‘attack’.
model_ids
This parameter is not supported in this implementation.

Returns: A set of Files with the specified properties.

class bob.pad.voice.database.ASVspoofPadDatabase(protocol='CM', **kwargs)

Bases: bob.pad.base.database.PadDatabase

Implements verification API for querying ASVspoof database.

objects(groups=None, protocol=None, purposes=None, model_ids=None, **kwargs)[source]

Returns a set of Files for the specific query by the user.

Keyword Parameters:

groups
One of the groups (‘dev’, ‘eval’, ‘train’) or a tuple with several of them. If ‘None’ is given (this is the default), it is considered the same as a tuple with all possible values.
protocol
The protocol for which the clients should be retrieved. The protocol is dependent on your database. If you do not have protocols defined, just ignore this field.
purposes
The purposes can be either ‘real’ or ‘attack’.
model_ids
This parameter is not supported in this implementation.

Returns: A set of Files with the specified properties.

class bob.pad.voice.database.AVspoofPadDatabase(protocol='grandtest', **kwargs)

Bases: bob.pad.base.database.PadDatabase

Implements verification API for querying AVspoof database.

annotations(file)[source]
objects(groups=None, protocol=None, purposes=None, model_ids=None, **kwargs)[source]

Returns a set of Files for the specific query by the user.

Keyword Parameters:

groups
One of the groups (‘dev’, ‘eval’, ‘train’) or a tuple with several of them. If ‘None’ is given (this is the default), it is considered the same as a tuple with all possible values.
protocol
The protocol for which the clients should be retrieved. The protocol is dependent on your database. If you do not have protocols defined, just ignore this field.
purposes
The purposes can be either ‘real’ or ‘attack’.
model_ids
This parameter is not supported in this implementation.

Returns: A set of Files with the specified properties.

class bob.pad.voice.database.PadVoiceFile(client_id, path, attack_type=None, file_id=None)

Bases: bob.pad.base.database.PadFile

A simple base class that defines basic properties of File object for the use in PAD experiments

load(directory=None, extension='.wav')[source]
class bob.pad.voice.database.VoicePAPadDatabase(protocol='grandtest', **kwargs)

Bases: bob.pad.base.database.PadDatabase

Implements verification API for querying voicePA database.

objects(groups=None, protocol=None, purposes=None, model_ids=None, **kwargs)[source]

Returns a set of Files for the specific query by the user.

Keyword Parameters:

groups
One of the groups (‘train’, ‘dev’, ‘eval’) or a tuple with several of them. If ‘None’ is given (this is the default), it is considered the same as a tuple with all possible values.
protocol
The protocol for which the clients should be retrieved. The protocol is dependent on your database. If you do not have protocols defined, just ignore this field.
purposes
The purposes can be either ‘real’ or ‘attack’.
model_ids
This parameter is not supported in this implementation.

Returns: A set of Files with the specified properties.

bob.pad.voice.database.VoicePadFile

alias of PadVoiceFile