Skip to content

Commit 9b93462

Browse files
Update whisper_audio_converter.py
1 parent 58cfbea commit 9b93462

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

keras_hub/src/models/whisper/whisper_audio_converter.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import keras.ops as ops
2-
import numpy as np
32
import tensorflow as tf
43

54
from keras_hub.src.api_export import keras_hub_export
@@ -157,7 +156,7 @@ def _extract_audio_features(self, audio):
157156
[0, 0],
158157
[self.num_fft_bins // 2, self.num_fft_bins // 2],
159158
],
160-
mode="REFLECT",
159+
mode="reflect",
161160
)
162161
# Compute the mel spectrogram.
163162
stft = ops.stft(
@@ -168,10 +167,7 @@ def _extract_audio_features(self, audio):
168167
center=False,
169168
)
170169
stft = ops.sum(stft, axis=0)
171-
# magnitudes = ops.square(ops.absolute(stft)
172170
magnitudes = ops.square(ops.absolute(stft[:, :-1, :]))
173-
# magnitudes = ops.square(ops.sqrt(ops.square(stft_real) + ops.square(stft_imag)))
174-
# mel_filters_casted = ops.cast(self.mel_filters, dtype=magnitudes.dtype)
175171

176172
mel_spec = ops.matmul(
177173
magnitudes,
@@ -230,7 +226,7 @@ def call(self, audio):
230226
audio = tf.RaggedTensor.from_tensor(audio)
231227

232228
# Pad audio.
233-
audio_shape = audio.shape.as_list()
229+
audio_shape = list(audio.shape)
234230
audio_shape[-1] = self.num_samples
235231
audio = audio.to_tensor(shape=audio_shape)
236232

0 commit comments

Comments
 (0)