Skip to content

Commit

Permalink
Revert irrelevant changes
Browse files Browse the repository at this point in the history
  • Loading branch information
greenw0lf committed Dec 3, 2024
1 parent 0a119b4 commit ef8c2ce
Showing 1 changed file with 0 additions and 62 deletions.
62 changes: 0 additions & 62 deletions faster_whisper/feature_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,65 +228,3 @@ def __call__(self, waveform: np.ndarray, padding=160, chunk_length=None):
log_spec = (log_spec + 4.0) / 4.0

return log_spec

if win_length <= 0 or win_length > n_fft:
raise ValueError(
f"stft: expected 0 < win_length <= n_fft, but got win_length={win_length}"
)

if window is not None:
if window.ndim != 1 or window.shape[0] != win_length:
raise ValueError(
f"stft: expected a 1D window tensor of size equal to win_length={win_length}, "
f"but got window with size {window.shape}"
)

# Handle padding of the window if necessary
if win_length < n_fft:
left = (n_fft - win_length) // 2
window_ = np.zeros(n_fft, dtype=window.dtype)
window_[left : left + win_length] = window
else:
window_ = window

# Calculate the number of frames
n_frames = 1 + (length - n_fft) // hop_length

# Time to columns
input_tensor = np.lib.stride_tricks.as_strided(
input_tensor,
(batch, n_frames, n_fft),
(
input_tensor.strides[0],
hop_length * input_tensor.strides[1],
input_tensor.strides[1],
),
)

if window_ is not None:
input_tensor = input_tensor * window_

# FFT and transpose
complex_fft = input_is_complex
onesided = onesided if onesided is not None else not complex_fft

if normalized:
norm = "ortho"
else:
norm = None

if complex_fft:
if onesided:
raise ValueError(
"Cannot have onesided output if window or input is complex"
)
output = np.fft.fft(input_tensor, n=n_fft, axis=-1, norm=norm)
else:
output = np.fft.rfft(input_tensor, n=n_fft, axis=-1, norm=norm)

output = output.transpose((0, 2, 1))

if input_tensor_1d:
output = output.squeeze(0)

return output if return_complex else np.real(output)

0 comments on commit ef8c2ce

Please sign in to comment.