# librosa.effects.trim¶

librosa.effects.trim(y, top_db=60, ref=<function amax>, frame_length=2048, hop_length=512)[source]

Trim leading and trailing silence from an audio signal.

Parameters: y : np.ndarray, shape=(n,) or (2,n) Audio signal, can be mono or stereo top_db : number > 0 The threshold (in decibels) below reference to consider as silence ref : number or callable The reference power. By default, it uses np.max and compares to the peak power in the signal. frame_length : int > 0 The number of samples per analysis frame hop_length : int > 0 The number of samples between analysis frames y_trimmed : np.ndarray, shape=(m,) or (2, m) The trimmed signal index : np.ndarray, shape=(2,) the interval of y corresponding to the non-silent region: y_trimmed = y[index[0]:index[1]] (for mono) or y_trimmed = y[:, index[0]:index[1]] (for stereo).

Examples

>>> # Load some audio