title: MFCC Python: completely different result from librosa vs python_speech_features vs tensorflow.signal
body: <p>I'm trying to do extract MFCC features from audio (.wav file) and I have tried <code>python_speech_features</code> and <code>librosa</code> but they are giving completely different results:</p>
  
  <pre><code>audio, sr = librosa.load(file, sr=None)
  
  # librosa
  hop_length = int(sr/100)
  n_fft = int(sr/40)
  features_librosa = librosa.feature.mfcc(audio, sr, n_mfcc=13, hop_length=hop_length, n_fft=n_fft)
  
  # psf
  features_psf = mfcc(audio, sr, numcep=13, winlen=0.025, winstep=0.01)
  </code></pre>
  
  <p>Below are the plots:</p>
  
  <p><strong>librosa</strong>:
  <a href="https://i.stack.imgur.com/q8YfI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/q8YfI.png" alt="enter image description here"></a></p>
  
  <p><strong>python_speech_features</strong>:
  <a href="https://i.stack.imgur.com/VW5j7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VW5j7.png" alt="enter image description here"></a></p>
  
  <p>Did I pass any parameters wrong for those two methods? Why there's such a huge difference here?</p>
  
  <p><strong>Update:</strong> I have also tried tensorflow.signal implementation, and here's the result:</p>
  
  <p><a href="https://i.stack.imgur.com/nvBcU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/nvBcU.png" alt="enter image description here"></a></p>
  
  <p>The plot itself matches closer to the one from librosa, but the scale is closer to python_speech_features. (Note that here I calculated 80 mel bins and took the first 13; if I do the calculation with only 13 bins, the result looks quite different as well). Code below:</p>
  
  <pre><code>stfts = tf.signal.stft(audio, frame_length=n_fft, frame_step=hop_length, fft_length=512)
  spectrograms = tf.abs(stfts)
  
  num_spectrogram_bins = stfts.shape[-1]
  lower_edge_hertz, upper_edge_hertz, num_mel_bins = 80.0, 7600.0, 80
  linear_to_mel_weight_matrix = tf.signal.linear_to_mel_weight_matrix(
      num_mel_bins, num_spectrogram_bins, sr, lower_edge_hertz, upper_edge_hertz)
  mel_spectrograms = tf.tensordot(spectrograms, linear_to_mel_weight_matrix, 1)
  mel_spectrograms.set_shape(spectrograms.shape[:-1].concatenate(linear_to_mel_weight_matrix.shape[-1:]))
  
  log_mel_spectrograms = tf.math.log(mel_spectrograms + 1e-6)
  features_tf = tf.signal.mfccs_from_log_mel_spectrograms(log_mel_spectrograms)[..., :13]
  features_tf = np.array(features_tf).T
  </code></pre>
  
  <p>I think my question is: <strong>which output is closer to what MFCC actually looks like?</strong></p>