From 810046e3df4910c8f5c1a90e4b53aca45b3397e8 Mon Sep 17 00:00:00 2001
From: wuhongsheng <664116298@qq.com>
Date: 星期一, 01 七月 2024 10:42:58 +0800
Subject: [PATCH] 优化merge segments 参数,解决新闻联播男女主持人“晚上好”合并一个speakid问题 (#1861)

---
 funasr/utils/dynamic_import.py |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/funasr/utils/dynamic_import.py b/funasr/utils/dynamic_import.py
index 71ad4fe..531b96b 100644
--- a/funasr/utils/dynamic_import.py
+++ b/funasr/utils/dynamic_import.py
@@ -2,6 +2,8 @@
 
 import importlib.util
 import inspect
+import os.path
+import sys
 
 
 def load_module_from_path(file_path):
@@ -18,6 +20,23 @@
     return module
 
 
+def import_module_from_path(file_path: str):
+
+    if file_path.startswith("http"):
+        from funasr.download.file import download_from_url
+
+        file_path = download_from_url(file_path)
+
+    file_dir = os.path.dirname(file_path)
+    file_name = os.path.basename(file_path)
+    module_name = file_path.split("/")[-1].replace(".py", "")
+    if len(file_dir) < 1:
+        file_dir = "./"
+    sys.path.append(file_dir)
+    importlib.import_module(module_name)
+    print(f"Loading remote code successfully: {file_path}")
+
+
 #
 # def load_module_from_path(module_name, file_path):
 #     """

--
Gitblit v1.9.1