Tools implemented in bob.bio.spear¶
Summary¶
Databases¶
Implements verification API for querying ASVspoof database. |
|
Implements verification API for querying AVspoof database. |
|
Implements verification API for querying Mobio database. |
|
Implements verification API for querying VoicePA database. |
Speech Preprocessors¶
|
Performs color space adaptations and data type corrections for the given image |
Extracts the Energy |
|
VAD based on the thresholded energy |
|
VAD based on the modulation of the energy around 4 Hz and the energy |
|
Uses external VAD and converts it to fit the format used by Spear |
Voice Feature Extractors¶
Extracts the Cepstral features |
|
Extracts the Cepstral features |
|
Extracts the Cepstral features |
Databases¶
Feature extraction tools
-
class
bob.bio.spear.database.
ASVspoof2017BioDatabase
(**kwargs)¶ Bases:
bob.bio.base.database.BioDatabase
Implements verification API for querying ASVspoof2017 database.
-
annotations
(file)[source]¶ Returns the annotations for the given File object, if available. You need to override this method in your high-level implementation. If your database does not have annotations, it should return
None
.Parameters:
- file
bob.bio.base.database.BioFile
The file for which annotations should be returned.
Returns:
- annotsdict or None
The annotations for the file, if available.
- file
-
model_ids_with_protocol
(groups = None, protocol = None, **kwargs) → ids[source]¶ Returns a list of model ids for the given groups and given protocol.
Parameters:
- groupsone or more of
('world', 'dev', 'eval')
The groups to get the model ids for.
protocol: a protocol name
Returns:
- ids[int] or [str]
The list of (unique) model ids for the given groups.
- groupsone or more of
-
objects
(protocol=None, purposes=None, model_ids=None, groups=None, **kwargs)[source]¶ This function returns a list of
bob.bio.base.database.BioFile
objects or the list of objects which inherit from this class. Returned files fulfill the given restrictions.Keyword parameters:
- groupsstr or [str]
The groups of which the clients should be returned. Usually, groups are one or more elements of (‘world’, ‘dev’, ‘eval’)
- 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.
- purposesstr or [str]
The purposes for which File objects should be retrieved. Usually, purposes are one of (‘enroll’, ‘probe’).
- model_ids[various type]
The model ids for which the File objects should be retrieved. What defines a ‘model id’ is dependent on the database. In cases, where there is only one model per client, model ids and client ids are identical. In cases, where there is one model per file, model ids and file ids are identical. But, there might also be other cases.
-
-
class
bob.bio.spear.database.
ASVspoofBioDatabase
(**kwargs)¶ Bases:
bob.bio.base.database.BioDatabase
Implements verification API for querying ASVspoof database.
-
annotations
(file)[source]¶ Returns the annotations for the given File object, if available. You need to override this method in your high-level implementation. If your database does not have annotations, it should return
None
.Parameters:
- file
bob.bio.base.database.BioFile
The file for which annotations should be returned.
Returns:
- annotsdict or None
The annotations for the file, if available.
- file
-
model_ids_with_protocol
(groups = None, protocol = None, **kwargs) → ids[source]¶ Returns a list of model ids for the given groups and given protocol.
Parameters:
- groupsone or more of
('world', 'dev', 'eval')
The groups to get the model ids for.
protocol: a protocol name
Returns:
- ids[int] or [str]
The list of (unique) model ids for the given groups.
- groupsone or more of
-
objects
(protocol=None, purposes=None, model_ids=None, groups=None, **kwargs)[source]¶ This function returns a list of
bob.bio.base.database.BioFile
objects or the list of objects which inherit from this class. Returned files fulfill the given restrictions.Keyword parameters:
- groupsstr or [str]
The groups of which the clients should be returned. Usually, groups are one or more elements of (‘world’, ‘dev’, ‘eval’)
- 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.
- purposesstr or [str]
The purposes for which File objects should be retrieved. Usually, purposes are one of (‘enroll’, ‘probe’).
- model_ids[various type]
The model ids for which the File objects should be retrieved. What defines a ‘model id’ is dependent on the database. In cases, where there is only one model per client, model ids and client ids are identical. In cases, where there is one model per file, model ids and file ids are identical. But, there might also be other cases.
-
-
class
bob.bio.spear.database.
AVspoofBioDatabase
(**kwargs)¶ Bases:
bob.bio.base.database.BioDatabase
Implements verification API for querying AVspoof database.
-
annotations
(file)[source]¶ Returns the annotations for the given File object, if available. You need to override this method in your high-level implementation. If your database does not have annotations, it should return
None
.Parameters:
- file
bob.bio.base.database.BioFile
The file for which annotations should be returned.
Returns:
- annotsdict or None
The annotations for the file, if available.
- file
-
model_ids_with_protocol
(groups = None, protocol = None, **kwargs) → ids[source]¶ Returns a list of model ids for the given groups and given protocol.
Parameters:
- groupsone or more of
('world', 'dev', 'eval')
The groups to get the model ids for.
protocol: a protocol name
Returns:
- ids[int] or [str]
The list of (unique) model ids for the given groups.
- groupsone or more of
-
objects
(protocol=None, purposes=None, model_ids=None, groups=None, **kwargs)[source]¶ This function returns a list of
bob.bio.base.database.BioFile
objects or the list of objects which inherit from this class. Returned files fulfill the given restrictions.Keyword parameters:
- groupsstr or [str]
The groups of which the clients should be returned. Usually, groups are one or more elements of (‘world’, ‘dev’, ‘eval’)
- 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.
- purposesstr or [str]
The purposes for which File objects should be retrieved. Usually, purposes are one of (‘enroll’, ‘probe’).
- model_ids[various type]
The model ids for which the File objects should be retrieved. What defines a ‘model id’ is dependent on the database. In cases, where there is only one model per client, model ids and client ids are identical. In cases, where there is one model per file, model ids and file ids are identical. But, there might also be other cases.
-
-
class
bob.bio.spear.database.
AudioBioFile
(client_id, path, file_id, **kwargs)¶ Bases:
bob.bio.base.database.BioFile
-
load
(directory=None, extension='.wav')[source]¶ Loads the data at the specified location and using the given extension. Override it if you need to load differently.
- Parameters
- Returns
The loaded data (normally
numpy.ndarray
).- Return type
-
-
class
bob.bio.spear.database.
MobioBioDatabase
(original_directory=None, original_extension=None, annotation_directory=None, annotation_extension='.pos', **kwargs)¶ Bases:
bob.bio.base.database.ZTBioDatabase
Implements verification API for querying Mobio database.
-
annotations
(file)[source]¶ Returns the annotations for the given File object, if available. You need to override this method in your high-level implementation. If your database does not have annotations, it should return
None
.Parameters:
- file
bob.bio.base.database.BioFile
The file for which annotations should be returned.
Returns:
- annotsdict or None
The annotations for the file, if available.
- file
-
model_ids_with_protocol
(groups = None, protocol = None, **kwargs) → ids[source]¶ Returns a list of model ids for the given groups and given protocol.
Parameters:
- groupsone or more of
('world', 'dev', 'eval')
The groups to get the model ids for.
protocol: a protocol name
Returns:
- ids[int] or [str]
The list of (unique) model ids for the given groups.
- groupsone or more of
-
objects
(groups=None, protocol=None, purposes=None, model_ids=None, **kwargs)[source]¶ This function returns a list of
bob.bio.base.database.BioFile
objects or the list of objects which inherit from this class. Returned files fulfill the given restrictions.Keyword parameters:
- groupsstr or [str]
The groups of which the clients should be returned. Usually, groups are one or more elements of (‘world’, ‘dev’, ‘eval’)
- 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.
- purposesstr or [str]
The purposes for which File objects should be retrieved. Usually, purposes are one of (‘enroll’, ‘probe’).
- model_ids[various type]
The model ids for which the File objects should be retrieved. What defines a ‘model id’ is dependent on the database. In cases, where there is only one model per client, model ids and client ids are identical. In cases, where there is one model per file, model ids and file ids are identical. But, there might also be other cases.
-
tmodel_ids_with_protocol
(protocol=None, groups=None, **kwargs)[source]¶ This function returns the ids of the T-Norm models of the given groups for the given protocol.
Keyword parameters:
- groupsstr or [str]
The groups of which the model ids should be returned. Usually, groups are one or more elements of (‘dev’, ‘eval’)
- protocolstr
The protocol for which the model ids should be retrieved. The protocol is dependent on your database. If you do not have protocols defined, just ignore this field.
-
tobjects
(groups=None, protocol=None, model_ids=None, **kwargs)[source]¶ This function returns the File objects of the T-Norm models of the given groups for the given protocol and the given model ids.
Keyword parameters:
- groupsstr or [str]
The groups of which the model ids should be returned. Usually, groups are one or more elements of (‘dev’, ‘eval’)
- protocolstr
The protocol for which the model ids should be retrieved. The protocol is dependent on your database. If you do not have protocols defined, just ignore this field.
- model_ids[various type]
The model ids for which the File objects should be retrieved. What defines a ‘model id’ is dependent on the database. In cases, where there is only one model per client, model ids and client ids are identical. In cases, where there is one model per file, model ids and file ids are identical. But, there might also be other cases.
-
zobjects
(groups=None, protocol=None, **kwargs)[source]¶ This function returns the File objects of the Z-Norm impostor files of the given groups for the given protocol.
Keyword parameters:
- groupsstr or [str]
The groups of which the model ids should be returned. Usually, groups are one or more elements of (‘dev’, ‘eval’)
- protocolstr
The protocol for which the model ids should be retrieved. The protocol is dependent on your database. If you do not have protocols defined, just ignore this field.
-
-
class
bob.bio.spear.database.
VoicePABioDatabase
(**kwargs)¶ Bases:
bob.bio.base.database.BioDatabase
Implements verification API for querying VoicePA database.
-
annotations
(file)[source]¶ Returns the annotations for the given File object, if available. You need to override this method in your high-level implementation. If your database does not have annotations, it should return
None
.Parameters:
- file
bob.bio.base.database.BioFile
The file for which annotations should be returned.
Returns:
- annotsdict or None
The annotations for the file, if available.
- file
-
model_ids_with_protocol
(groups = None, protocol = None, **kwargs) → ids[source]¶ Returns a list of model ids for the given groups and given protocol.
Parameters:
- groupsone or more of
('world', 'dev', 'eval')
The groups to get the model ids for.
protocol: a protocol name
Returns:
- ids[int] or [str]
The list of (unique) model ids for the given groups.
- groupsone or more of
-
objects
(protocol=None, purposes=None, model_ids=None, groups=None, **kwargs)[source]¶ This function returns a list of
bob.bio.base.database.BioFile
objects or the list of objects which inherit from this class. Returned files fulfill the given restrictions.Keyword parameters:
- groupsstr or [str]
The groups of which the clients should be returned. Usually, groups are one or more elements of (‘world’, ‘dev’, ‘eval’)
- 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.
- purposesstr or [str]
The purposes for which File objects should be retrieved. Usually, purposes are one of (‘enroll’, ‘probe’).
- model_ids[various type]
The model ids for which the File objects should be retrieved. What defines a ‘model id’ is dependent on the database. In cases, where there is only one model per client, model ids and client ids are identical. In cases, where there is one model per file, model ids and file ids are identical. But, there might also be other cases.
-
Preprocessors¶
-
class
bob.bio.spear.preprocessor.
Base
(**kwargs)¶ Bases:
bob.bio.base.preprocessor.Preprocessor
Performs color space adaptations and data type corrections for the given image
-
read_data
(data_file) → data[source]¶ Reads the preprocessed data from file. In this base class implementation, it uses
bob.bio.base.load()
to do that. If you have different format, please overwrite this function.Parameters:
- data_filestr or
bob.io.base.HDF5File
The file open for reading or the name of the file to read from.
Returns:
- dataobject (usually
numpy.ndarray
) The preprocessed data read from file.
- data_filestr or
-
-
class
bob.bio.spear.preprocessor.
Energy_2Gauss
(max_iterations=10, convergence_threshold=0.0005, variance_threshold=0.0005, win_length_ms=20.0, win_shift_ms=10.0, smoothing_window=10, **kwargs)¶ Bases:
bob.bio.spear.preprocessor.Base
Extracts the Energy
-
class
bob.bio.spear.preprocessor.
Energy_Thr
(win_length_ms=20.0, win_shift_ms=10.0, smoothing_window=10, ratio_threshold=0.15, **kwargs)¶ Bases:
bob.bio.spear.preprocessor.Base
VAD based on the thresholded energy
-
class
bob.bio.spear.preprocessor.
External
(win_length_ms=20.0, win_shift_ms=10.0, **kwargs)¶ Bases:
bob.bio.spear.preprocessor.Base
Uses external VAD and converts it to fit the format used by Spear
-
class
bob.bio.spear.preprocessor.
Mod_4Hz
(max_iterations=10, convergence_threshold=0.0005, variance_threshold=0.0005, win_length_ms=20.0, win_shift_ms=10.0, smoothing_window=10, n_filters=40, f_min=0.0, f_max=4000, pre_emphasis_coef=1.0, ratio_threshold=0.1, **kwargs)¶ Bases:
bob.bio.spear.preprocessor.Base
VAD based on the modulation of the energy around 4 Hz and the energy
Extractors¶
Feature extraction tools
-
class
bob.bio.spear.extractor.
CQCCFeatures
(split_training_data_by_client=False, features_mask=array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]), **kwargs)¶ Bases:
bob.bio.base.preprocessor.Preprocessor
,bob.bio.base.extractor.Extractor
This class should be used as a preprocessor (converts matlab data into HDF5) and an extractor (reads saved data)
Converts pre-computed with Matlab CQCC features into numpy array suitable for Bob-based experiments. CQCC features are obtained using CQCC Matlab toolkit from http://audio.eurecom.fr/content/software The features are originally proposed in the following paper: Todisco, Massimiliano; Delgado, Héctor; Evans, Nicholas “Articulation rate filtering of CQCC features for automatic speaker verification”, INTERSPEECH 2016, Annual Conference of the International Speech Communication Association, September 8-12, 2016, San Francisco, USA
-
class
bob.bio.spear.extractor.
Cepstral
(win_length_ms=20, win_shift_ms=10, n_filters=24, dct_norm=False, f_min=0.0, f_max=4000, delta_win=2, mel_scale=True, with_energy=True, with_delta=True, with_delta_delta=True, n_ceps=19, pre_emphasis_coef=0.95, features_mask=array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59]), normalize_flag=True, **kwargs)¶ Bases:
bob.bio.base.extractor.Extractor
Extracts the Cepstral features
-
class
bob.bio.spear.extractor.
CepstralExtended
(win_length_ms=20.0, win_shift_ms=10.0, n_filters=40, f_min=0.0, f_max=8000, pre_emphasis_coef=1.0, mel_scale=True, rect_filter=False, inverse_filter=False, delta_win=2, n_ceps=19, dct_norm=False, ssfc_features=False, scfc_features=False, scmc_features=False, with_delta=True, with_delta_delta=True, with_energy=False, normalize_spectrum=False, keep_only_deltas=True, log_filter=True, energy_filter=False, vad_filter='no_filter', 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
-
class
bob.bio.spear.extractor.
HTKFeatures
(features_mask=array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59]), normalize_flag=True, **kwargs)¶ Bases:
bob.bio.base.extractor.Extractor
Extracts the Cepstral features
-
class
bob.bio.spear.extractor.
SPROFeatures
(features_mask=array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59]), normalize_flag=True, **kwargs)¶ Bases:
bob.bio.base.extractor.Extractor
Extracts the Cepstral features