From ddd4ad419bd168fb35172efcda1e90da5132ef8a Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期二, 04 六月 2024 11:20:29 +0800
Subject: [PATCH] auto frontend

---
 funasr/auto/auto_frontend.py |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/funasr/auto/auto_frontend.py b/funasr/auto/auto_frontend.py
index 3d6db8d..696a51e 100644
--- a/funasr/auto/auto_frontend.py
+++ b/funasr/auto/auto_frontend.py
@@ -87,8 +87,16 @@
                 speech_lengths.sum().item() * self.frontend.frame_shift * self.frontend.lfr_n / 1000
             )
 
-            speech.to(device=device), speech_lengths.to(device=device)
-            batch = {"input": speech, "input_len": speech_lengths, "key": key_batch}
+            if kwargs.get("return_pt", True):
+                speech, speech_lengths = speech.to(device=device), speech_lengths.to(device=device)
+            else:
+                speech, speech_lengths = speech.numpy(), speech_lengths.numpy()
+            batch = {
+                "input": speech,
+                "input_len": speech_lengths,
+                "key": key_batch,
+                data_type: "fbank",
+            }
             result_list.append(batch)
 
             pbar.update(1)

--
Gitblit v1.9.1