From 4cf44a89f808411a0616c8ed92c3afae3d3e371a Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期三, 21 二月 2024 00:43:27 +0800
Subject: [PATCH] bugfix
---
funasr/auto/auto_model.py | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/funasr/auto/auto_model.py b/funasr/auto/auto_model.py
index 8e00703..e4a154d 100644
--- a/funasr/auto/auto_model.py
+++ b/funasr/auto/auto_model.py
@@ -20,7 +20,10 @@
from funasr.utils.load_utils import load_audio_text_image_video, extract_fbank
from funasr.utils.timestamp_tools import timestamp_sentence
from funasr.models.campplus.utils import sv_chunk, postprocess, distribute_spk
-from funasr.models.campplus.cluster_backend import ClusterBackend
+try:
+ from funasr.models.campplus.cluster_backend import ClusterBackend
+except:
+ print("If you want to use the speaker diarization, please `pip install hdbscan`")
def prepare_data_iterator(data_in, input_len=None, data_type=None, key=None):
@@ -171,7 +174,7 @@
# build model
model_class = tables.model_classes.get(kwargs["model"])
model = model_class(**kwargs, **kwargs["model_conf"], vocab_size=vocab_size)
- model.eval()
+
model.to(device)
# init_param
@@ -206,6 +209,7 @@
kwargs = self.kwargs if kwargs is None else kwargs
kwargs.update(cfg)
model = self.model if model is None else model
+ model.eval()
batch_size = kwargs.get("batch_size", 1)
# if kwargs.get("device", "cpu") == "cpu":
@@ -396,20 +400,20 @@
for res, vadsegment in zip(restored_data, vadsegments):
sentence_list.append({"start": vadsegment[0],\
"end": vadsegment[1],
- "sentence": res['raw_text'],
+ "sentence": res['text'],
"timestamp": res['timestamp']})
elif self.spk_mode == 'punc_segment':
sentence_list = timestamp_sentence(punc_res[0]['punc_array'], \
result['timestamp'], \
- result['raw_text'])
+ result['text'])
distribute_spk(sentence_list, sv_output)
result['sentence_info'] = sentence_list
elif kwargs.get("sentence_timestamp", False):
sentence_list = timestamp_sentence(punc_res[0]['punc_array'], \
result['timestamp'], \
- result['raw_text'])
+ result['text'])
result['sentence_info'] = sentence_list
- del result['spk_embedding']
+ if "spk_embedding" in result: del result['spk_embedding']
result["key"] = key
results_ret_list.append(result)
--
Gitblit v1.9.1