mirror of
https://github.com/modelscope/FunASR
synced 2025-09-15 14:48:36 +08:00
install requirements automatically
This commit is contained in:
parent
3cdb83537b
commit
eb3d5c78bf
@ -72,6 +72,9 @@ def download_from_ms(**kwargs):
|
||||
kwargs["jieba_usr_dict"] = os.path.join(model_or_path, "jieba_usr_dict")
|
||||
if isinstance(kwargs, DictConfig):
|
||||
kwargs = OmegaConf.to_container(kwargs, resolve=True)
|
||||
if os.path.exists(os.path.join(model_or_path, "requirements.txt")):
|
||||
from funasr.utils.install_model_requirements import install_requirements
|
||||
install_requirements(os.path.join(model_or_path, "requirements.txt"))
|
||||
return kwargs
|
||||
|
||||
def add_file_root_path(model_or_path: str, file_path_metas: dict, cfg = {}):
|
||||
|
||||
35
funasr/utils/install_model_requirements.py
Normal file
35
funasr/utils/install_model_requirements.py
Normal file
@ -0,0 +1,35 @@
|
||||
import subprocess
|
||||
|
||||
def install_requirements(requirements_path):
|
||||
try:
|
||||
result = subprocess.run(
|
||||
['pip', 'install', '-r', requirements_path],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
text=True
|
||||
)
|
||||
|
||||
# check status
|
||||
if result.returncode == 0:
|
||||
print("install model requirements successfully")
|
||||
return True
|
||||
else:
|
||||
print("fail to install model requirements! ")
|
||||
print("error", result.stderr)
|
||||
return False
|
||||
except Exception as e:
|
||||
result = subprocess.run(
|
||||
['pip', 'install', '-r', requirements_path],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
text=True
|
||||
)
|
||||
|
||||
# check status
|
||||
if result.returncode == 0:
|
||||
print("install model requirements successfully")
|
||||
return True
|
||||
else:
|
||||
print("fail to install model requirements! ")
|
||||
print("error", result.stderr)
|
||||
return False
|
||||
Loading…
Reference in New Issue
Block a user