From 1596f6f414f6f41da66506debb1dff19fffeb3ec Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期一, 24 六月 2024 11:55:17 +0800
Subject: [PATCH] fixbug hotwords
---
funasr/models/sense_voice/whisper_lib/audio.py | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/funasr/models/sense_voice/whisper_lib/audio.py b/funasr/models/sense_voice/whisper_lib/audio.py
index cf6c66a..2f688e9 100644
--- a/funasr/models/sense_voice/whisper_lib/audio.py
+++ b/funasr/models/sense_voice/whisper_lib/audio.py
@@ -68,9 +68,7 @@
"""
if torch.is_tensor(array):
if array.shape[axis] > length:
- array = array.index_select(
- dim=axis, index=torch.arange(length, device=array.device)
- )
+ array = array.index_select(dim=axis, index=torch.arange(length, device=array.device))
if array.shape[axis] < length:
pad_widths = [(0, 0)] * array.ndim
@@ -89,7 +87,7 @@
@lru_cache(maxsize=None)
-def mel_filters(device, n_mels: int) -> torch.Tensor:
+def mel_filters(device, n_mels: int, filters_path: str = None) -> torch.Tensor:
"""
load the mel filterbank matrix for projecting STFT into a Mel spectrogram.
Allows decoupling librosa dependency; saved using:
@@ -101,8 +99,8 @@
)
"""
assert n_mels in {80, 128}, f"Unsupported n_mels: {n_mels}"
-
- filters_path = os.path.join(os.path.dirname(__file__), "assets", "mel_filters.npz")
+ if filters_path is None:
+ filters_path = os.path.join(os.path.dirname(__file__), "assets", "mel_filters.npz")
with np.load(filters_path, allow_pickle=False) as f:
return torch.from_numpy(f[f"mel_{n_mels}"]).to(device)
--
Gitblit v1.9.1