def create_spectrogram_from_audio(data):
global setting
spectrogram = librosa.stft(data, n_fft=Config.n_fft, hop_length=Config.hop_length).transpose()
# divide the real and imaginary components of each element
# concatenate the matrix with the real components and the matrix with imaginary components
# (DataCorruptionError when saving complex numbers in TFRecords)
# concatenated = np.concatenate([np.real(spectrogram), np.imag(spectrogram)], axis=1)
return spectrogram # [num_time_frames, num_freq_bins]
评论列表
文章目录