-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariable.py
More file actions
48 lines (42 loc) · 1.4 KB
/
Copy pathvariable.py
File metadata and controls
48 lines (42 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#import yaml
from ruamel.yaml import YAML
yaml = YAML()
class variable():
#config
config = {}
language = 'ja' # auto, zh, en, yue, ja, ko, nospeech
merge_short = True #合并短句
name_nostamp = 'iic/SenseVoiceSmall' #无时间戳模型名
name_stamp = '' #有时间戳模型名
#var
model = None #当前模型
model_nostamp = None #当前无时间戳模型
name = '' #当前模型名
def init_args(self, args):
self.name_nostamp = args[1]
self.name_stamp = ''
self.language = args[2]
self.merge_short = args[3]
self.save_config()
def init_model(self):
if self.name_nostamp:
#无时间戳模型
if not self.model_nostamp or self.name != self.name_nostamp:
self.name = self.name_nostamp
from sense_voice import create_model
self.model_nostamp = create_model(self.name)
self.model = self.model_nostamp
def load_config(self):
with open('config.yaml', 'r', encoding='utf-8') as file:
self.config = yaml.load(file)
self.language = self.config['language']
self.merge_short = self.config['merge_short']
self.name_nostamp = self.config['model_name_nostamp']
def save_config(self):
with open('config.yaml', 'w', encoding='utf-8') as file:
self.config['language'] = self.language
self.config['merge_short'] = self.merge_short
self.config['model_name_nostamp'] = self.name_nostamp
yaml.dump(self.config, file)
# ----------------------------------
Var = variable()