From c47ad73e46bbaad7b2b003ecd890dc0e8f537172 Mon Sep 17 00:00:00 2001
From: shixian.shi <shixian.shi@alibaba-inc.com>
Date: 星期一, 29 一月 2024 15:49:45 +0800
Subject: [PATCH] fix device bug
---
funasr/auto/auto_model.py | 19 ++++++++-----------
1 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/funasr/auto/auto_model.py b/funasr/auto/auto_model.py
index 9d957a3..3986a11 100644
--- a/funasr/auto/auto_model.py
+++ b/funasr/auto/auto_model.py
@@ -88,7 +88,8 @@
class AutoModel:
def __init__(self, **kwargs):
- tables.print()
+ if kwargs.get("disable_log", False):
+ tables.print()
model, kwargs = self.build_model(**kwargs)
@@ -133,8 +134,6 @@
self.spk_model = spk_model
self.spk_kwargs = spk_kwargs
self.model_path = kwargs.get("model_path")
-
-
def build_model(self, **kwargs):
assert "model" in kwargs
@@ -145,7 +144,7 @@
set_all_random_seed(kwargs.get("seed", 0))
device = kwargs.get("device", "cuda")
- if not torch.cuda.is_available() or kwargs.get("ngpu", 0) == 0:
+ if not torch.cuda.is_available() or kwargs.get("ngpu", 1) == 0:
device = "cpu"
kwargs["batch_size"] = 1
kwargs["device"] = device
@@ -198,8 +197,6 @@
kwargs.update(cfg)
res = self.model(*args, kwargs)
return res
-
-
def generate(self, input, input_len=None, **cfg):
if self.vad_model is None:
@@ -426,10 +423,10 @@
f"time_escape: {time_escape_total_per_sample:0.3f}")
- end_total = time.time()
- time_escape_total_all_samples = end_total - beg_total
- print(f"rtf_avg_all: {time_escape_total_all_samples / time_speech_total_all_samples:0.3f}, "
- f"time_speech_all: {time_speech_total_all_samples: 0.3f}, "
- f"time_escape_all: {time_escape_total_all_samples:0.3f}")
+ # end_total = time.time()
+ # time_escape_total_all_samples = end_total - beg_total
+ # print(f"rtf_avg_all: {time_escape_total_all_samples / time_speech_total_all_samples:0.3f}, "
+ # f"time_speech_all: {time_speech_total_all_samples: 0.3f}, "
+ # f"time_escape_all: {time_escape_total_all_samples:0.3f}")
return results_ret_list
--
Gitblit v1.9.1