From e65b1f701abca03bf3a1b5fbb200392aabd38c22 Mon Sep 17 00:00:00 2001
From: zhifu gao <zhifu.gzf@alibaba-inc.com>
Date: 星期四, 20 六月 2024 17:09:33 +0800
Subject: [PATCH] Dev gzf deepspeed (#1833)
---
funasr/auto/auto_model.py | 38 +++++++++++++++-----------------------
1 files changed, 15 insertions(+), 23 deletions(-)
diff --git a/funasr/auto/auto_model.py b/funasr/auto/auto_model.py
index e30eb09..57a15db 100644
--- a/funasr/auto/auto_model.py
+++ b/funasr/auto/auto_model.py
@@ -92,7 +92,8 @@
if isinstance(data_i, str) and os.path.exists(data_i):
key = misc.extract_filename_without_extension(data_i)
else:
- key = "rand_key_" + "".join(random.choice(chars) for _ in range(13))
+ if key is None:
+ key = "rand_key_" + "".join(random.choice(chars) for _ in range(13))
key_list.append(key)
else: # raw text; audio sample point, fbank; bytes
@@ -324,7 +325,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 +468,20 @@
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"] = ""
- 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"]
- else:
- raw_text = None
+ 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):
@@ -605,12 +603,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