The code is a set of functions for recovering audio waveform from a spectrogram. It takes as input a predicted magnitude spectrogram, the ground truth complex spectrogram, the overlap size, and the window function used to create the spectrogram. It returns the recovered audio waveform.

The recover_wav function first recovers the complex spectrogram from the predicted magnitude spectrogram and the ground truth complex spectrogram, then recovers the whole spectrogram from the half spectrogram, and finally recovers the audio waveform from the whole spectrogram using the overlap-add procedure. If a specific length of waveform is required, it pads or truncates the output accordingly.

The real_to_complex function takes as input the predicted magnitude spectrogram and the ground truth complex spectrogram, and returns the complex spectrogram by replacing the phase of the ground truth with that of the predicted magnitude.

The half_to_whole function takes as input the half spectrogram and returns the whole spectrogram by concatenating it with its complex conjugate.

The ifft_to_wav function takes as input the whole spectrogram and returns the audio waveform by performing an inverse Fourier transform.

The pad_or_trunc function takes as input the recovered waveform and the desired length of the output waveform, and returns the waveform padded with zeros or truncated accordingly.

The recover_gt_wav function takes as input the ground truth complex spectrogram, the overlap size, and the window function, and returns the corresponding waveform using the same procedure as recover_wav.

The deframesig function performs the overlap-add procedure to recover the waveform from the frames. It takes as input the frames, the desired length of the output waveform, the frame length, the frame step, and the window function used to create the frames

import numpy as npimport numpyimport decimal def recover_wavpd_abs_x gt_x n_overlap winfunc wav_len=None Recover wave from spectrogram If you are using scipysignalspectrogram you may need to

原文地址: http://www.cveoy.top/t/topic/ck2z 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录