I wrote a simple program to convert .wav to spectogram and save this as an png. Here you go:
import numpy as np
import matplotlib.pyplot as plt
import scipy.io.wavfile as wavfile
import os
import time as t
DATAPATH = 'dataset' #path
CATEGORIES = ['zero','one','two','three','four','five','six','seven','eight','nine']
for categorie in CATEGORIES:
path = DATAPATH + '/' + categorie + '/'
filenames = os.listdir(path) #get all filenames in categorie
print(categorie)
i = 0
for file in filenames[:100]:
start = t.time()
Fs, aud = wavfile.read(path + file)
powerSpectrum, frequenciesFound, time, imageAxis = plt.specgram(aud, Fs=Fs)
plt.subplots_adjust(left=0, right=1, bottom=0, top=1) #cut axis
plt.axis('off')
plt.savefig('pics/' + categorie + '/' + str(i) + '.png')
ende = t.time()
print(i, str(ende-start)+'s')
i += 1
The problem is that the time per image getiing higher and higher (only for a few milisekonds) but at the thousand pic it will be like 10sek per pic. Thats why I stopp the time and print it out. Some solutions?