From 145022c438c8158e6bffdc5ff66fdd28468a0a18 Mon Sep 17 00:00:00 2001
From: zhong zhuang <zhuangz@lamda.nju.edu.cn>
Date: 星期五, 14 六月 2024 20:33:16 +0800
Subject: [PATCH] Update cif_predictor.py (#1811)

---
 funasr/auto/auto_model.py |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/funasr/auto/auto_model.py b/funasr/auto/auto_model.py
index fb81608..4418b6a 100644
--- a/funasr/auto/auto_model.py
+++ b/funasr/auto/auto_model.py
@@ -234,6 +234,8 @@
         # fp16
         if kwargs.get("fp16", False):
             model.to(torch.float16)
+        elif kwargs.get("bf16", False):
+            model.to(torch.bfloat16)
         return model, kwargs
 
     def __call__(self, *args, **cfg):
@@ -428,6 +430,10 @@
             #                      f"time_speech_total_per_sample: {time_speech_total_per_sample: 0.3f}, "
             #                      f"time_escape_total_per_sample: {time_escape_total_per_sample:0.3f}")
 
+            if len(results_sorted) != n:
+                results_ret_list.append({"key": key, "text": "", "timestamp": []})
+                logging.info("decoding, utt: {}, empty result".format(key))
+                continue
             restored_data = [0] * n
             for j in range(n):
                 index = sorted_data[j][1]

--
Gitblit v1.9.1