From 05c8eba11c51ca928eee9c041de1a4192e590aec Mon Sep 17 00:00:00 2001
From: nianjiuhuiyi <64776403+nianjiuhuiyi@users.noreply.github.com>
Date: 星期五, 27 六月 2025 09:57:45 +0800
Subject: [PATCH] Fix: 修复c++后端服务因为空数组的异常退出,以及c++的http服务在收到Ctrl+C信号后无法正常退出 (#2571)
---
funasr/frontends/fused.py | 18 ++++++++----------
1 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/funasr/frontends/fused.py b/funasr/frontends/fused.py
index 24f73f4..1da1e9f 100644
--- a/funasr/frontends/fused.py
+++ b/funasr/frontends/fused.py
@@ -7,14 +7,10 @@
class FusedFrontends(nn.Module):
- def __init__(
- self, frontends=None, align_method="linear_projection", proj_dim=100, fs=16000
- ):
+ def __init__(self, frontends=None, align_method="linear_projection", proj_dim=100, fs=16000):
super().__init__()
- self.align_method = (
- align_method # fusing method : linear_projection only for now
- )
+ self.align_method = align_method # fusing method : linear_projection only for now
self.proj_dim = proj_dim # dim of the projection done on each frontend
self.frontends = [] # list of the frontends to combine
@@ -82,6 +78,10 @@
self.factors = [frontend.hop_length // self.gcd for frontend in self.frontends]
if torch.cuda.is_available():
dev = "cuda"
+ elif torch.xpu.is_available():
+ dev = "xpu"
+ elif torch.backends.mps.is_available():
+ dev = "mps"
else:
dev = "cpu"
if self.align_method == "linear_projection":
@@ -109,9 +109,7 @@
input_feats, feats_lens = frontend.forward(input, input_lengths)
self.feats.append([input_feats, feats_lens])
- if (
- self.align_method == "linear_projection"
- ): # TODO(Dan): to add other align methods
+ if self.align_method == "linear_projection": # TODO(Dan): to add other align methods
# first step : projections
self.feats_proj = []
@@ -141,4 +139,4 @@
else:
raise NotImplementedError
- return input_feats, feats_lens
\ No newline at end of file
+ return input_feats, feats_lens
--
Gitblit v1.9.1