deep-clustering icon indicating copy to clipboard operation
deep-clustering copied to clipboard

how can i fix the following errors? -- audio_test.py

Open DYJ1111 opened this issue 6 years ago • 5 comments

frame_out1 = np.fft.ifft(out1).astype(np.float64)

Error: ComplexWarning: Casting complex values to real discards the imaginary part frame_out1 = np.fft.ifft(out1.real).astype(np.float64)

DYJ1111 avatar Jan 06 '19 10:01 DYJ1111

The error is due to your version of numpy doesn't allow casting the type from complex number(the output of the IFFT) to float64(the time domain signal).

Actually the output of the ifft should be pure real number given the input is conjugate symmetric, but the imaginary part will not strictly equal to zero due to the computational accuracy. So you can try discarding the imaginary part first, something like frame_out1 = np.fft.ifft(out1).real().astype(np.float64).

zhr1201 avatar Jan 08 '19 01:01 zhr1201

The error is due to your version of numpy doesn't allow casting the type from complex number(the output of the IFFT) to float64(the time domain signal).

Actually the output of the ifft should be pure real number given the input is conjugate symmetric, but the imaginary part will not strictly equal to zero due to the computational accuracy. So you can try discarding the imaginary part first, something like frame_out1 = np.fft.ifft(out1).real().astype(np.float64).

yeah, I have fixed this problem by using your advise. But why I meet another problem that the reconstructed audio can't play.

DYJ1111 avatar Jan 08 '19 02:01 DYJ1111

You can check the values of the output audio data array to see if it is legit. If not, probably sth. in the model went wrong. If it is legit, then sth. went wrong when you trying to write data into the audio file

zhr1201 avatar Jan 16 '19 03:01 zhr1201

frame_out1 = np.fft.ifft(out1).astype(np.float64) Error: ComplexWarning: Casting complex values to real discards the imaginary part frame_out1 = np.fft.ifft(out1.real).astype(np.float64)

May I ask that what did you do to solve the problem which the reconstructed audio can not play?

JayYang-Fdu avatar Apr 09 '19 13:04 JayYang-Fdu

frame_out1 = np.fft.ifft(out1).astype(np.float64) Error: ComplexWarning: Casting complex values to real discards the imaginary part frame_out1 = np.fft.ifft(out1.real).astype(np.float64)

May I ask that what did you do to solve the problem which the reconstructed audio can not play?

frame_out1 = np.fft.irfft(out_stft1).real.astype(np.float32)

DYJ1111 avatar Apr 09 '19 15:04 DYJ1111