<p>Yes, it is possible to recover most of the signal and estimate the phase with e.g. Griffin-Lim Algorithm (GLA). Its "fast" implementation for Python can be found in <a href="https://librosa.github.io/librosa/generated/librosa.core.griffinlim.html" rel="noreferrer">librosa</a>. Here's how you can use it:</p>

<pre><code>import numpy as np
import librosa

y, sr = librosa.load(librosa.util.example_audio_file(), duration=10)
S = np.abs(librosa.stft(y))
y_inv = librosa.griffinlim(S)
</code></pre>

<p>And that's how the original and reconstruction look like:</p>

<p><a href="https://i.stack.imgur.com/DdNk7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/DdNk7.png" alt="reconstruction"></a></p>

<p>The algorithm by default randomly initialises the phases and then iterates forward and inverse STFT operations to estimate the phases.</p>

<p>Looking at your code, to reconstruct the signal, you'd just need to do:</p>

<pre><code>import numpy as np

X_inv = librosa.griffinlim(np.abs(X))
</code></pre>

<p>It's just an example of course. As pointed out by @PaulR, in your case you'd need to load the data from <code>jpeg</code> (which is lossy!) and then apply inverse transform to <code>amplitude_to_db</code> first.</p>

<p>The algorithm, especially the phase estimation, can be further improved thanks to advances in artificial neural networks. <a href="https://arxiv.org/abs/1903.03971" rel="noreferrer">Here</a> is one paper that discusses some enhancements. </p>
Can I convert spectrograms generated with librosa back to audio?
<p>I converted some audio files to spectrograms and saved them to files using the following code:</p>

<pre><code>import os
from matplotlib import pyplot as plt
import librosa
import librosa.display
import IPython.display as ipd

audio_fpath = "./audios/"
spectrograms_path = "./spectrograms/"
audio_clips = os.listdir(audio_fpath)

def generate_spectrogram(x, sr, save_name):
    X = librosa.stft(x)
    Xdb = librosa.amplitude_to_db(abs(X))
    fig = plt.figure(figsize=(20, 20), dpi=1000, frameon=False)
    ax = fig.add_axes([0, 0, 1, 1], frameon=False)
    ax.axis('off')
    librosa.display.specshow(Xdb, sr=sr, cmap='gray', x_axis='time', y_axis='hz')
    plt.savefig(save_name, quality=100, bbox_inches=0, pad_inches=0)
    librosa.cache.clear()

for i in audio_clips:
    audio_fpath = "./audios/"
    spectrograms_path = "./spectrograms/"
    audio_length = librosa.get_duration(filename=audio_fpath + i)
    j=60
    while j &lt; audio_length:
        x, sr = librosa.load(audio_fpath + i, offset=j-60, duration=60)
        save_name = spectrograms_path + i + str(j) + ".jpg"
        generate_spectrogram(x, sr, save_name)
        j += 60
        if j &gt;= audio_length:
            j = audio_length
            x, sr = librosa.load(audio_fpath + i, offset=j-60, duration=60)
            save_name = spectrograms_path + i + str(j) + ".jpg"
            generate_spectrogram(x, sr, save_name)
</code></pre>

<p>I wanted to keep the most detail and quality from the audios, so that i could turn them back to audio without too much loss (They are 80MB each).</p>

<p>Is it possible to turn them back to audio files? How can I do it?</p>

<p><a href="https://i.stack.imgur.com/hmvBJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/hmvBJ.png" alt="Example spectrograms"></a></p>

<p>I tried using librosa.feature.inverse.mel_to_audio, but it didn't work, and I don't think it applies.</p>

<p>I now have 1300 spectrogram files and want to train a Generative Adversarial Network with them, so that I can generate new audios, but I don't want to do it if i wont be able to listen to the results later.</p>