Commit e2ed2ffc authored by Amir MOHAMMADI's avatar Amir MOHAMMADI

Audio and video database

parent 7119b2c3
Pipeline #15070 failed with stages
in 4 minutes and 19 seconds
from .query import Database, SwanAudioBioFile, SwanVideoBioFile
def __appropriate__(*args):
"""Says object was actually declared here, and not in the import module.
Fixing sphinx warnings of not being able to find classes, when path is
shortened. Parameters:
*args: An iterable of objects to modify
Resolves `Sphinx referencing issues
<https://github.com/sphinx-doc/sphinx/issues/3048>`
"""
for obj in args:
obj.__module__ = __name__
__appropriate__(
Database,
SwanAudioBioFile,
SwanVideoBioFile,
)
def get_config():
"""Returns a string containing the configuration information.
......
#!/usr/bin/env python
from bob.db.swan import Database
from bob.db.swan import Database, SwanAudioBioFile
swan_raw_data_directory = "[YOUR_SWAN_DIRECTORY]"
database = Database(
original_directory=swan_raw_data_directory,
original_extension=".mp4",
bio_file_class=SwanAudioBioFile,
)
#!/usr/bin/env python
from bob.db.swan import Database, SwanVideoBioFile
swan_raw_data_directory = "[YOUR_SWAN_DIRECTORY]"
database = Database(
original_directory=swan_raw_data_directory,
original_extension=".mp4",
bio_file_class=SwanVideoBioFile,
)
#!/usr/bin/env python
from bob.bio.spear.database import AudioBioFile
from bob.bio.video.database import VideoBioFile
from bob.bio.video.utils import FrameSelector
import bob.bio.base
import numpy
import scipy.io.wavfile
import subprocess
import tempfile
import bob.io.base
import bob.io.video
import numpy as np
def read_audio(video_path):
......@@ -30,6 +35,22 @@ class SwanAudioBioFile(AudioBioFile):
return super(SwanAudioBioFile, self).load(directory, extension)
class SwanVideoBioFile(VideoBioFile):
"""SwanVideoBioFile are video files actually"""
def load(self, directory=None, extension='.mp4', frame_selector=FrameSelector()):
extension = extension or '.mp4'
if extension == '.mp4':
video_path = self.make_path(directory, extension)
video = bob.io.base.load(video_path)
# rotate the video since SWAN videos are not upright!
video = np.swapaxes(video, -2, -1)
return frame_selector(video)
else:
return super(SwanVideoBioFile, self).load(
directory, extension, frame_selector)
class Database(bob.bio.base.database.FileListBioDatabase):
"""Wrapper class for the SWAN database for speaker recognition
(http://www.idiap.ch/dataset/swan). This class defines a simple protocol
......@@ -37,11 +58,12 @@ class Database(bob.bio.base.database.FileListBioDatabase):
three main parts.
"""
def __init__(self, original_directory=None, original_extension=None):
def __init__(self, original_directory=None, original_extension=None,
bio_file_class=SwanAudioBioFile):
# call base class constructor
from pkg_resources import resource_filename
folder = resource_filename(__name__, 'lists')
super(Database, self).__init__(
folder, 'voxforge', bio_file_class=SwanAudioBioFile,
folder, 'swan', bio_file_class=bio_file_class,
original_directory=original_directory,
original_extension=original_extension)
......@@ -33,7 +33,8 @@ setup(
entry_points={
'bob.db': ['swan = bob.db.swan.driver:Interface'],
'bob.bio.database': ['swan = bob.db.swan.config:database'],
'bob.bio.database': ['swan-audio = bob.db.swan.config_audio:database'],
'bob.bio.database': ['swan-video = bob.db.swan.config_video:database'],
},
classifiers=[
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment