Caution

You're reading the documentation for a development version. For the latest released version, please have a look at 0.11.0.

librosa.loadx

librosa.loadx(key, *, hq=None, **kwargs)[source]

Load an example audio file by key.

This is a wrapper around librosa.util.example that provides the same functionality as load, but with the convenience of loading from the built-in examples.

Note

This function is primarily useful for demonstration purposes, and to make documentation examples more concise. For general-purpose loading of audio files, use load instead.

Parameters:
keystr

The identifier for the track to load

hqbool, optional

If True, return the high-quality version of the recording. If False, return the 22KHz mono version of the recording.

If not provided, hq is inferred based on additional parameters in kwargs:
  • If sr is provided and greater than 22050 (or is None), then hq is set to True.

  • If mono is provided and set to False, then hq is set to True.

  • Otherwise, hq is set to False.

**kwargsadditional keyword arguments

Additional keyword arguments to pass to load

Returns:
ynp.ndarray [shape=(n,) or (…, n)]

audio time series. Multi-channel is supported.

srnumber > 0 [scalar]

sampling rate of y

Examples

Load the default version of the ‘trumpet’ example

>>> y, sr = librosa.loadx('trumpet')

Load the stereo version of the ‘trumpet’ example

>>> y, sr = librosa.loadx('trumpet', mono=False)
>>> # This is equivalent to the following more verbose code:
>>> y, sr = librosa.load(librosa.ex('trumpet', hq=True), mono=False)