Tools implemented in bob.bio.spear¶
Preprocessors¶
-
class
bob.bio.spear.preprocessor.
Base
(**kwargs)[source]¶ Bases:
bob.bio.base.preprocessor.Preprocessor.Preprocessor
Performs color space adaptations and data type corrections for the given image
-
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)[source]¶ Bases:
bob.bio.spear.preprocessor.Base.Base
Extracts the Energy
-
read_data
(data_file)¶
-
read_original_data
(original_file_name)¶ Reads the original wav data from file (usually .wav file) If you have different format, please overwrite this function.
-
write_data
(data, data_file, compression=0)¶ Writes the given preprocessed data to a file with the given name.
-
-
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)[source]¶ Bases:
bob.bio.spear.preprocessor.Base.Base
VAD based on the thresholded energy
-
read_data
(data_file)¶
-
read_original_data
(original_file_name)¶ Reads the original wav data from file (usually .wav file) If you have different format, please overwrite this function.
-
write_data
(data, data_file, compression=0)¶ Writes the given preprocessed data to a file with the given name.
-
-
class
bob.bio.spear.preprocessor.
External
(win_length_ms=20.0, win_shift_ms=10.0, **kwargs)[source]¶ Bases:
bob.bio.spear.preprocessor.Base.Base
Uses external VAD and converts it to fit the format used by Spear
-
read_data
(data_file)¶
-
read_original_data
(original_file_name)¶ Reads the original wav data from file (usually .wav file) If you have different format, please overwrite this function.
-
write_data
(data, data_file, compression=0)¶ Writes the given preprocessed data to a file with the given name.
-
-
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)[source]¶ Bases:
bob.bio.spear.preprocessor.Base.Base
VAD based on the modulation of the energy around 4 Hz and the energy
-
mod_4hz
(rate_wavsample)[source]¶ Computes and returns the 4Hz modulation energy features for the given input wave file
-
read_data
(data_file)¶
-
read_original_data
(original_file_name)¶ Reads the original wav data from file (usually .wav file) If you have different format, please overwrite this function.
-
write_data
(data, data_file, compression=0)¶ Writes the given preprocessed data to a file with the given name.
-
Extractors¶
Feature extraction tools
-
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)[source]¶ Bases:
bob.bio.base.extractor.Extractor.Extractor
Extracts the Cepstral features
-
load
(extractor_file)¶ Loads the parameters required for feature extraction from the extractor file. This function usually is only useful in combination with the
train()
function. In this base class implementation, it does nothing.Parameters:
- extractor_file : str
- The file to read the extractor from.
-
read_feature
(feature_file)¶ Reads the extracted feature 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:
- feature_file : str or
bob.io.base.HDF5File
- The file open for reading or the name of the file to read from.
Returns:
- feature : object (usually
numpy.ndarray
) - The feature read from file.
- feature_file : str or
-
train
(training_data, extractor_file)¶ This function can be overwritten to train the feature extractor. If you do this, please also register the function by calling this base class constructor and enabling the training by
requires_training = True
.Parameters:
- training_data : [object] or [[object]]
- A list of preprocessed data that can be used for training the extractor.
Data will be provided in a single list, if
split_training_features_by_client = False
was specified in the constructor, otherwise the data will be split into lists, each of which contains the data of a single (training-)client. - extractor_file : str
- The file to write.
This file should be readable with the
load()
function.
-
write_feature
(feature, feature_file)¶ Writes the given extracted feature to a file with the given name. In this base class implementation, we simply use
bob.bio.base.save()
for that. If you have a different format, please overwrite this function.Parameters:
- feature : object
- The extracted feature, i.e., what is returned from
__call__()
. - feature_file : str or
bob.io.base.HDF5File
- The file open for writing, or the name of the file to write.
-
-
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)[source]¶ Bases:
bob.bio.base.extractor.Extractor.Extractor
Extracts the Cepstral features
-
load
(extractor_file)¶ Loads the parameters required for feature extraction from the extractor file. This function usually is only useful in combination with the
train()
function. In this base class implementation, it does nothing.Parameters:
- extractor_file : str
- The file to read the extractor from.
-
read_feature
(feature_file)¶ Reads the extracted feature 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:
- feature_file : str or
bob.io.base.HDF5File
- The file open for reading or the name of the file to read from.
Returns:
- feature : object (usually
numpy.ndarray
) - The feature read from file.
- feature_file : str or
-
train
(training_data, extractor_file)¶ This function can be overwritten to train the feature extractor. If you do this, please also register the function by calling this base class constructor and enabling the training by
requires_training = True
.Parameters:
- training_data : [object] or [[object]]
- A list of preprocessed data that can be used for training the extractor.
Data will be provided in a single list, if
split_training_features_by_client = False
was specified in the constructor, otherwise the data will be split into lists, each of which contains the data of a single (training-)client. - extractor_file : str
- The file to write.
This file should be readable with the
load()
function.
-
write_feature
(feature, feature_file)¶ Writes the given extracted feature to a file with the given name. In this base class implementation, we simply use
bob.bio.base.save()
for that. If you have a different format, please overwrite this function.Parameters:
- feature : object
- The extracted feature, i.e., what is returned from
__call__()
. - feature_file : str or
bob.io.base.HDF5File
- The file open for writing, or the name of the file to write.
-
-
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)[source]¶ Bases:
bob.bio.base.extractor.Extractor.Extractor
Extracts the Cepstral features
-
load
(extractor_file)¶ Loads the parameters required for feature extraction from the extractor file. This function usually is only useful in combination with the
train()
function. In this base class implementation, it does nothing.Parameters:
- extractor_file : str
- The file to read the extractor from.
-
read_feature
(feature_file)¶ Reads the extracted feature 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:
- feature_file : str or
bob.io.base.HDF5File
- The file open for reading or the name of the file to read from.
Returns:
- feature : object (usually
numpy.ndarray
) - The feature read from file.
- feature_file : str or
-
train
(training_data, extractor_file)¶ This function can be overwritten to train the feature extractor. If you do this, please also register the function by calling this base class constructor and enabling the training by
requires_training = True
.Parameters:
- training_data : [object] or [[object]]
- A list of preprocessed data that can be used for training the extractor.
Data will be provided in a single list, if
split_training_features_by_client = False
was specified in the constructor, otherwise the data will be split into lists, each of which contains the data of a single (training-)client. - extractor_file : str
- The file to write.
This file should be readable with the
load()
function.
-
write_feature
(feature, feature_file)¶ Writes the given extracted feature to a file with the given name. In this base class implementation, we simply use
bob.bio.base.save()
for that. If you have a different format, please overwrite this function.Parameters:
- feature : object
- The extracted feature, i.e., what is returned from
__call__()
. - feature_file : str or
bob.io.base.HDF5File
- The file open for writing, or the name of the file to write.
-