File size: 2,222 Bytes
503ec99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Copyright 2023 by zhongying
#


from . import load_yaml
from util.utils import preprocess_paths


class Config:
    """ User configs class for training, testing or infering """

    def __init__(self, path: str):
        print('configs file path:', path)
        config = load_yaml(preprocess_paths(path))
        self.speech_config = config.get("speech_config", {})
        self.model_config = config.get("model_config", {})
        self.dataset_config = config.get("dataset_config", {})
        self.optimizer_config = config.get("optimizer_config", {})
        self.running_config = config.get("running_config", {})

    def print(self):
        print('==================================================')
        print('speech configs:', self.speech_config)
        print('--------------------------------------------------')
        print('model configs:', self.model_config)
        print('--------------------------------------------------')
        print('dataset configs:', self.dataset_config)
        print('--------------------------------------------------')
        print('optimizer configs', self.optimizer_config)
        print('--------------------------------------------------')
        print('running configs:', self.running_config)
        print('==================================================')

    def toString(self):
        string = ''
        string += '#==================================================' + '\n'
        string += '#speech config: ' + str(self.speech_config) + '\n'
        string += '#--------------------------------------------------' + '\n'
        string += '#model config: ' + str(self.model_config) + '\n'
        string += '#--------------------------------------------------' + '\n'
        string += '#dataset config: ' + str(self.dataset_config) + '\n'
        string += '#--------------------------------------------------' + '\n'
        string += '#optimizer config: ' + str(self.optimizer_config) + '\n'
        string += '#--------------------------------------------------' + '\n'
        string += '#running config: ' + str(self.running_config) + '\n'
        string += '#==================================================' + '\n'
        return string