Bladeren bron

download configuration.json

游雁 2 jaren geleden
bovenliggende
commit
831c48a886
2 gewijzigde bestanden met toevoegingen van 6 en 7 verwijderingen
  1. 2 2
      funasr/download/download_from_hub.py
  2. 4 5
      funasr/models/bicif_paraformer/model.py

+ 2 - 2
funasr/download/download_from_hub.py

@@ -22,6 +22,7 @@ def download_from_ms(**kwargs):
 	
 	
 	config = os.path.join(model_or_path, "config.yaml")
 	config = os.path.join(model_or_path, "config.yaml")
 	if os.path.exists(config) and os.path.exists(os.path.join(model_or_path, "model.pb")):
 	if os.path.exists(config) and os.path.exists(os.path.join(model_or_path, "model.pb")):
+		
 		config = OmegaConf.load(config)
 		config = OmegaConf.load(config)
 		kwargs = OmegaConf.merge(config, kwargs)
 		kwargs = OmegaConf.merge(config, kwargs)
 		init_param = os.path.join(model_or_path, "model.pb")
 		init_param = os.path.join(model_or_path, "model.pb")
@@ -39,8 +40,7 @@ def download_from_ms(**kwargs):
 			kwargs["frontend_conf"]["cmvn_file"] = os.path.join(model_or_path, "am.mvn")
 			kwargs["frontend_conf"]["cmvn_file"] = os.path.join(model_or_path, "am.mvn")
 		if os.path.exists(os.path.join(model_or_path, "jieba_usr_dict")):
 		if os.path.exists(os.path.join(model_or_path, "jieba_usr_dict")):
 			kwargs["jieba_usr_dict"] = os.path.join(model_or_path, "jieba_usr_dict")
 			kwargs["jieba_usr_dict"] = os.path.join(model_or_path, "jieba_usr_dict")
-	else:# configuration.json
-		assert os.path.exists(os.path.join(model_or_path, "configuration.json"))
+	elif os.path.exists(os.path.join(model_or_path, "configuration.json")):
 		with open(os.path.join(model_or_path, "configuration.json"), 'r', encoding='utf-8') as f:
 		with open(os.path.join(model_or_path, "configuration.json"), 'r', encoding='utf-8') as f:
 			conf_json = json.load(f)
 			conf_json = json.load(f)
 			cfg = {}
 			cfg = {}

+ 4 - 5
funasr/models/bicif_paraformer/model.py

@@ -1,14 +1,13 @@
+#!/usr/bin/env python3
+# -*- encoding: utf-8 -*-
+# Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved.
+#  MIT License  (https://opensource.org/licenses/MIT)
 
 
 import logging
 import logging
 from typing import Dict
 from typing import Dict
 from typing import List
 from typing import List
 from typing import Optional
 from typing import Optional
 from typing import Tuple
 from typing import Tuple
-from typing import Union
-import tempfile
-import codecs
-import requests
-import re
 import copy
 import copy
 import torch
 import torch
 import torch.nn as nn
 import torch.nn as nn