Answer the question
In order to leave comments, you need to log in
How to get an audio file from a power spectogram image?
Good afternoon. I am converting audio to picture with the following code without converting stft to absolute numbers so as not to lose data. As I understand it, I don’t lose anything at all, in order to restore the original sound, correct me if it’s wrong.
path = '/content/drive/MyDrive/originalputin/2.mp3.wav'
audio, sr = librosa.load(path)
print('length of the audio:',len(audio)/sr)
audio_stft = librosa.stft(audio)
audio_stft_db = librosa.power_to_db(audio_stft)
print('audio_stft.shape:',audio_stft.shape)
print('audio_stft_db.shape:',audio_stft_db.shape)
import matplotlib.pyplot as plt
import librosa.display
fig, ax = plt.subplots()
img = librosa.display.specshow(audio_stft_db, y_axis='log', x_axis='time', ax=ax)
ax.set_title('Power spectrogram')
fig.colorbar(img, ax=ax, format="%+2.0f dB")
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question