From 0fe232fd7b41ad24320447d51c07f14d0a807cf3 Mon Sep 17 00:00:00 2001
From: 北念 <lzr265946@alibaba-inc.com>
Date: 星期三, 10 七月 2024 11:32:49 +0800
Subject: [PATCH] add postprocess for sensevoice
---
funasr/auto/auto_model.py | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/funasr/auto/auto_model.py b/funasr/auto/auto_model.py
index 01e6aaf..e027e07 100644
--- a/funasr/auto/auto_model.py
+++ b/funasr/auto/auto_model.py
@@ -20,7 +20,7 @@
from funasr.download.file import download_from_url
from funasr.utils.timestamp_tools import timestamp_sentence
from funasr.utils.timestamp_tools import timestamp_sentence_en
-from funasr.download.download_from_hub import download_model
+from funasr.download.download_model_from_hub import download_model
from funasr.utils.vad_utils import slice_padding_audio_samples
from funasr.utils.vad_utils import merge_vad
from funasr.utils.load_utils import load_audio_text_image_video
@@ -121,9 +121,6 @@
log_level = getattr(logging, kwargs.get("log_level", "INFO").upper())
logging.basicConfig(level=log_level)
- if not kwargs.get("disable_log", True):
- tables.print()
-
model, kwargs = self.build_model(**kwargs)
# if vad_model is not None, build vad model else None
@@ -171,7 +168,8 @@
self.spk_kwargs = spk_kwargs
self.model_path = kwargs.get("model_path")
- def build_model(self, **kwargs):
+ @staticmethod
+ def build_model(**kwargs):
assert "model" in kwargs
if "model_conf" not in kwargs:
logging.info("download models from model hub: {}".format(kwargs.get("hub", "ms")))
@@ -217,6 +215,7 @@
kwargs["frontend"] = frontend
# build model
model_class = tables.model_classes.get(kwargs["model"])
+ assert model_class is not None, f'{kwargs["model"]} is not registered'
model_conf = {}
deep_update(model_conf, kwargs.get("model_conf", {}))
deep_update(model_conf, kwargs)
@@ -244,6 +243,10 @@
elif kwargs.get("bf16", False):
model.to(torch.bfloat16)
model.to(device)
+
+ if not kwargs.get("disable_log", True):
+ tables.print()
+
return model, kwargs
def __call__(self, *args, **cfg):
--
Gitblit v1.9.1