Skip to content

Instantly share code, notes, and snippets.

@vinay-hebb
Forked from manashmandal/mfcc.py
Created October 18, 2018 15:14
Show Gist options
  • Save vinay-hebb/5a1571a05a12cde1685f37867498e178 to your computer and use it in GitHub Desktop.
Save vinay-hebb/5a1571a05a12cde1685f37867498e178 to your computer and use it in GitHub Desktop.
import numpy as np
import librosa
def wav2mfcc(file_path, max_pad_len=11):
wave, sr = librosa.load(file_path, mono=True, sr=None)
wave = wave[::3]
mfcc = librosa.feature.mfcc(wave, sr=16000)
pad_width = max_pad_len - mfcc.shape[1]
mfcc = np.pad(mfcc, pad_width=((0, 0), (0, pad_width)), mode='constant')
return mfcc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment