From 45d7aa9004763684fb748ee17942ecba81042201 Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期三, 19 六月 2024 10:26:40 +0800
Subject: [PATCH] decoding
---
funasr/auto/auto_model.py | 36 ++++++++++++++----------------------
1 files changed, 14 insertions(+), 22 deletions(-)
diff --git a/funasr/auto/auto_model.py b/funasr/auto/auto_model.py
index 9f8e4dc..a6cd3a6 100644
--- a/funasr/auto/auto_model.py
+++ b/funasr/auto/auto_model.py
@@ -213,7 +213,6 @@
deep_update(model_conf, kwargs.get("model_conf", {}))
deep_update(model_conf, kwargs)
model = model_class(**model_conf, vocab_size=vocab_size)
- model.to(device)
# init_param
init_param = kwargs.get("init_param", None)
@@ -236,6 +235,7 @@
model.to(torch.float16)
elif kwargs.get("bf16", False):
model.to(torch.bfloat16)
+ model.to(device)
return model, kwargs
def __call__(self, *args, **cfg):
@@ -324,7 +324,7 @@
input, input_len=input_len, model=self.vad_model, kwargs=self.vad_kwargs, **cfg
)
end_vad = time.time()
-
+
# FIX(gcf): concat the vad clips for sense vocie model for better aed
if kwargs.get("merge_vad", False):
for i in range(len(res)):
@@ -467,23 +467,21 @@
else:
result[k] += restored_data[j][k]
+ if not len(result["text"].strip()):
+ continue
return_raw_text = kwargs.get("return_raw_text", False)
# step.3 compute punc model
raw_text = None
if self.punc_model is not None:
- if not len(result["text"].strip()):
- if return_raw_text:
- result["raw_text"] = raw_text = ""
- else:
- deep_update(self.punc_kwargs, cfg)
- punc_res = self.inference(
- result["text"], model=self.punc_model, kwargs=self.punc_kwargs, **cfg
- )
- raw_text = copy.copy(result["text"])
- if return_raw_text:
- result["raw_text"] = raw_text
- result["text"] = punc_res[0]["text"]
-
+ deep_update(self.punc_kwargs, cfg)
+ punc_res = self.inference(
+ result["text"], model=self.punc_model, kwargs=self.punc_kwargs, **cfg
+ )
+ raw_text = copy.copy(result["text"])
+ if return_raw_text:
+ result["raw_text"] = raw_text
+ result["text"] = punc_res[0]["text"]
+
# speaker embedding cluster after resorted
if self.spk_model is not None and kwargs.get("return_spk_res", True):
if raw_text is None:
@@ -604,12 +602,6 @@
)
with torch.no_grad():
-
- if type == "onnx":
- export_dir = export_utils.export_onnx(model=model, data_in=data_list, **kwargs)
- else:
- export_dir = export_utils.export_torchscripts(
- model=model, data_in=data_list, **kwargs
- )
+ export_dir = export_utils.export(model=model, data_in=data_list, **kwargs)
return export_dir
--
Gitblit v1.9.1