Waveform to spectrogram. Args: input: (batch_size, segment_samples, channels_num) Outputs: output: (batch_size, channels_num, time_steps, freq_bins)
(self, input, eps=1e-10)
| 89 | |
| 90 | |
| 91 | def wav_to_spectrogram_phase(self, input, eps=1e-10): |
| 92 | """Waveform to spectrogram. |
| 93 | |
| 94 | Args: |
| 95 | input: (batch_size, segment_samples, channels_num) |
| 96 | |
| 97 | Outputs: |
| 98 | output: (batch_size, channels_num, time_steps, freq_bins) |
| 99 | """ |
| 100 | sp_list = [] |
| 101 | cos_list = [] |
| 102 | sin_list = [] |
| 103 | channels_num = input.shape[1] |
| 104 | for channel in range(channels_num): |
| 105 | mag, cos, sin = self.spectrogram_phase(input[:, channel, :], eps=eps) |
| 106 | sp_list.append(mag) |
| 107 | cos_list.append(cos) |
| 108 | sin_list.append(sin) |
| 109 | |
| 110 | sps = torch.cat(sp_list, dim=1) |
| 111 | coss = torch.cat(cos_list, dim=1) |
| 112 | sins = torch.cat(sin_list, dim=1) |
| 113 | return sps, coss, sins |
| 114 | |
| 115 | def wav_to_spectrogram(self, input, eps=0.): |
| 116 | """Waveform to spectrogram. |
no test coverage detected