def get_mfcc(x, sr, n_mfcc=20):
"""Compute MFCC features from raw audio, using librosa.
Librosa must be installed.
Args:
x (1d-array) audio signal, mono
sr (int): sample rate
n_mfcc (int): number of coefficients to retain
Returns:
2d-array: MFCC features
"""
mfcc_all = librosa.feature.mfcc(x, sr)
n_coeff, n_frames = mfcc_all.shape
t = librosa.frames_to_time(np.arange(n_frames), sr=sr, hop_length=512)
return t, mfcc_all[:n_mfcc].T
评论列表
文章目录