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 with audb.load().

Parameters
  • name (str) – name of database

  • media (str | Sequence[str]) – load media files provided in the list

  • version (Optional[str]) – version of database

  • bit_depth (Optional[int]) – bit depth, one of 16, 24, 32

  • channels (Union[int, Sequence[int], None]) – channel selection, see audresample.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, and channels=[1] returns the second channel of all multi-channel files and all mono files

  • format (Optional[str]) – file format, one of 'flac', 'wav'

  • mixdown (bool) – apply mono mix-down

  • sampling_rate (Optional[int]) – sampling rate in Hz, one of 8000, 16000, 22500, 44100, 48000

  • cache_root (Optional[str]) – cache folder where databases are stored. If not set audb.default_cache_root() is used

  • num_workers (Optional[int]) – number of parallel jobs or 1 for sequential processing. If None will be set to the number of processors on the machine multiplied by 5

  • timeout (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 accessed

  • verbose (bool) – show debug messages

Return type

Optional[list]

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, or sampling_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']