0

I am doing my final year project of genre classification. For that I need to extract spectogram of multiple files. I know how to extract the spectogram of single audio, but i need spectogram for every audio file.

My for loop code is:

#display Spectrogram
for file in range(0,len(audio_path),1):

    X = librosa.stft(x)
    Xdb = librosa.amplitude_to_db(abs(X))
    plt.figure(figsize=(14, 5))
    librosa.display.specshow(Xdb, sr=sr, x_axis='time', y_axis='hz') 
    #If to pring log of frequencies  
    #librosa.display.specshow(Xdb, sr=sr, x_axis='time', y_axis='log')
    plt.colorbar()

Any help would be appreciated! Thanks.

desertnaut
  • 57,590
  • 26
  • 140
  • 166

1 Answers1

0

This answer has example code on how to do this, including using multiple CPU cores to speed it up.

Jon Nordby
  • 5,494
  • 1
  • 21
  • 50