Skip to content
Snippets Groups Projects
Commit 8352cb41 authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Merge branch 'issue-8-remove-database-configuration' into 'master'

Issue 8 remove database configuration

Continuing the merge with bob.bio.base

bob.bio.base!37

See merge request !14
parents 1e52ae87 4da68cc0
Branches
Tags
1 merge request!14Issue 8 remove database configuration
Pipeline #
......@@ -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")
#!/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'}
)
#!/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",
)
#!/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('_')]
#!/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
#!/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]
#!/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]
......@@ -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
; 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
......@@ -12,5 +12,4 @@ bob.learn.em
bob.measure
bob.db.base
bob.bio.base
bob.bio.db
matplotlib # for plotting
......@@ -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': [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment