ruizhecao96 / CMGAN

Conformer-based Metric GAN for speech enhancement
MIT License
309 stars 60 forks source link

RuntimeError #31

Closed omtrix closed 1 year ago

omtrix commented 1 year ago

i dont want to change my pytorch version ,so i set "return_complex=False" in torch.stft() but i got error while running torch.istft(),the problrm just like below:

/home/tewt/anaconda3/envs/hyj_test/lib/python3.9/site-packages/torch/functional.py:641: UserWarning: stft with return_complex=False is deprecated. In a future pytorch release, stft will return complex tensors for all inputs, and return_complex=False will raise an error. Note: you can still call torch.view_as_real on the complex output to recover the old return format. (Triggered internally at ../aten/src/ATen/native/SpectralOps.cpp:862.) return _VF.stft(input, n_fft, hop_length, win_length, window, # type: ignore[attr-defined] Traceback (most recent call last): File "/home/tewt/Desktop/hyj_projects/CMGAN/src/hyj_test2.py", line 53, in est_audio = torch.istft(est_spec_uncompress, n_fft, hop, window=torch.hamming_window(n_fft).cuda(), RuntimeError: istft requires a complex-valued input tensor matching the output from stft with return_complex=True.

can anyone give some suggestions?

omtrix commented 1 year ago

btw,my torch.version is '2.0.1+cu117'

SherifAbdulatif commented 1 year ago

Maybe this can help: est_spec_uncompress = torch.stft(audio, n_fft, hop_length, win_length, window, return_complex=True) est_spec_real_imag = torch.view_as_real(est_spec_uncompress) est_audio = torch.istft(est_spec_uncompress, n_fft, hop, window=torch.hamming_window(n_fft)

However, you can have a separate virtual environment to install the specified torch version in the requirements and recheck.