Save a matrix to Image and then extract the same matrix from Image

9 views (last 30 days)
Fareed Jamali
Fareed Jamali on 28 May 2021
Greetings everyone.
Above is the link from which I am trying to implement a process. I want to convert stft magnitude of audio to spectrogram and from the spectrogram, I want to regenerate the stft magnitude of audio. Saving the stft magnitude of audio in the spectrogram is easy through imwrite command but I can not recreate the same matrix when I try to convert the spectrogram back to audio. Not sure where I am missing some crucial information that is required to implement this process. Attaching the audio2 file for reference. Audio is attached as a zip file due to file sharing format restrictions. Any help will be highly appreciated.
clear all
close all
clc
[y,Fs]=audioread('audio2.wav');
sound(y,Fs) %To hear the sound
ty = (0:length(y)-1)/Fs;
wind = hamming(128);
olen = 64;
nfft = 1024;
stft(y,Fs,'Window',wind,'OverlapLength',olen,'FFTLength',nfft);
s=stft(y,Fs,'Window',wind,'OverlapLength',olen,'FFTLength',nfft);
smag=abs(s);
sphs=angle(s);
imwrite(smag,'FigureNew',jpg);
imshow(smag);

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!