From 7fc17b1aafb0c53ac83a86ecf4adbee3e10fdb86 Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期日, 09 六月 2024 22:40:49 +0800
Subject: [PATCH] fix bug

---
 funasr/models/llm_asr/model.py |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/funasr/models/llm_asr/model.py b/funasr/models/llm_asr/model.py
index aacbe45..21072b0 100644
--- a/funasr/models/llm_asr/model.py
+++ b/funasr/models/llm_asr/model.py
@@ -556,7 +556,7 @@
 
         return contents
 
-    def data_load_speech(self, contents: dict, tokenizer, frontend, **kwargs):
+    def data_load_speech(self, contents: dict, tokenizer, frontend, meta_data={}, **kwargs):
 
         system = contents["system"]
         user = contents["user"]
@@ -594,7 +594,10 @@
                     )
                     if sub_str.startswith("!"):
                         try:
+                            time1 = time.perf_counter()
                             data_src = load_audio_text_image_video(sub_str[1:], fs=frontend.fs)
+                            time2 = time.perf_counter()
+                            meta_data["load_data"] = f"{time2 - time1:0.3f}"
                         except Exception as e:
                             logging.error(f"Loading wav failed! {str(e)}, {traceback.format_exc()}")
 
@@ -604,6 +607,15 @@
                             frontend=frontend,
                             is_final=True,
                         )  # speech: [b, T, d]
+
+                        time3 = time.perf_counter()
+                        meta_data["extract_feat"] = f"{time3 - time2:0.3f}"
+                        meta_data["batch_data_time"] = (
+                            speech_lengths.sum().item()
+                            * frontend.frame_shift
+                            * frontend.lfr_n
+                            / 1000
+                        )
 
                         if kwargs.get("permute", True):
                             speech = speech.permute(0, 2, 1)
@@ -666,7 +678,7 @@
             raise NotImplementedError("batch decoding is not implemented")
 
         contents = self.data_template(data_in[0])
-        output = self.data_load_speech(contents, tokenizer, frontend, **kwargs)
+        output = self.data_load_speech(contents, tokenizer, frontend, meta_data=meta_data, **kwargs)
         batch = to_device(output, kwargs["device"])
 
         # audio encoder

--
Gitblit v1.9.1