diff --git a/bob/bio/spear/config/database/banca_audio_G.py b/bob/bio/spear/config/database/banca_audio_G.py index 0c81423963b4a424c1cd6daf8e66f9bd98c8b6dd..4885cf09eb1d5cbec7f49f1810cc1f94f030a3f6 100644 --- a/bob/bio/spear/config/database/banca_audio_G.py +++ b/bob/bio/spear/config/database/banca_audio_G.py @@ -5,7 +5,7 @@ import bob.db.bio_filelist banca_wav_directory = "[YOUR_BANCA_WAV_DIRECTORY]" -database = bob.db.bio_filelist.Database(pkg_resources.resource_filename('bob.bio.spear', 'config/database/banca'), +database = bob.db.bio_filelist.Database(pkg_resources.resource_filename('bob.bio.db', 'default_configs/banca'), original_directory=banca_wav_directory, original_extension=".wav") diff --git a/bob/bio/spear/config/database/mobio.py b/bob/bio/spear/config/database/mobio.py new file mode 100644 index 0000000000000000000000000000000000000000..e018fc38d10b601ebf4ef0498ba5a154acde6aa0 --- /dev/null +++ b/bob/bio/spear/config/database/mobio.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +from bob.bio.spear.database import MobioBioDatabase +mobio_wav_directory = "[YOUR_MOBIO_WAV_DIRECTORY]" + +mobio_audio_male = MobioBioDatabase( + original_directory=mobio_wav_directory, + original_extension=".wav", + protocol='male', + models_depend_on_protocol=True, + all_files_options={'gender': 'male'}, + extractor_training_options={'gender': 'male'}, + projector_training_options={'gender': 'male'}, + enroller_training_options={'gender': 'male'}, + z_probe_options={'gender': 'male'} +) + +mobio_audio_female = MobioBioDatabase( + original_directory=mobio_wav_directory, + original_extension=".wav", + protocol='female', + models_depend_on_protocol=True, + all_files_options={'gender': 'female'}, + extractor_training_options={'gender': 'female'}, + projector_training_options={'gender': 'female'}, + enroller_training_options={'gender': 'female'}, + z_probe_options={'gender': 'female'} +) diff --git a/bob/bio/spear/config/database/voxforge.py b/bob/bio/spear/config/database/voxforge.py index 97af17ad0cb40f4d19781a0bc65d514f1d0272b0..c51a0d2ef7803f5ca9d86fe824b05c09c916ff4e 100644 --- a/bob/bio/spear/config/database/voxforge.py +++ b/bob/bio/spear/config/database/voxforge.py @@ -1,10 +1,9 @@ #!/usr/bin/env python -import bob.bio.db - +from bob.bio.spear.database import VoxforgeBioDatabase voxforge_wav_directory = "[YOUR_VOXFORGE_DIRECTORY]" -database = bob.bio.db.VoxforgeBioDatabase( +database = VoxforgeBioDatabase( original_directory=voxforge_wav_directory, original_extension=".wav", ) diff --git a/bob/bio/spear/database/__init__.py b/bob/bio/spear/database/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..9997d6ef8434872e80908674f78fde23fdbd09f4 --- /dev/null +++ b/bob/bio/spear/database/__init__.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python +# vim: set fileencoding=utf-8 : +# Elie Khoury <Elie.Khoury@idiap.ch> +# Fri Aug 30 11:42:11 CEST 2013 +# +# Copyright (C) 2012-2013 Idiap Research Institute, Martigny, Switzerland +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +"""Feature extraction tools""" + +from .database import AudioBioFile +from .mobio import MobioBioDatabase +from .voxforge import VoxforgeBioDatabase + +# gets sphinx autodoc done right - don't remove it +__all__ = [_ for _ in dir() if not _.startswith('_')] diff --git a/bob/bio/spear/database/database.py b/bob/bio/spear/database/database.py new file mode 100644 index 0000000000000000000000000000000000000000..d366db482e8ff07918b8dfb12dc45c888d88b60c --- /dev/null +++ b/bob/bio/spear/database/database.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python +# vim: set fileencoding=utf-8 : +# Tiago de Freitas Pereira <tiago.pereira@idiap.ch> +# Wed 20 July 14:43:22 CEST 2016 + +""" + Verification API for bob.db.voxforge +""" + +from bob.bio.base.database.file import BioFile +import scipy +import numpy + + +class AudioBioFile(BioFile): + def __init__(self, f): + """ + Initializes this File object with an File equivalent for + VoxForge database. + """ + super(AudioBioFile, self).__init__(client_id=f.client_id, path=f.path, file_id=f.id) + + self.__f = f + + def load(self, directory=None, extension='.wav'): + rate, audio = scipy.io.wavfile.read(self.make_path(directory, extension)) + # We consider there is only 1 channel in the audio file => data[0] + data= numpy.cast['float'](audio) + return rate, data + diff --git a/bob/bio/spear/database/mobio.py b/bob/bio/spear/database/mobio.py new file mode 100644 index 0000000000000000000000000000000000000000..a6469d1c8b3b83947c5e8a80d8fba9792b1bfc1a --- /dev/null +++ b/bob/bio/spear/database/mobio.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python +# vim: set fileencoding=utf-8 : +# Amir Mohammadi <amir.mohammadi@idiap.ch> +# Wed 13 Jul 16:43:22 CEST 2016 + +""" + MOBIO database implementation of bob.bio.db.ZTDatabase interface. + It is an extension of an SQL-based database interface, which directly talks to Mobio database, for + verification experiments (good to use in bob.bio.base framework). +""" + + +from .database import AudioBioFile +from bob.bio.base.database import ZTBioDatabase, BioFile + + +class MobioBioDatabase(ZTBioDatabase): + """ + Implements verification API for querying Mobio database. + """ + + def __init__( + self, + **kwargs + ): + # call base class constructors to open a session to the database + super(MobioBioDatabase, self).__init__(name='mobio', + **kwargs) + + from bob.db.mobio.query import Database as LowLevelDatabase + self.__db = LowLevelDatabase() + + def model_ids_with_protocol(self, groups=None, protocol=None, gender=None): + return self.__db.model_ids(groups=groups, protocol=protocol, gender=gender) + + def tmodel_ids_with_protocol(self, protocol=None, groups=None, **kwargs): + return self.__db.tmodel_ids(protocol=protocol, groups=groups, **kwargs) + + def objects(self, groups=None, protocol=None, purposes=None, model_ids=None, **kwargs): + retval = self.__db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) + return [AudioBioFile(f) for f in retval] + + def tobjects(self, groups=None, protocol=None, model_ids=None, **kwargs): + retval = self.__db.tobjects(groups=groups, protocol=protocol, model_ids=model_ids, **kwargs) + return [AudioBioFile(f) for f in retval] + + def zobjects(self, groups=None, protocol=None, **kwargs): + retval = self.__db.zobjects(groups=groups, protocol=protocol, **kwargs) + return [AudioBioFile(f) for f in retval] diff --git a/bob/bio/spear/database/voxforge.py b/bob/bio/spear/database/voxforge.py new file mode 100644 index 0000000000000000000000000000000000000000..4e2679834b7c772ca7fe68af32b3ccc6a492aade --- /dev/null +++ b/bob/bio/spear/database/voxforge.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python +# vim: set fileencoding=utf-8 : +# Tiago de Freitas Pereira <tiago.pereira@idiap.ch> +# Wed 20 July 14:43:22 CEST 2016 + +""" + Verification API for bob.db.voxforge +""" + +from .database import AudioBioFile +from bob.bio.base.database import BioDatabase, BioFile + +class VoxforgeBioDatabase(BioDatabase): + """ + Implements verification API for querying Voxforge database. + """ + + def __init__(self, original_directory=None, original_extension=None, **kwargs): + # call base class constructors to open a session to the database + super(VoxforgeBioDatabase, self).__init__( + name='voxforge', protocol='', + original_directory=original_directory, + original_extension=original_extension, **kwargs) + + from bob.db.voxforge.query import Database as LowLevelDatabase + self.__db = LowLevelDatabase(original_directory=original_directory, original_extension=original_extension) + + def model_ids_with_protocol(self, groups=None, protocol=None, **kwargs): + """Returns a set of models ids for the specific query by the user. + + Keyword Parameters: + + protocol + Protocol is ignored in this context, since its choice has no influence on models. + + groups + The groups to which the subjects attached to the models belong ('dev', 'eval', 'world') + + Returns: A list containing the ids of all models belonging to the given groups. + """ + return [client.id for client in self.__db.clients(groups=groups, protocol=protocol)] + + def objects(self, protocol=None, purposes=None, model_ids=None, + groups=None, gender=None): + """Returns a set of Files for the specific query by the user. + + Keyword Parameters: + + protocol + Not applicable. VoxForge has only one protocol + + purposes + The purposes can be either 'enroll', 'probe', or their tuple. + If 'None' is given (this is the default), it is + considered the same as a tuple with both possible values. + + model_ids + Only retrieves the files for the provided list of model ids (claimed + client id). If 'None' is given (this is the default), no filter over + the model_ids is performed. + + groups + One of the groups ('dev', 'eval', 'world') 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. + + gender + Not applicable + + Returns: A set of Files with the specified properties. + """ + + # now, query the actual Voxforge database + objects = self.__db.objects(groups=groups, + model_ids=model_ids, purposes=purposes) + + # make sure to return BioFile representation of a file, not the database one + return [AudioBioFile(BioFile(client_id=f.client_id, path=f.path, file_id=f.id)) for f in objects] diff --git a/buildout-dev.cfg b/buildout-dev.cfg index 004c5a859547c278f0972f2e2048bd9b9cd638d0..2f6eb54bcc7361bd5da0ca5bee344699a79a6839 100644 --- a/buildout-dev.cfg +++ b/buildout-dev.cfg @@ -25,7 +25,6 @@ develop = src/bob.extension src/bob.measure src/bob.db.base src/bob.bio.base - src/bob.bio.db src/bob.db.bio_filelist src/bob.db.voxforge . @@ -36,23 +35,24 @@ verbose = true newest = false [sources] -bob.extension = git https://github.com/bioidiap/bob.extension -bob.blitz = git https://github.com/bioidiap/bob.blitz -bob.core = git https://github.com/bioidiap/bob.core -bob.io.base = git https://github.com/bioidiap/bob.io.base -bob.learn.activation = git https://github.com/bioidiap/bob.learn.activation -bob.math = git https://github.com/bioidiap/bob.math -bob.sp = git https://github.com/bioidiap/bob.sp -bob.ap = git https://github.com/bioidiap/bob.ap -bob.learn.linear = git https://github.com/bioidiap/bob.learn.linear -bob.learn.em = git https://github.com/bioidiap/bob.learn.em -bob.measure = git https://github.com/bioidiap/bob.measure -bob.db.base = git https://github.com/bioidiap/bob.db.base -bob.bio.base = git https://github.com/bioidiap/bob.bio.base -bob.bio.db = git git@gitlab.idiap.ch:biometric/bob.bio.db -bob.db.bio_filelist = git git@github.com:bioidiap/bob.db.bio_filelist -bob.db.voxforge = git git@github.com:bioidiap/bob.db.voxforge +bob.extension = git https://gitlab.idiap.ch/bob/bob.extension +bob.blitz = git https://gitlab.idiap.ch/bob/bob.blitz +bob.core = git https://gitlab.idiap.ch/bob/bob.core +bob.io.base = git https://gitlab.idiap.ch/bob/bob.io.base +bob.learn.activation = git https://gitlab.idiap.ch/bob/bob.learn.activation +bob.math = git https://gitlab.idiap.ch/bob/bob.math +bob.sp = git https://gitlab.idiap.ch/bob/bob.sp +bob.ap = git https://gitlab.idiap.ch/bob/bob.ap +bob.learn.linear = git https://gitlab.idiap.ch/bob/bob.learn.linear +bob.learn.em = git https://gitlab.idiap.ch/bob/bob.learn.em +bob.measure = git https://gitlab.idiap.ch/bob/bob.measure +bob.db.base = git https://gitlab.idiap.ch/bob/bob.db.base +bob.bio.base = git https://gitlab.idiap.ch/bob/bob.bio.base branch=issue-8-remove-database-configuration +bob.db.bio_filelist = git git@gitlab.idiap.ch:bob/bob.db.bio_filelist +bob.db.voxforge = git git@gitlab.idiap.ch:bob/bob.db.voxforge [scripts] recipe = bob.buildout:scripts dependent-scripts = true + + diff --git a/develop.cfg b/develop.cfg deleted file mode 100644 index 276f0ee2817770db567261e4c024bf2e20f95748..0000000000000000000000000000000000000000 --- a/develop.cfg +++ /dev/null @@ -1,42 +0,0 @@ -; vim: set fileencoding=utf-8 : -; Elie Khoury <Elie.Khoury@idiap.ch> -; Thu 11 Jun 18:07:26 CEST 2015 - -[buildout] -parts = scripts -eggs = bob.bio.spear - bob.bio.db - bob.db.base - bob.db.bio_filelist - bob.db.voxforge - bob.bio.base - bob.db.asvspoof - gridtk - -extensions = bob.buildout - mr.developer -auto-checkout = * -develop = src/bob.bio.db - src/bob.db.bio_filelist - src/bob.db.voxforge - src/bob.bio.base - src/bob.db.asvspoof - . - -; options for bob.buildout -debug = false -verbose = true -newest = false - -[sources] -bob.db.base = git git@gitlab.idiap.ch:bob/bob.db.base -bob.bio.db = git git@gitlab.idiap.ch:bob/bob.bio.db -bob.db.bio_filelist = git git@gitlab.idiap.ch:bob/bob.db.bio_filelist -bob.db.voxforge = git git@gitlab.idiap.ch:bob/bob.db.voxforge -bob.bio.base = git git@gitlab.idiap.ch:bob/bob.bio.base -bob.db.asvspoof = git git@gitlab.idiap.ch:bob/bob.db.asvspoof - - -[scripts] -recipe = bob.buildout:scripts -dependent-scripts = true diff --git a/requirements.txt b/requirements.txt index 6d3cf00ab2b8cea061552a455be282735b0f4896..815c0179129c121de84015c0b6af3fcda6b6dead 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,5 +12,4 @@ bob.learn.em bob.measure bob.db.base bob.bio.base -bob.bio.db matplotlib # for plotting diff --git a/setup.py b/setup.py index b78fb8262e971b20a96486dfb42d7d0589600141..f41c5b4009ab7726a8bca8a3070723989167f822 100644 --- a/setup.py +++ b/setup.py @@ -100,9 +100,11 @@ setup( entry_points = { 'bob.bio.database': [ - 'voxforge = bob.bio.spear.config.database.voxforge:database', + 'voxforge = bob.bio.spear.config.database.voxforge:database', 'banca-audio = bob.bio.spear.config.database.banca_audio_G:database', - 'timit = bob.bio.spear.config.database.timit:database', + 'timit = bob.bio.spear.config.database.timit:database', + 'mobio-male = bob.bio.spear.config.database.mobio:mobio_audio_male', + 'mobio-female = bob.bio.spear.config.database.mobio:mobio_audio_female', ], 'bob.bio.preprocessor': [