def plot_specgrams(base_dir=CHART_DIR):
 plt.clf()
 genres = ['classical', 'jazz', 'country', 'pop', 'rock', 'metal']
 num_files = 3
 (f, axes) = plt.subplots(len(genres), num_files)
 for (genre_idx, genre) in enumerate(genres):
  for (idx, fn) in enumerate(glob.glob(os.path.join(GENRE_DIR, genre, '*.wav'))):
   if (idx == num_files):
    break
   axis = axes[(genre_idx, idx)]
   axis.yaxis.set_major_formatter(EngFormatter())
   axis.set_title(('%s song %i' % (genre, (idx + 1))))
   plot_specgram(axis, fn)
 specgram_file = os.path.join(base_dir, 'Spectrogram_Genres.png')
 plt.savefig(specgram_file, bbox_inches='tight')
 plt.show()

def plot_specgrams ( base_dir = CHART_DIR ) : plt . clf ( ) genres = [ 'classical' , 'jazz' , 'country' , 'pop' , 'rock' , 'metal' ] num_files = 3 ( f , axes ) = plt . subplots ( len ( genres ) , num_files ) for ( genre_idx , genre ) in enumerate ( genres ) : for ( idx , fn ) in enumerate ( glob . glob ( os . path . join ( GENRE_DIR , genre , '*.wav' ) ) ) : if ( idx == num_files ) : break axis = axes [ ( genre_idx , idx ) ] axis . yaxis . set_major_formatter ( EngFormatter ( ) ) axis . set_title ( ( '%s song %i' % ( genre , ( idx + 1 ) ) ) ) plot_specgram ( axis , fn ) specgram_file = os . path . join ( base_dir , 'Spectrogram_Genres.png' ) plt . savefig ( specgram_file , bbox_inches = 'tight' ) plt . show ( )
plot a bunch of spectrograms of wav files in different genres .