mirror of
https://github.com/openai/whisper.git
synced 2025-11-29 08:28:53 +00:00
Support batch-dimension in log_mel_spectogram (#839)
This commit is contained in:
parent
70861c7ce3
commit
6df3ea1fb5
@ -113,7 +113,7 @@ def log_mel_spectrogram(audio: Union[str, np.ndarray, torch.Tensor], n_mels: int
|
|||||||
|
|
||||||
window = torch.hann_window(N_FFT).to(audio.device)
|
window = torch.hann_window(N_FFT).to(audio.device)
|
||||||
stft = torch.stft(audio, N_FFT, HOP_LENGTH, window=window, return_complex=True)
|
stft = torch.stft(audio, N_FFT, HOP_LENGTH, window=window, return_complex=True)
|
||||||
magnitudes = stft[:, :-1].abs() ** 2
|
magnitudes = stft[..., :-1].abs() ** 2
|
||||||
|
|
||||||
filters = mel_filters(audio.device, n_mels)
|
filters = mel_filters(audio.device, n_mels)
|
||||||
mel_spec = filters @ magnitudes
|
mel_spec = filters @ magnitudes
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user