load()¶
- audb.load(name, *, version=None, only_metadata=False, bit_depth=None, channels=None, format=None, mixdown=False, sampling_rate=None, attachments=None, tables=None, media=None, removed_media=False, full_path=True, pickle_tables=True, cache_root=None, num_workers=1, timeout=-1, verbose=True)[source]¶
Load database.
Loads meta and media files of a database to the local cache and returns a
audformat.Database
object.By setting
bit_depth
,channels
,format
,mixdown
, andsampling_rate
we can request a specific flavor of the database. In that case media files are automatically converted to the desired properties (see alsoaudb.Flavor
).It is possible to filter meta and media files with the arguments
tables
andmedia
. Only media files with at least one reference are loaded. I.e. filtering meta files, may also remove media files. Likewise, references to missing media files will be removed, too. I.e. filtering media files, may also remove entries from the meta files.- Parameters
name (
str
) – name of databaseonly_metadata (
bool
) – load only header and tables of databasechannels (
Union
[int
,Sequence
[int
],None
]) – channel selection, seeaudresample.remix()
. Note that media files with too few channels will be first upsampled by repeating the existing channels. E.g.channels=[0, 1]
upsamples all mono files to stereo, andchannels=[1]
returns the second channel of all multi-channel files and all mono filesmixdown (
bool
) – apply mono mix-downsampling_rate (
Optional
[int
]) – sampling rate in Hz, one of8000
,16000
,22500
,44100
,48000
attachments (
Union
[str
,Sequence
[str
],None
]) – load only attachment files for the attachments matching the regular expression or provided in the list. If set to[]
no attachments are loadedtables (
Union
[str
,Sequence
[str
],None
]) – load only tables and misc tables matching the regular expression or provided in the list. Media files not referenced in the selected tables are automatically excluded, too. If set to[]
no tables and media files are loaded. Misc tables used in schemes are always loadedmedia (
Union
[str
,Sequence
[str
],None
]) – load only media files matching the regular expression or provided in the list. Excluded media files are automatically removed from the tables, too. This may result in empty tables. If set to[]
no media files are loaded and all tables except misc tables will be emptyremoved_media (
bool
) – keep rows that reference removed mediafull_path (
bool
) – replace relative with absolute file pathspickle_tables (
bool
) – ifTrue
, tables are cached locally in their original format and as pickle files. This allows for faster loading, when loading from cachecache_root (
Optional
[str
]) – cache folder where databases are stored. If not setaudb.default_cache_root()
is usednum_workers (
Optional
[int
]) – number of parallel jobs or 1 for sequential processing. IfNone
will be set to the number of processors on the machine multiplied by 5timeout (
float
) – maximum wait time if another thread or process is already accessing the database. If timeout is reached,None
is returned. If timeout < 0 the method will block until the database can be accessedverbose (
bool
) – show debug messages
- Return type
- Returns
database object
- Raises
ValueError – if attachment, table or media is requested that is not part of the database
ValueError – if a non-supported
bit_depth
,format
, orsampling_rate
is requestedRuntimeError – if a flavor is requested, but the database contains media files, that don’t contain audio, e.g. text files
Examples
>>> db = audb.load( ... "emodb", ... version="1.4.1", ... tables=["emotion", "files"], ... only_metadata=True, ... full_path=False, ... verbose=False, ... ) >>> list(db.tables) ['emotion', 'files']