MCPcopy Create free account
hub / github.com/ASLP-lab/SenSE / get_conformer_mel_spectrogram

Function get_conformer_mel_spectrogram

src/sense/model/modules.py:183–209  ·  view source on GitHub ↗
(
    waveform,
    n_fft=400,
    n_mel_channels=80,
    target_sample_rate=24000,
    hop_length=160,
    win_length=400,
)

Source from the content-addressed store, hash-verified

181 return mel
182
183def 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
211def get_whisper_mel_spectrogram(
212 waveform,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected