I would like to know whether I am correct in my understanding of going from STFT to a spectrogram. My goal is to convert a spectrogram back to a wav file.
If I have my STFT:
audio, _ = librosa.load(f, sr=Fs)
stft = librosa.stft(samples, n_fft=NFFT, hop_length=HOP_LENGTH, win_length=window_length_samples)
and I wish to display a spectogram, I have to do:
spec = librosa.specshow(np.abs(stft))
However, since I have taken the modulus, it must be impossible to go from spec
back to audio
correct? So does that mean that librosa.istft
does NOT convert a spectrogram to a wav file? My confusion arises because I have seen many answers to "spec to wav" questions suggesting the use of librosa.istft
.
I am wishing to use a visual representation of audio that can be fed to a convolutional neural network, but still be converted back into audio. As an extension to the question, does anyone have experience using the stft
numpy array as the input to a CNN?