1

I try to plot the mfcc features of a sound in matplotlib. Unfortunately I am not able to plot only the first 0.54 s. It seems like that the plot fixed to 2 s. How can I change that?

import matplotlib.pyplot as plt
import librosa
import librosa.display
import numpy as np

'#1.Step: Create data for the plot'
 data = np.array([[-537., -504., -439., -388., -405., -459., -369., -294., -278.,
    -292., -307., -344., -392., -407., -402., -381., -366., -327.,
    -301., -298., -306., -297., -297., -320., -344., -360., -374.,
    -415., -466., -498., -516., -560., -689., -768., -768., -768.,
    -768., -768., -768., -768., -768., -768., -768., -768., -768.,
    -768., -768., -768., -768., -768., -768., -768., -768., -768.,
    -768., -768., -768., -768., -768., -768., -768., -768., -768.,
    -768., -768., -768., -768., -768., -768., -768., -768., -768.,
    -768., -768., -768., -768., -768., -768., -768., -768., -768.,
    -768., -768., -768., -768., -768., -768., -768.],
   [  43.,   43.,   30.,   10.,    2.,   48.,  182.,  194.,  169.,
     142.,  142.,  138.,  138.,  146.,  150.,  135.,  115.,  117.,
     127.,  131.,  135.,  148.,  149.,  145.,  150.,  162.,  170.,
     146.,   91.,   65.,   68.,   63.,   39.,    0.,    0.,    0.,
       0.,    0.,    0.,    0.,    0.,    0.,    0.,    0.,    0.,
       0.,    0.,    0.,    0.,    0.,    0.,    0.,    0.,    0.,
       0.,    0.,    0.,    0.,    0.,    0.,    0.,    0.,    0.,
       0.,    0.,    0.,    0.,    0.,    0.,    0.,    0.,    0.,
       0.,    0.,    0.,    0.,    0.,    0.,    0.,    0.,    0.,
       0.,    0.,    0.,    0.,    0.,    0.,    0.],
   [ -13.,    8.,   13.,  -21.,  -41.,  -17.,  -23.,  -57.,  -83.,
     -95.,  -82.,  -59.,  -30.,  -23.,  -25.,  -36.,  -43.,  -65.,
     -87.,  -99.,  -96.,  -95.,  -95.,  -86.,  -71.,  -53.,  -41.,
     -25.,  -25.,  -38.,  -33.,  -28.,   -9.,    0.,    0.,    0.,
       0.,    0.,    0.,    0.,    0.,    0.,    0.,    0.,    0.,
       0.,    0.,    0.,    0.,    0.,    0.,    0.,    0.,    0.,
       0.,    0.,    0.,    0.,    0.,    0.,    0.,    0.,    0.,
       0.,    0.,    0.,    0.,    0.,    0.,    0.,    0.,    0.,
       0.,    0.,    0.,    0.,    0.,    0.,    0.,    0.,    0.,
       0.,    0.,    0.,    0.,    0.,    0.,    0.],
   ])
'#2.Step: Configure the plot'
plt.figure(figsize=(10, 6))
plt.subplot(2, 1, 1)
'#3.Step: Display the data'
librosa.display.specshow(data, x_axis='time')
plt.title('MFCC')
plt.colorbar()

enter image description here

Diziet Asahi
  • 38,379
  • 7
  • 60
  • 75
user8495738
  • 147
  • 1
  • 3
  • 14

0 Answers0