MFCC by librosa
import librosa
import librosa.display
# Generate mfccs from a time series
y, sr = librosa.load('0acdb43dae5a7a66945bc44ee87ee67cd64f4e9dabf2817ab59ffe8bf9093778.wav')
librosa.feature.mfcc(y=y, sr=sr)
# array([[ -5.229e+02, -4.944e+02, ..., -5.229e+02, -5.229e+02],
# [ 7.105e-15, 3.787e+01, ..., -7.105e-15, -7.105e-15],
# ...,
# [ 1.066e-14, -7.500e+00, ..., 1.421e-14, 1.421e-14],
# [ 3.109e-14, -5.058e+00, ..., 2.931e-14, 2.931e-14]])
# Use a pre-computed log-power Mel spectrogram
S = librosa.feature.melspectrogram(y=y, sr=sr, n_mels=128,
fmax=8000)
librosa.feature.mfcc(S=librosa.power_to_db(S))
# array([[ -5.207e+02, -4.898e+02, ..., -5.207e+02, -5.207e+02],
# [ -2.576e-14, 4.054e+01, ..., -3.997e-14, -3.997e-14],
# ...,
# [ 7.105e-15, -3.534e+00, ..., 0.000e+00, 0.000e+00],
# [ 3.020e-14, -2.613e+00, ..., 3.553e-14, 3.553e-14]])
# Get more components
mfccs = librosa.feature.mfcc(y=y, sr=sr, n_mfcc=40)
# Visualize the MFCC series
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(4, 4))
librosa.display.specshow(mfccs)
#plt.colorbar()
#plt.title('MFCC')
plt.tight_layout()
fig.savefig('test.png')
plt.show()
# save png using pylab
#fig= plt.figure()

import librosa
답글삭제import librosa.display
y, sr = librosa.load('0acdb43dae5a7a66945bc44ee87ee67cd64f4e9dabf2817ab59ffe8bf9093778.wav')
librosa.feature.mfcc(y=y, sr=sr)
S = librosa.feature.melspectrogram(y=y, sr=sr, n_mels=128,
fmax=8000)
librosa.feature.mfcc(S=librosa.power_to_db(S))
mfccs = librosa.feature.mfcc(y=y, sr=sr, n_mfcc=40)
# Visualize the MFCC series
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(4, 4))
librosa.display.specshow(mfccs)
plt.tight_layout(pad=0.0, w_pad=0.0, h_pad=0.0)
fig.savefig('test.png')
plt.show()