对Python使用mfcc的两种方式详解
1、Librosa
import librosa filepath = "/Users/birenjianmo/Desktop/learn/librosa/mp3/in.wav" y,sr = librosa.load(filepath) mfcc = librosa.feature.mfcc( y,sr,n_mfcc=13 )
返回结构为(13,None)的np.Array,None表示任意数量
2、python_speech_features
from python_speech_features import mfcc as pmfcc filepath = "/Users/birenjianmo/Desktop/learn/librosa/mp3/in.wav" (rate,sig) = wav.read(filepath) amfcc = pmfcc( sig, rate ).T
返回结构为(None,13)的np.Array,通过 .T 可转为(13,None)
3、这两种方式的mfcc还是有明显的区别的,上面两个子图是从(1)Librosa得到的 mfcc[0] 和 mfcc[1],下面的是(2)python_speech_features得到的 amfcc[0] 和 amfcc[1]