From 3df109adfccedeb134dea4ba2ea9a2da89872048 Mon Sep 17 00:00:00 2001
From: Isuxiz Slidder <48672727+Isuxiz@users.noreply.github.com>
Date: 星期一, 31 三月 2025 17:51:52 +0800
Subject: [PATCH] Update model.py to fix "IndexError: index 1 is out of bounds for dimension 1 with size 0" (#2454)

---
 funasr/frontends/eend_ola_feature.py |   24 ++++++++++--------------
 1 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/funasr/frontends/eend_ola_feature.py b/funasr/frontends/eend_ola_feature.py
index e15b71c..0c79a3b 100644
--- a/funasr/frontends/eend_ola_feature.py
+++ b/funasr/frontends/eend_ola_feature.py
@@ -13,7 +13,7 @@
     sr = 8000
     n_mels = 23
     mel_basis = librosa.filters.mel(sr, n_fft, n_mels)
-    Y = np.dot(Y ** 2, mel_basis.T)
+    Y = np.dot(Y**2, mel_basis.T)
     Y = np.log10(np.maximum(Y, 1e-10))
     mean = np.mean(Y, axis=0)
     Y = Y - mean
@@ -27,25 +27,21 @@
 
 
 def splice(Y, context_size=0):
-    Y_pad = np.pad(
-        Y,
-        [(context_size, context_size), (0, 0)],
-        'constant')
+    Y_pad = np.pad(Y, [(context_size, context_size), (0, 0)], "constant")
     Y_spliced = np.lib.stride_tricks.as_strided(
         np.ascontiguousarray(Y_pad),
         (Y.shape[0], Y.shape[1] * (2 * context_size + 1)),
-        (Y.itemsize * Y.shape[1], Y.itemsize), writeable=False)
+        (Y.itemsize * Y.shape[1], Y.itemsize),
+        writeable=False,
+    )
     return Y_spliced
 
 
-def stft(
-        data,
-        frame_size=1024,
-        frame_shift=256):
+def stft(data, frame_size=1024, frame_shift=256):
     fft_size = 1 << (frame_size - 1).bit_length()
     if len(data) % frame_shift == 0:
-        return librosa.stft(data, n_fft=fft_size, win_length=frame_size,
-                            hop_length=frame_shift).T[:-1]
+        return librosa.stft(data, n_fft=fft_size, win_length=frame_size, hop_length=frame_shift).T[
+            :-1
+        ]
     else:
-        return librosa.stft(data, n_fft=fft_size, win_length=frame_size,
-                            hop_length=frame_shift).T
\ No newline at end of file
+        return librosa.stft(data, n_fft=fft_size, win_length=frame_size, hop_length=frame_shift).T

--
Gitblit v1.9.1