I want to write a python script which takes the input as the image of the spectrogram and generates the audio from it. Is there a way to convert the image of spectrogram into corresponding audio ? I believe that there must be a way to reverse engineer the image of spectrogram to generate the audio. Can someone please help me with the same?
-
This idea probably won't be any fruitful. An image of a spectrogram is a very inefficient way of storing sound data. You can hear frequencies up to the order of > 10 kHz. That means to store that information you would need in the range of 10k pixels per second of sound. – user14325 Mar 16 '21 at 18:41
-
The spectrogram image which I have, is generated by concatenating the audio encoding and the speaker encoding outputs. Now I have an image which I want to convert into the audio. It doesn't matter how good or bad the audio sounds. I just need to convert it into audio. Is there a python script to do this ? The size of the image generated is around 128*128 and this is for 2-3 seconds of the audio. – Hitesh Kumar Mar 17 '21 at 09:22
-
Does this answer your question? [Can I convert spectrograms generated with librosa back to audio?](https://stackoverflow.com/questions/61132574/can-i-convert-spectrograms-generated-with-librosa-back-to-audio) – Lukasz Tracewski Mar 17 '21 at 11:10
-
Does this answer your question? [Creating wave data from FFT data?](https://stackoverflow.com/questions/56931834/creating-wave-data-from-fft-data) – Jon Nordby Mar 17 '21 at 20:42
-
The answers are corresponding to the features of the audio, what I need is image of spectrogram to audio. Help me with the same. – Hitesh Kumar Mar 18 '21 at 19:01
1 Answers
By a strange coincidence, I also needed to do this to recover audio for which only the spectrograms were available, but could find no tools to do this so wrote it myself in C. It's not simple and the results are, as user14325 rightly points out, very noisy compared to the originals, partly due to the low time resolution of most spectrograms but mostly because the phase information for each data point is lost and has to be invented.
However, if you are interested, you will find a brief description at https://wikidelia.net/wiki/Spectrograms#Inverse_spectrograms and you can find the code by following the "even hairier custom software" link and checking the files named "run.*" (the rest of the code there is for log-freq-axis forward spectrograms)

- 948
- 6
- 14