librosa.load(path, *, sr=22050, mono=True, offset=0.0, duration=None, dtype=<class 'numpy.float32'>, res_type='soxr_hq')[source]

Load an audio file as a floating point time series.

Audio will be automatically resampled to the given rate (default sr=22050).

To preserve the native sampling rate of the file, use sr=None.

pathstring, int, pathlib.Path, soundfile.SoundFile, audioread object, or file-like object

path to the input file.

Any codec supported by soundfile or audioread will work.

Any string file paths, or any object implementing Python’s file interface (e.g. pathlib.Path) are supported as path.

If the codec is supported by soundfile, then path can also be an open file descriptor (int) or an existing soundfile.SoundFile object.

Pre-constructed audioread decoders are also supported here, see the example below. This can be used, for example, to force a specific decoder rather than relying upon audioread to select one for you.


audioread support is deprecated as of version 0.10.0. audioread support be removed in version 1.0.

srnumber > 0 [scalar]

target sampling rate

‘None’ uses the native sampling rate


convert signal to mono


start reading after this time (in seconds)


only load up to this much audio (in seconds)

dtypenumeric type

data type of y


resample type (see note)


By default, this uses soxr’s high-quality mode (‘HQ’).

For alternative resampling modes, see resample


audioread may truncate the precision of the audio data to 16 bits.

See Advanced I/O Use Cases for alternate loading methods.

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

audio time series. Multi-channel is supported.

srnumber > 0 [scalar]

sampling rate of y


>>> # Load an ogg vorbis file
>>> filename = librosa.ex('trumpet')
>>> y, sr = librosa.load(filename)
>>> y
array([-1.407e-03, -4.461e-04, ..., -3.042e-05,  1.277e-05],
>>> sr
>>> # Load a file and resample to 11 KHz
>>> filename = librosa.ex('trumpet')
>>> y, sr = librosa.load(filename, sr=11025)
>>> y
array([-8.746e-04, -3.363e-04, ..., -1.301e-05,  0.000e+00],
>>> sr
>>> # Load 5 seconds of a file, starting 15 seconds in
>>> filename = librosa.ex('brahms')
>>> y, sr = librosa.load(filename, offset=15.0, duration=5.0)
>>> y
array([0.146, 0.144, ..., 0.128, 0.015], dtype=float32)
>>> sr
>>> # Load using an already open SoundFile object
>>> import soundfile
>>> sfo = soundfile.SoundFile(librosa.ex('brahms'))
>>> y, sr = librosa.load(sfo)
>>> # Load using an already open audioread object
>>> import audioread.ffdec  # Use ffmpeg decoder
>>> aro = audioread.ffdec.FFmpegAudioFile(librosa.ex('brahms'))
>>> y, sr = librosa.load(aro)