From 3a4281f4959534b1bf5d01acf0085f4f8e6f2ec8 Mon Sep 17 00:00:00 2001
From: wuhongsheng <664116298@qq.com>
Date: 星期五, 05 七月 2024 00:55:32 +0800
Subject: [PATCH] 优化speakid和语句匹配逻辑,部分解决speakid不从0递增问题 (#1870)

---
 funasr/download/runtime_sdk_download_tool.py |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/funasr/download/runtime_sdk_download_tool.py b/funasr/download/runtime_sdk_download_tool.py
index 96c6735..0db17c7 100644
--- a/funasr/download/runtime_sdk_download_tool.py
+++ b/funasr/download/runtime_sdk_download_tool.py
@@ -10,7 +10,7 @@
     parser.add_argument("--model-name", type=str, required=True)
     parser.add_argument("--export-dir", type=str, required=True)
     parser.add_argument("--export", type=str2bool, default=True, help="whether to export model")
-    parser.add_argument("--type", type=str, default="onnx", help='["onnx", "torch"]')
+    parser.add_argument("--type", type=str, default="onnx", help='["onnx", "torchscript", "bladedisc"]')
     parser.add_argument("--device", type=str, default="cpu", help='["cpu", "cuda"]')
     parser.add_argument("--quantize", type=str2bool, default=False, help="export quantized model")
     parser.add_argument("--fallback-num", type=int, default=0, help="amp fallback number")
@@ -37,11 +37,17 @@
         model_file = os.path.join(model_dir, "model.onnx")
         if args.quantize:
             model_file = os.path.join(model_dir, "model_quant.onnx")
+        if args.type == "torchscript":
+            model_file = os.path.join(model_dir, "model.torchscript")
+            args.device = "cuda"
+        elif args.type == "bladedisc":
+            model_file = os.path.join(model_dir, "model_blade.torchscript")
+            args.device = "cuda"
         if not os.path.exists(model_file):
-            print(".onnx is not exist, begin to export onnx")
+            print("model is not exist, begin to export " + model_file)
             from funasr import AutoModel
 
-            export_model = AutoModel(model=args.model_name, output_dir=output_dir)
+            export_model = AutoModel(model=args.model_name, output_dir=output_dir, device=args.device)
             export_model.export(
                     quantize=args.quantize,
                     type=args.type,

--
Gitblit v1.9.1