librosa.resample(y, *, orig_sr, target_sr, res_type='soxr_hq', fix=True, scale=False, axis=-1, **kwargs)[source]

Resample a time series from orig_sr to target_sr

By default, this uses a high-quality (but relatively slow) method (‘kaiser_best’) for band-limited sinc interpolation. The alternate res_type values listed below offer different trade-offs of speed and quality.

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

audio time series, with n samples along the specified axis.

orig_srnumber > 0 [scalar]

original sampling rate of y

target_srnumber > 0 [scalar]

target sampling rate

res_typestr (default: soxr_hq)

resample type

‘soxr_vhq’, ‘soxr_hq’, ‘soxr_mq’ or ‘soxr_lq’

soxr Very high-, High-, Medium-, Low-quality FFT-based bandlimited interpolation. 'soxr_hq' is the default setting of soxr.


soxr Quick cubic interpolation (very fast)


resampy high-quality mode


resampy faster method

‘fft’ or ‘scipy’

scipy.signal.resample Fourier method.


scipy.signal.resample_poly polyphase filtering. (fast)


samplerate linear interpolation. (very fast)


samplerate repeat the last value between samples. (very fast)

‘sinc_best’, ‘sinc_medium’ or ‘sinc_fastest’

samplerate high-, medium-, and low-quality sinc interpolation.


samplerate and resampy are not installed with librosa. To use samplerate or resampy, they should be installed manually:

$ pip install samplerate
$ pip install resampy


When using res_type='polyphase', only integer sampling rates are supported.


adjust the length of the resampled signal to be of size exactly ceil(target_sr * len(y) / orig_sr)


Scale the resampled signal so that y and y_hat have approximately equal total energy.


The target axis along which to resample. Defaults to the trailing axis.

**kwargsadditional keyword arguments

If fix==True, additional keyword arguments to pass to librosa.util.fix_length.

y_hatnp.ndarray [shape=(…, n * target_sr / orig_sr, …)]

y resampled from orig_sr to target_sr along the target axis


If res_type='polyphase' and orig_sr or target_sr are not both integer-valued.


This function caches at level 20.


Downsample from 22 KHz to 8 KHz

>>> y, sr = librosa.load(librosa.ex('trumpet'), sr=22050)
>>> y_8k = librosa.resample(y, orig_sr=sr, target_sr=8000)
>>> y.shape, y_8k.shape
((117601,), (42668,))