From 6bdae5723e403584ee3507675b3e4e922a34f246 Mon Sep 17 00:00:00 2001
From: lingyunfly <121302812+lingyunfly@users.noreply.github.com>
Date: 星期五, 09 六月 2023 16:19:35 +0800
Subject: [PATCH] Optimize memory (#612)

---
 funasr/bin/diar_infer.py |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/funasr/bin/diar_infer.py b/funasr/bin/diar_infer.py
index f698a66..4460e3d 100755
--- a/funasr/bin/diar_infer.py
+++ b/funasr/bin/diar_infer.py
@@ -1,3 +1,4 @@
+# -*- encoding: utf-8 -*-
 #!/usr/bin/env python3
 # Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved.
 #  MIT License  (https://opensource.org/licenses/MIT)
@@ -234,8 +235,11 @@
                 new_seq.append(x)
             else:
                 idx_list = np.where(seq < 2 ** vec_dim)[0]
-                idx = np.abs(idx_list - i).argmin()
-                new_seq.append(seq[idx_list[idx]])
+                if len(idx_list) > 0:
+                    idx = np.abs(idx_list - i).argmin()
+                    new_seq.append(seq[idx_list[idx]])
+                else:
+                    new_seq.append(0)
         return np.row_stack([int2vec(x, vec_dim) for x in new_seq])
 
     def post_processing(self, raw_logits: torch.Tensor, spk_num: int, output_format: str = "speaker_turn"):

--
Gitblit v1.9.1