load_media()¶
- audb.load_media(name, media, *, version=None, bit_depth=None, channels=None, format=None, mixdown=False, sampling_rate=None, cache_root=None, num_workers=1, timeout=-1, verbose=True)[source]¶
Load media file(s).
If you are interested in media files and not the corresponding tables, you can use
audb.load_media()
to load them. This will not download any table files to your disk, but share the cache withaudb.load()
.- Parameters
name (
str
) – name of databasemedia (
str
|Sequence
[str
]) – load media files provided in the listchannels (
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
cache_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
paths to media files
- Raises
ValueError – if a media file is requested that is not part of the database
ValueError – if a non-supported
bit_depth
,format
, orsampling_rate
is requested
Examples
>>> paths = load_media( ... "emodb", ... ["wav/03a01Fa.wav"], ... version="1.4.1", ... format="flac", ... verbose=False, ... ) >>> paths[0].split(os.path.sep)[-5:] ['emodb', '1.4.1', '40bb2241', 'wav', '03a01Fa.flac']