(
waveform,
n_fft=400,
n_mel_channels=80,
target_sample_rate=24000,
hop_length=160,
win_length=400,
)
| 181 | return mel |
| 182 | |
| 183 | def get_conformer_mel_spectrogram( |
| 184 | waveform, |
| 185 | n_fft=400, |
| 186 | n_mel_channels=80, |
| 187 | target_sample_rate=24000, |
| 188 | hop_length=160, |
| 189 | win_length=400, |
| 190 | ): |
| 191 | mel_stft = torchaudio.transforms.MelSpectrogram( |
| 192 | sample_rate=target_sample_rate, |
| 193 | n_fft=n_fft, |
| 194 | win_length=win_length, |
| 195 | hop_length=hop_length, |
| 196 | n_mels=n_mel_channels, |
| 197 | power=1, |
| 198 | center=True, |
| 199 | normalized=False, |
| 200 | norm=None, |
| 201 | ).to(waveform.device) |
| 202 | if len(waveform.shape) == 3: |
| 203 | waveform = waveform.squeeze(1) # 'b 1 nw -> b nw' |
| 204 | |
| 205 | assert len(waveform.shape) == 2 |
| 206 | |
| 207 | mel = mel_stft(waveform) |
| 208 | mel = mel.clamp(min=1e-5).log() |
| 209 | return mel |
| 210 | |
| 211 | def get_whisper_mel_spectrogram( |
| 212 | waveform, |
nothing calls this directly
no outgoing calls
no test coverage detected