Wednesday, 19 June 2019

differance between output of python librosa.core.stft() and matlab spectrogram(x)

I am converting a python code to MATLAB. The python code, uses the following command:

stft_ch = librosa.core.stft(audio_input[:, ch_cnt], n_fft=self._nfft, hop_length=self._hop_len,win_length=self._win_len, window='hann')

Where audio_input.shape=(2880000,4),self._nfft=2048, self._hop_len=960 and self._win_len=1920. When converting to MATLAB I used:

stft_ch = spectrogram(audio_input(:, ch_cnt), hann(win_len), win_len-hop_len, nfft);

where I verified size(audio_input)=2880000,4, win_len=1920, win_len-hop_len=960and nfft=2048.

I am getting an output with size(stft_ch)=1025,2999 where the python shows stft_ch.shape=(1025, 3001) the 2999 size of the MATLAB output is clear and feats the documentation where k = ⌊(Nx – noverlap)/(length(window) – noverlap)⌋ if window is a vector.

However, I could not find in the python documentation how is the legth of t set.

Why is there a difference between sizes? Is my conversion good?

Is there a python function which produces an output more similar to MATLABs' spectrogram() so that I can get the complex output with the same size?



from differance between output of python librosa.core.stft() and matlab spectrogram(x)

No comments:

Post a Comment