From 7a992aa7a5477788f929aff9bbe361cc9470e6fc Mon Sep 17 00:00:00 2001 From: Ryan Hileman Date: Wed, 8 Mar 2023 01:04:08 -0800 Subject: [PATCH] maybe fix --speed-up after fft changes --- whisper.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/whisper.cpp b/whisper.cpp index c9d5914..fb92303 100644 --- a/whisper.cpp +++ b/whisper.cpp @@ -2251,7 +2251,7 @@ static bool log_mel_spectrogram( workers[iw] = std::thread([&](int ith) { float *fft_in = fft_alloc(fft_size); std::fill(fft_in, fft_in + fft_size, 0.0); - std::complex *fft_out = fft_alloc>(n_fft); + std::complex *fft_out = fft_alloc>(fft_size / 2 + 1); pocketfft::shape_t fft_shape = {(size_t)fft_size}; pocketfft::stride_t fft_stride_real = {(ptrdiff_t)sizeof(float)}; @@ -2271,14 +2271,14 @@ static bool log_mel_spectrogram( } pocketfft::r2c(fft_shape, fft_stride_real, fft_stride_complex, 0, pocketfft::FORWARD, fft_in, fft_out, 1.0, 1); - for (int j = 0; j < n_fft; j++) { + for (int j = 0; j < fft_size / 2 + 1; j++) { fft_out[j] = std::norm(fft_out[j]); } if (speed_up) { // scale down in the frequency domain results in a speed up in the time domain - for (int j = 0; j < n_fft; j++) { - fft_out[j].real(0.5 * fft_out[j].real()); + for (int j = 0; j < n_fft; j += 2) { + fft_out[j].real(0.5 * (fft_out[j].real() + fft_out[j + 1].real())); } }