«Невозможно выделить ошибку памяти» при генерации спектрограмм
enter code here
import os
import wave
import matplotlib.pyplot as plt
импорт pylab как pylab
def graph_spectrogram (wav_file, sp):
sound_info, frame_rate = get_wav_info(wav_file)
plt.figure(num=None, figsize=(19, 12))
plt.subplot(111)
#pylab.title('spectrogram of %r' % wav_file)
plt.specgram(sound_info, Fs=frame_rate)
plt.axis('off')
plt.savefig(sp)
plt.rcParams.update({'figure.max_open_warning': 0})
def get_wav_info (wav_file):
wav = wave.open("C:\\fdata\\wavs\\speakers\\2ojo7YRL7Gck83Z3\\"+wav_file, 'r')
frames = wav.readframes(-1)
sound_info = pylab.fromstring(frames, 'Int16')
frame_rate = wav.getframerate()
wav.close()
return sound_info, frame_rate
ct = 0
для i в os.listdir (r "C: \ fdata \ wavs \ speaker \ 2ojo7YRL7Gck83Z3"):
save_path=r"C:\spect\s2"+i[:-4]+".png"
graph_spectrogram(i,save_path)
ct+=1
print(ct)