iSTFTNet-pytorch icon indicating copy to clipboard operation
iSTFTNet-pytorch copied to clipboard

Single frequency line problem

Open mayfool opened this issue 2 years ago • 14 comments

Thanks for the implemention of ISTFT. It has better inference speed than hifigan v1.However, I found that there is a single frequency line which would cause little noise.I use 16KHZ dataset for training.And all the line is extractly at 4k which is the middle of the all frequency.I'm trying to fix this problem, do you have the same problem?

mayfool avatar Apr 07 '22 01:04 mayfool

yes I also saw that line but it won't impact my quality

rishikksh20 avatar Apr 12 '22 12:04 rishikksh20

Hi @mayfool, can you show the mel-spectrogram image which has a single frequency line ?

leminhnguyen avatar Apr 18 '22 05:04 leminhnguyen

Hi @mayfool, can you show the mel-spectrogram image which has a single frequency line ?

All synthesised wavs have single frequency line. Not few of them. So I think it has no matter with input mels.

mayfool avatar Apr 24 '22 02:04 mayfool

Hi @mayfool, can you show the mel-spectrogram image which has a single frequency line ?

All synthesised wavs have single frequency line. Not few of them. So I think it has no matter with input mels.

@mayfool have you solved this problem now?

xiaoyangnihao avatar Jul 05 '22 02:07 xiaoyangnihao

Hi @mayfool, can you show the mel-spectrogram image which has a single frequency line ?

All synthesised wavs have single frequency line. Not few of them. So I think it has no matter with input mels.

@mayfool have you solved this problem now?

@xiaoyangnihao Nope..

mayfool avatar Jul 07 '22 01:07 mayfool

I implemented the code for any number of upsampling, and it seems that the problem with the single line frequency (which, by the way, lies in the region of 5500 Hz, that is, half of the fmax at a sample rate of 22050 Hz) is observed specifically for the configuration C8C8I.

Below is a comparison of C8C8I and C8C8C2I

Screenshot from 2022-07-12 12-13-41 Screenshot from 2022-07-12 12-13-16

Dekakhrone avatar Jul 12 '22 09:07 Dekakhrone

I also encountered this problem. I set the sample rate to 48k, the horizontal line appears at 12k HZ (half of the fmax 24k HZ).

jstzwj avatar Nov 28 '22 08:11 jstzwj

I encountered this problem too.

leng-yue avatar Feb 22 '23 22:02 leng-yue

I have trained a model with 100k steps, it sounds good, but looking into the generated spec, it seems to make no sense.
Looking at the generated spec, we can find the highlight in 2k and 6k Hz, which do not exist in the input mel, even not in the mel re-calc from the generated audio. Comparing the two specs, we can say, that even it can be converted to audio by istft, the model output is actually NOT spectrum.
Moreover, run ifft and de-window for the generated spec, it generates the audio frames with length 16. For sil, the beginning 100 frames look very similar, thus, followed with the overlap-and-add method, just the same signal added with 4 samples moving behind. And that's it, the 4k Hz signal.

I think adding spec loss directly to the generated spec may be a good idea to improve the quality and to solve this question. I will train a new model to see what will happen. image

ease-zh avatar Dec 25 '23 09:12 ease-zh

Yet I have trained a model with linear spec loss for 100k steps, the 4k Hz signal is gone. Since I randomly selected the sample to syn, I cannot find the exact sample that was used for the aforementioned plot. So I re-plot the figure with a new sample. Looking at the figure with spec loss, the generated spec looks to make sense, the 4k line was gone, and the waveform for the beginning silence is not always the same. Now everything looks all right. image image

I have trained a model with 100k steps, it sounds good, but looking into the generated spec, it seems to make no sense. Looking at the generated spec, we can find the highlight in 2k and 6k Hz, which do not exist in the input mel, even not in the mel re-calc from the generated audio. Comparing the two specs, we can say, that even it can be converted to audio by istft, the model output is actually NOT spectrum. Moreover, run ifft and de-window for the generated spec, it generates the audio frames with length 16. For sil, the beginning 100 frames look very similar, thus, followed with the overlap-and-add method, just the same signal added with 4 samples moving behind. And that's it, the 4k Hz signal.

I think adding spec loss directly to the generated spec may be a good idea to improve the quality and to solve this question. I will train a new model to see what will happen. image

ease-zh avatar Jan 02 '24 05:01 ease-zh

@ease-zh what changes you have made to this repo to achieve that ?

rishikksh20 avatar Jan 02 '24 10:01 rishikksh20

@ease-zh what changes you have made to this repo to achieve that ?

Just a l1 loss for the generated linear spec, loss_spec = F.l1_loss(y_spec, spec) * 45. However, after careful comparison, I found that the spec loss harms the audio quality.
Maybe changing the loss formula or tuning the loss weight can further improve the quality. Do you have more suggestions?

By the way, I think using reflection_pad before the conv_post seems to make less sense, although it did work. I guess here is to justify the length so that torch.istft will give the exact samples as used to calculate the mel? But the difference is caused by that torch.istft only supports center mode, while calculating the mel, we manually pad the wav, and set center=False for torch.stft. This may not affect the final synthesis, and I will give it a try later.

ease-zh avatar Jan 03 '24 07:01 ease-zh

@ease-zh what changes you have made to this repo to achieve that ?

Just a l1 loss for the generated linear spec, loss_spec = F.l1_loss(y_spec, spec) * 45. However, after careful comparison, I found that the spec loss harms the audio quality. Maybe changing the loss formula or tuning the loss weight can further improve the quality. Do you have more suggestions?

By the way, I think using reflection_pad before the conv_post seems to make less sense, although it did work. I guess here is to justify the length so that torch.istft will give the exact samples as used to calculate the mel? But the difference is caused by that torch.istft only supports center mode, while calculating the mel, we manually pad the wav, and set center=False for torch.stft. This may not affect the final synthesis, and I will give it a try later.

then? have you tried?

a897456 avatar Feb 29 '24 11:02 a897456

@a897456 Not yet. I've been busy with something else.

ease-zh avatar Mar 06 '24 03:03 ease-zh