title: MFCC feature descriptors for audio classification using librosa
body: <p>I am trying to obtain single vector feature representations for audio files to use in a machine learning task (specifically, classification using a neural net). I have experience in computer vision and natural language processing, but I need some help getting up to speed with audio files.</p>
  
  <p>There are a variety of feature descriptors for audio files out there, but it seems that MFCCs are used the most for audio classification tasks. My question is this: how do I take the MFCC representation for an audio file, which is usually a matrix (of coefficients, presumably), and turn it into a single feature vector? I am currently using <a href="http://bmcfee.github.io/librosa/" rel="noreferrer">librosa</a> for this.</p>
  
  <p>I have a bunch of audio files, but they all vary in their shape:</p>
  
  <pre><code>for filename in os.listdir('data'):
      y, sr = librosa.load('data/' + filename)
      print filename, librosa.feature.mfcc(y=y, sr=sr).shape
  
  213493.ogg (20, 2375)
  120093.ogg (20, 7506)
  174576.ogg (20, 2482)
  194439.ogg (20, 14)
  107936.ogg (20, 2259)
  </code></pre>
  
  <p>What I would do as a CV person is quantize these coefficients by doing k-means and then use something like <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.vq.vq.html#scipy.cluster.vq.vq" rel="noreferrer">scipy.cluster.vq</a> to get vectors of identical shape that I can use as input to my NN. Is this what you would do in the audio case as well, or are there different/better approaches to this problem?</p>