We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
develop  版本 paddlespeech_server 启动后会打印 2 遍 log
```bash
paddlespeech_server start --config_file ./conf/application.yaml
```
log：
```text
[2022-06-23 06:18:31,311] [    INFO] - start to init the engine
[2022-06-23 06:18:31,311] [    INFO] - start to init the engine
[2022-06-23 06:18:31,312] [    INFO] - tts : python engine.
[2022-06-23 06:18:31,312] [    INFO] - tts : python engine.
from .pretrained_models import tts_dynamic_pretrained_models
[2022-06-23 06:18:36,330] [    INFO] - File /home/xxx/.paddlespeech/models/fastspeech2_csmsc-zh/1.0/fastspeech2_nosil_baker_ckpt_0.4.zip md5 checking...
[2022-06-23 06:18:36,330] [    INFO] - File /home/xxx/.paddlespeech/models/fastspeech2_csmsc-zh/1.0/fastspeech2_nosil_baker_ckpt_0.4.zip md5 checking...
[2022-06-23 06:18:37,699] [    INFO] - /home/xxx/.paddlespeech/models/fastspeech2_csmsc-zh/1.0/fastspeech2_nosil_baker_ckpt_0.4
[2022-06-23 06:18:37,699] [    INFO] - /home/xxx/.paddlespeech/models/fastspeech2_csmsc-zh/1.0/fastspeech2_nosil_baker_ckpt_0.4
[2022-06-23 06:18:37,699] [    INFO] - /home/xxx/.paddlespeech/models/fastspeech2_csmsc-zh/1.0/fastspeech2_nosil_baker_ckpt_0.4/default.yaml
[2022-06-23 06:18:37,699] [    INFO] - /home/xxx/.paddlespeech/models/fastspeech2_csmsc-zh/1.0/fastspeech2_nosil_baker_ckpt_0.4/default.yaml
[2022-06-23 06:18:37,700] [    INFO] - /home/xxx/.paddlespeech/models/fastspeech2_csmsc-zh/1.0/fastspeech2_nosil_baker_ckpt_0.4/snapshot_iter_76000.pdz
[2022-06-23 06:18:37,700] [    INFO] - /home/xxx/.paddlespeech/models/fastspeech2_csmsc-zh/1.0/fastspeech2_nosil_baker_ckpt_0.4/snapshot_iter_76000.pdz
[2022-06-23 06:18:37,700] [    INFO] - File /home/xxx/.paddlespeech/models/pwgan_csmsc-zh/1.0/pwg_baker_ckpt_0.4.zip md5 checking...
[2022-06-23 06:18:37,700] [    INFO] - File /home/xxx/.paddlespeech/models/pwgan_csmsc-zh/1.0/pwg_baker_ckpt_0.4.zip md5 checking...
[2022-06-23 06:18:37,744] [    INFO] - /home/xxx/.paddlespeech/models/pwgan_csmsc-zh/1.0/pwg_baker_ckpt_0.4
[2022-06-23 06:18:37,744] [    INFO] - /home/xxx/.paddlespeech/models/pwgan_csmsc-zh/1.0/pwg_baker_ckpt_0.4
[2022-06-23 06:18:37,744] [    INFO] - /home/xxx/.paddlespeech/models/pwgan_csmsc-zh/1.0/pwg_baker_ckpt_0.4/pwg_default.yaml
[2022-06-23 06:18:37,744] [    INFO] - /home/xxx/.paddlespeech/models/pwgan_csmsc-zh/1.0/pwg_baker_ckpt_0.4/pwg_default.yaml
[2022-06-23 06:18:37,744] [    INFO] - /home/xxx/.paddlespeech/models/pwgan_csmsc-zh/1.0/pwg_baker_ckpt_0.4/pwg_snapshot_iter_400000.pdz
[2022-06-23 06:18:37,744] [    INFO] - /home/xxx/.paddlespeech/models/pwgan_csmsc-zh/1.0/pwg_baker_ckpt_0.4/pwg_snapshot_iter_400000.pdz
vocab_size: 268
frontend done!
```
有问题的 commit 号：
```text
5e03d75
```

没问题的 commit 号：
```text
803800
```
引起问题的 commit
<img width="522" alt="image" src="https://user-images.githubusercontent.com/24568452/175233071-0cf2e8fa-78e0-4497-afa9-584b4b61c3bd.png">



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `paddlespeech/server/utils/log.py`
Content:
```
1 # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 import functools
15 import logging
16 
17 __all__ = [
18     'logger',
19 ]
20 
21 
22 class Logger(object):
23     def __init__(self, name: str=None):
24         name = 'PaddleSpeech' if not name else name
25         self.logger = logging.getLogger(name)
26 
27         log_config = {
28             'DEBUG': 10,
29             'INFO': 20,
30             'TRAIN': 21,
31             'EVAL': 22,
32             'WARNING': 30,
33             'ERROR': 40,
34             'CRITICAL': 50,
35             'EXCEPTION': 100,
36         }
37         for key, level in log_config.items():
38             logging.addLevelName(level, key)
39             if key == 'EXCEPTION':
40                 self.__dict__[key.lower()] = self.logger.exception
41             else:
42                 self.__dict__[key.lower()] = functools.partial(self.__call__,
43                                                                level)
44 
45         self.format = logging.Formatter(
46             fmt='[%(asctime)-15s] [%(levelname)8s] - %(message)s')
47 
48         self.handler = logging.StreamHandler()
49         self.handler.setFormatter(self.format)
50 
51         self.logger.addHandler(self.handler)
52         self.logger.setLevel(logging.DEBUG)
53         self.logger.propagate = False
54 
55     def __call__(self, log_level: str, msg: str):
56         self.logger.log(log_level, msg)
57 
58 
59 logger = Logger()
60
```

Path: `paddlespeech/server/utils/onnx_infer.py`
Content:
```
1 # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 import os
15 from typing import Optional
16 
17 import onnxruntime as ort
18 
19 from .log import logger
20 
21 
22 def get_sess(model_path: Optional[os.PathLike]=None, sess_conf: dict=None):
23     logger.info(f"ort sessconf: {sess_conf}")
24     sess_options = ort.SessionOptions()
25     sess_options.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_ALL
26     if sess_conf.get('graph_optimization_level', 99) == 0:
27         sess_options.graph_optimization_level = ort.GraphOptimizationLevel.ORT_DISABLE_ALL
28     sess_options.execution_mode = ort.ExecutionMode.ORT_SEQUENTIAL
29 
30     # "gpu:0"
31     providers = ['CPUExecutionProvider']
32     if "gpu" in sess_conf.get("device", ""):
33         providers = ['CUDAExecutionProvider']
34         # fastspeech2/mb_melgan can't use trt now!
35         if sess_conf.get("use_trt", 0):
36             providers = ['TensorrtExecutionProvider']
37     logger.info(f"ort providers: {providers}")
38 
39     if 'cpu_threads' in sess_conf:
40         sess_options.intra_op_num_threads = sess_conf.get("cpu_threads", 0)
41     else:
42         sess_options.intra_op_num_threads = sess_conf.get(
43             "intra_op_num_threads", 0)
44 
45     sess_options.inter_op_num_threads = sess_conf.get("inter_op_num_threads", 0)
46 
47     sess = ort.InferenceSession(
48         model_path, providers=providers, sess_options=sess_options)
49     return sess
50
```

Path: `paddlespeech/server/engine/engine_factory.py`
Content:
```
1 # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 from typing import Text
15 
16 from ..utils.log import logger
17 
18 __all__ = ['EngineFactory']
19 
20 
21 class EngineFactory(object):
22     @staticmethod
23     def get_engine(engine_name: Text, engine_type: Text):
24         logger.info(f"{engine_name} : {engine_type} engine.")
25 
26         if engine_name == 'asr' and engine_type == 'inference':
27             from paddlespeech.server.engine.asr.paddleinference.asr_engine import ASREngine
28             return ASREngine()
29         elif engine_name == 'asr' and engine_type == 'python':
30             from paddlespeech.server.engine.asr.python.asr_engine import ASREngine
31             return ASREngine()
32         elif engine_name == 'asr' and engine_type == 'online':
33             from paddlespeech.server.engine.asr.online.python.asr_engine import ASREngine
34             return ASREngine()
35         elif engine_name == 'asr' and engine_type == 'online-inference':
36             from paddlespeech.server.engine.asr.online.paddleinference.asr_engine import ASREngine
37             return ASREngine()
38         elif engine_name == 'asr' and engine_type == 'online-onnx':
39             from paddlespeech.server.engine.asr.online.onnx.asr_engine import ASREngine
40             return ASREngine()
41         elif engine_name == 'tts' and engine_type == 'inference':
42             from paddlespeech.server.engine.tts.paddleinference.tts_engine import TTSEngine
43             return TTSEngine()
44         elif engine_name == 'tts' and engine_type == 'python':
45             from paddlespeech.server.engine.tts.python.tts_engine import TTSEngine
46             return TTSEngine()
47         elif engine_name == 'tts' and engine_type == 'online':
48             from paddlespeech.server.engine.tts.online.python.tts_engine import TTSEngine
49             return TTSEngine()
50         elif engine_name == 'tts' and engine_type == 'online-onnx':
51             from paddlespeech.server.engine.tts.online.onnx.tts_engine import TTSEngine
52             return TTSEngine()
53         elif engine_name == 'cls' and engine_type == 'inference':
54             from paddlespeech.server.engine.cls.paddleinference.cls_engine import CLSEngine
55             return CLSEngine()
56         elif engine_name == 'cls' and engine_type == 'python':
57             from paddlespeech.server.engine.cls.python.cls_engine import CLSEngine
58             return CLSEngine()
59         elif engine_name.lower() == 'text' and engine_type.lower() == 'python':
60             from paddlespeech.server.engine.text.python.text_engine import TextEngine
61             return TextEngine()
62         elif engine_name.lower() == 'vector' and engine_type.lower() == 'python':
63             from paddlespeech.server.engine.vector.python.vector_engine import VectorEngine
64             return VectorEngine()
65         elif engine_name.lower() == 'acs' and engine_type.lower() == 'python':
66             from paddlespeech.server.engine.acs.python.acs_engine import ACSEngine
67             return ACSEngine()
68         else:
69             return None
70
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/paddlespeech/server/engine/engine_factory.py b/paddlespeech/server/engine/engine_factory.py
--- a/paddlespeech/server/engine/engine_factory.py
+++ b/paddlespeech/server/engine/engine_factory.py
@@ -13,7 +13,7 @@
 # limitations under the License.
 from typing import Text
 
-from ..utils.log import logger
+from paddlespeech.cli.log import logger
 
 __all__ = ['EngineFactory']
 
diff --git a/paddlespeech/server/utils/log.py b/paddlespeech/server/utils/log.py
deleted file mode 100644
--- a/paddlespeech/server/utils/log.py
+++ /dev/null
@@ -1,59 +0,0 @@
-# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-import functools
-import logging
-
-__all__ = [
-    'logger',
-]
-
-
-class Logger(object):
-    def __init__(self, name: str=None):
-        name = 'PaddleSpeech' if not name else name
-        self.logger = logging.getLogger(name)
-
-        log_config = {
-            'DEBUG': 10,
-            'INFO': 20,
-            'TRAIN': 21,
-            'EVAL': 22,
-            'WARNING': 30,
-            'ERROR': 40,
-            'CRITICAL': 50,
-            'EXCEPTION': 100,
-        }
-        for key, level in log_config.items():
-            logging.addLevelName(level, key)
-            if key == 'EXCEPTION':
-                self.__dict__[key.lower()] = self.logger.exception
-            else:
-                self.__dict__[key.lower()] = functools.partial(self.__call__,
-                                                               level)
-
-        self.format = logging.Formatter(
-            fmt='[%(asctime)-15s] [%(levelname)8s] - %(message)s')
-
-        self.handler = logging.StreamHandler()
-        self.handler.setFormatter(self.format)
-
-        self.logger.addHandler(self.handler)
-        self.logger.setLevel(logging.DEBUG)
-        self.logger.propagate = False
-
-    def __call__(self, log_level: str, msg: str):
-        self.logger.log(log_level, msg)
-
-
-logger = Logger()
diff --git a/paddlespeech/server/utils/onnx_infer.py b/paddlespeech/server/utils/onnx_infer.py
--- a/paddlespeech/server/utils/onnx_infer.py
+++ b/paddlespeech/server/utils/onnx_infer.py
@@ -16,7 +16,7 @@
 
 import onnxruntime as ort
 
-from .log import logger
+from paddlespeech.cli.log import logger
 
 
 def get_sess(model_path: Optional[os.PathLike]=None, sess_conf: dict=None):

{"golden_diff": "diff --git a/paddlespeech/server/engine/engine_factory.py b/paddlespeech/server/engine/engine_factory.py\n--- a/paddlespeech/server/engine/engine_factory.py\n+++ b/paddlespeech/server/engine/engine_factory.py\n@@ -13,7 +13,7 @@\n # limitations under the License.\n from typing import Text\n \n-from ..utils.log import logger\n+from paddlespeech.cli.log import logger\n \n __all__ = ['EngineFactory']\n \ndiff --git a/paddlespeech/server/utils/log.py b/paddlespeech/server/utils/log.py\ndeleted file mode 100644\n--- a/paddlespeech/server/utils/log.py\n+++ /dev/null\n@@ -1,59 +0,0 @@\n-# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.\n-#\n-# Licensed under the Apache License, Version 2.0 (the \"License\");\n-# you may not use this file except in compliance with the License.\n-# You may obtain a copy of the License at\n-#\n-#     http://www.apache.org/licenses/LICENSE-2.0\n-#\n-# Unless required by applicable law or agreed to in writing, software\n-# distributed under the License is distributed on an \"AS IS\" BASIS,\n-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n-# See the License for the specific language governing permissions and\n-# limitations under the License.\n-import functools\n-import logging\n-\n-__all__ = [\n-    'logger',\n-]\n-\n-\n-class Logger(object):\n-    def __init__(self, name: str=None):\n-        name = 'PaddleSpeech' if not name else name\n-        self.logger = logging.getLogger(name)\n-\n-        log_config = {\n-            'DEBUG': 10,\n-            'INFO': 20,\n-            'TRAIN': 21,\n-            'EVAL': 22,\n-            'WARNING': 30,\n-            'ERROR': 40,\n-            'CRITICAL': 50,\n-            'EXCEPTION': 100,\n-        }\n-        for key, level in log_config.items():\n-            logging.addLevelName(level, key)\n-            if key == 'EXCEPTION':\n-                self.__dict__[key.lower()] = self.logger.exception\n-            else:\n-                self.__dict__[key.lower()] = functools.partial(self.__call__,\n-                                                               level)\n-\n-        self.format = logging.Formatter(\n-            fmt='[%(asctime)-15s] [%(levelname)8s] - %(message)s')\n-\n-        self.handler = logging.StreamHandler()\n-        self.handler.setFormatter(self.format)\n-\n-        self.logger.addHandler(self.handler)\n-        self.logger.setLevel(logging.DEBUG)\n-        self.logger.propagate = False\n-\n-    def __call__(self, log_level: str, msg: str):\n-        self.logger.log(log_level, msg)\n-\n-\n-logger = Logger()\ndiff --git a/paddlespeech/server/utils/onnx_infer.py b/paddlespeech/server/utils/onnx_infer.py\n--- a/paddlespeech/server/utils/onnx_infer.py\n+++ b/paddlespeech/server/utils/onnx_infer.py\n@@ -16,7 +16,7 @@\n \n import onnxruntime as ort\n \n-from .log import logger\n+from paddlespeech.cli.log import logger\n \n \n def get_sess(model_path: Optional[os.PathLike]=None, sess_conf: dict=None):\n", "issue": "develop  \u7248\u672c paddlespeech_server \u542f\u52a8\u540e\u4f1a\u6253\u5370 2 \u904d log\n```bash\r\npaddlespeech_server start --config_file ./conf/application.yaml\r\n```\r\nlog\uff1a\r\n```text\r\n[2022-06-23 06:18:31,311] [    INFO] - start to init the engine\r\n[2022-06-23 06:18:31,311] [    INFO] - start to init the engine\r\n[2022-06-23 06:18:31,312] [    INFO] - tts : python engine.\r\n[2022-06-23 06:18:31,312] [    INFO] - tts : python engine.\r\nfrom .pretrained_models import tts_dynamic_pretrained_models\r\n[2022-06-23 06:18:36,330] [    INFO] - File /home/xxx/.paddlespeech/models/fastspeech2_csmsc-zh/1.0/fastspeech2_nosil_baker_ckpt_0.4.zip md5 checking...\r\n[2022-06-23 06:18:36,330] [    INFO] - File /home/xxx/.paddlespeech/models/fastspeech2_csmsc-zh/1.0/fastspeech2_nosil_baker_ckpt_0.4.zip md5 checking...\r\n[2022-06-23 06:18:37,699] [    INFO] - /home/xxx/.paddlespeech/models/fastspeech2_csmsc-zh/1.0/fastspeech2_nosil_baker_ckpt_0.4\r\n[2022-06-23 06:18:37,699] [    INFO] - /home/xxx/.paddlespeech/models/fastspeech2_csmsc-zh/1.0/fastspeech2_nosil_baker_ckpt_0.4\r\n[2022-06-23 06:18:37,699] [    INFO] - /home/xxx/.paddlespeech/models/fastspeech2_csmsc-zh/1.0/fastspeech2_nosil_baker_ckpt_0.4/default.yaml\r\n[2022-06-23 06:18:37,699] [    INFO] - /home/xxx/.paddlespeech/models/fastspeech2_csmsc-zh/1.0/fastspeech2_nosil_baker_ckpt_0.4/default.yaml\r\n[2022-06-23 06:18:37,700] [    INFO] - /home/xxx/.paddlespeech/models/fastspeech2_csmsc-zh/1.0/fastspeech2_nosil_baker_ckpt_0.4/snapshot_iter_76000.pdz\r\n[2022-06-23 06:18:37,700] [    INFO] - /home/xxx/.paddlespeech/models/fastspeech2_csmsc-zh/1.0/fastspeech2_nosil_baker_ckpt_0.4/snapshot_iter_76000.pdz\r\n[2022-06-23 06:18:37,700] [    INFO] - File /home/xxx/.paddlespeech/models/pwgan_csmsc-zh/1.0/pwg_baker_ckpt_0.4.zip md5 checking...\r\n[2022-06-23 06:18:37,700] [    INFO] - File /home/xxx/.paddlespeech/models/pwgan_csmsc-zh/1.0/pwg_baker_ckpt_0.4.zip md5 checking...\r\n[2022-06-23 06:18:37,744] [    INFO] - /home/xxx/.paddlespeech/models/pwgan_csmsc-zh/1.0/pwg_baker_ckpt_0.4\r\n[2022-06-23 06:18:37,744] [    INFO] - /home/xxx/.paddlespeech/models/pwgan_csmsc-zh/1.0/pwg_baker_ckpt_0.4\r\n[2022-06-23 06:18:37,744] [    INFO] - /home/xxx/.paddlespeech/models/pwgan_csmsc-zh/1.0/pwg_baker_ckpt_0.4/pwg_default.yaml\r\n[2022-06-23 06:18:37,744] [    INFO] - /home/xxx/.paddlespeech/models/pwgan_csmsc-zh/1.0/pwg_baker_ckpt_0.4/pwg_default.yaml\r\n[2022-06-23 06:18:37,744] [    INFO] - /home/xxx/.paddlespeech/models/pwgan_csmsc-zh/1.0/pwg_baker_ckpt_0.4/pwg_snapshot_iter_400000.pdz\r\n[2022-06-23 06:18:37,744] [    INFO] - /home/xxx/.paddlespeech/models/pwgan_csmsc-zh/1.0/pwg_baker_ckpt_0.4/pwg_snapshot_iter_400000.pdz\r\nvocab_size: 268\r\nfrontend done!\r\n```\r\n\u6709\u95ee\u9898\u7684 commit \u53f7\uff1a\r\n```text\r\n5e03d75\r\n```\r\n\r\n\u6ca1\u95ee\u9898\u7684 commit \u53f7\uff1a\r\n```text\r\n803800\r\n```\r\n\u5f15\u8d77\u95ee\u9898\u7684 commit\r\n<img width=\"522\" alt=\"image\" src=\"https://user-images.githubusercontent.com/24568452/175233071-0cf2e8fa-78e0-4497-afa9-584b4b61c3bd.png\">\r\n\r\n\n", "before_files": [{"content": "# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nimport functools\nimport logging\n\n__all__ = [\n    'logger',\n]\n\n\nclass Logger(object):\n    def __init__(self, name: str=None):\n        name = 'PaddleSpeech' if not name else name\n        self.logger = logging.getLogger(name)\n\n        log_config = {\n            'DEBUG': 10,\n            'INFO': 20,\n            'TRAIN': 21,\n            'EVAL': 22,\n            'WARNING': 30,\n            'ERROR': 40,\n            'CRITICAL': 50,\n            'EXCEPTION': 100,\n        }\n        for key, level in log_config.items():\n            logging.addLevelName(level, key)\n            if key == 'EXCEPTION':\n                self.__dict__[key.lower()] = self.logger.exception\n            else:\n                self.__dict__[key.lower()] = functools.partial(self.__call__,\n                                                               level)\n\n        self.format = logging.Formatter(\n            fmt='[%(asctime)-15s] [%(levelname)8s] - %(message)s')\n\n        self.handler = logging.StreamHandler()\n        self.handler.setFormatter(self.format)\n\n        self.logger.addHandler(self.handler)\n        self.logger.setLevel(logging.DEBUG)\n        self.logger.propagate = False\n\n    def __call__(self, log_level: str, msg: str):\n        self.logger.log(log_level, msg)\n\n\nlogger = Logger()\n", "path": "paddlespeech/server/utils/log.py"}, {"content": "# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nimport os\nfrom typing import Optional\n\nimport onnxruntime as ort\n\nfrom .log import logger\n\n\ndef get_sess(model_path: Optional[os.PathLike]=None, sess_conf: dict=None):\n    logger.info(f\"ort sessconf: {sess_conf}\")\n    sess_options = ort.SessionOptions()\n    sess_options.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_ALL\n    if sess_conf.get('graph_optimization_level', 99) == 0:\n        sess_options.graph_optimization_level = ort.GraphOptimizationLevel.ORT_DISABLE_ALL\n    sess_options.execution_mode = ort.ExecutionMode.ORT_SEQUENTIAL\n\n    # \"gpu:0\"\n    providers = ['CPUExecutionProvider']\n    if \"gpu\" in sess_conf.get(\"device\", \"\"):\n        providers = ['CUDAExecutionProvider']\n        # fastspeech2/mb_melgan can't use trt now!\n        if sess_conf.get(\"use_trt\", 0):\n            providers = ['TensorrtExecutionProvider']\n    logger.info(f\"ort providers: {providers}\")\n\n    if 'cpu_threads' in sess_conf:\n        sess_options.intra_op_num_threads = sess_conf.get(\"cpu_threads\", 0)\n    else:\n        sess_options.intra_op_num_threads = sess_conf.get(\n            \"intra_op_num_threads\", 0)\n\n    sess_options.inter_op_num_threads = sess_conf.get(\"inter_op_num_threads\", 0)\n\n    sess = ort.InferenceSession(\n        model_path, providers=providers, sess_options=sess_options)\n    return sess\n", "path": "paddlespeech/server/utils/onnx_infer.py"}, {"content": "# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nfrom typing import Text\n\nfrom ..utils.log import logger\n\n__all__ = ['EngineFactory']\n\n\nclass EngineFactory(object):\n    @staticmethod\n    def get_engine(engine_name: Text, engine_type: Text):\n        logger.info(f\"{engine_name} : {engine_type} engine.\")\n\n        if engine_name == 'asr' and engine_type == 'inference':\n            from paddlespeech.server.engine.asr.paddleinference.asr_engine import ASREngine\n            return ASREngine()\n        elif engine_name == 'asr' and engine_type == 'python':\n            from paddlespeech.server.engine.asr.python.asr_engine import ASREngine\n            return ASREngine()\n        elif engine_name == 'asr' and engine_type == 'online':\n            from paddlespeech.server.engine.asr.online.python.asr_engine import ASREngine\n            return ASREngine()\n        elif engine_name == 'asr' and engine_type == 'online-inference':\n            from paddlespeech.server.engine.asr.online.paddleinference.asr_engine import ASREngine\n            return ASREngine()\n        elif engine_name == 'asr' and engine_type == 'online-onnx':\n            from paddlespeech.server.engine.asr.online.onnx.asr_engine import ASREngine\n            return ASREngine()\n        elif engine_name == 'tts' and engine_type == 'inference':\n            from paddlespeech.server.engine.tts.paddleinference.tts_engine import TTSEngine\n            return TTSEngine()\n        elif engine_name == 'tts' and engine_type == 'python':\n            from paddlespeech.server.engine.tts.python.tts_engine import TTSEngine\n            return TTSEngine()\n        elif engine_name == 'tts' and engine_type == 'online':\n            from paddlespeech.server.engine.tts.online.python.tts_engine import TTSEngine\n            return TTSEngine()\n        elif engine_name == 'tts' and engine_type == 'online-onnx':\n            from paddlespeech.server.engine.tts.online.onnx.tts_engine import TTSEngine\n            return TTSEngine()\n        elif engine_name == 'cls' and engine_type == 'inference':\n            from paddlespeech.server.engine.cls.paddleinference.cls_engine import CLSEngine\n            return CLSEngine()\n        elif engine_name == 'cls' and engine_type == 'python':\n            from paddlespeech.server.engine.cls.python.cls_engine import CLSEngine\n            return CLSEngine()\n        elif engine_name.lower() == 'text' and engine_type.lower() == 'python':\n            from paddlespeech.server.engine.text.python.text_engine import TextEngine\n            return TextEngine()\n        elif engine_name.lower() == 'vector' and engine_type.lower() == 'python':\n            from paddlespeech.server.engine.vector.python.vector_engine import VectorEngine\n            return VectorEngine()\n        elif engine_name.lower() == 'acs' and engine_type.lower() == 'python':\n            from paddlespeech.server.engine.acs.python.acs_engine import ACSEngine\n            return ACSEngine()\n        else:\n            return None\n", "path": "paddlespeech/server/engine/engine_factory.py"}], "after_files": [{"content": null, "path": "paddlespeech/server/utils/log.py"}, {"content": "# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nimport os\nfrom typing import Optional\n\nimport onnxruntime as ort\n\nfrom paddlespeech.cli.log import logger\n\n\ndef get_sess(model_path: Optional[os.PathLike]=None, sess_conf: dict=None):\n    logger.info(f\"ort sessconf: {sess_conf}\")\n    sess_options = ort.SessionOptions()\n    sess_options.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_ALL\n    if sess_conf.get('graph_optimization_level', 99) == 0:\n        sess_options.graph_optimization_level = ort.GraphOptimizationLevel.ORT_DISABLE_ALL\n    sess_options.execution_mode = ort.ExecutionMode.ORT_SEQUENTIAL\n\n    # \"gpu:0\"\n    providers = ['CPUExecutionProvider']\n    if \"gpu\" in sess_conf.get(\"device\", \"\"):\n        providers = ['CUDAExecutionProvider']\n        # fastspeech2/mb_melgan can't use trt now!\n        if sess_conf.get(\"use_trt\", 0):\n            providers = ['TensorrtExecutionProvider']\n    logger.info(f\"ort providers: {providers}\")\n\n    if 'cpu_threads' in sess_conf:\n        sess_options.intra_op_num_threads = sess_conf.get(\"cpu_threads\", 0)\n    else:\n        sess_options.intra_op_num_threads = sess_conf.get(\n            \"intra_op_num_threads\", 0)\n\n    sess_options.inter_op_num_threads = sess_conf.get(\"inter_op_num_threads\", 0)\n\n    sess = ort.InferenceSession(\n        model_path, providers=providers, sess_options=sess_options)\n    return sess\n", "path": "paddlespeech/server/utils/onnx_infer.py"}, {"content": "# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nfrom typing import Text\n\nfrom paddlespeech.cli.log import logger\n\n__all__ = ['EngineFactory']\n\n\nclass EngineFactory(object):\n    @staticmethod\n    def get_engine(engine_name: Text, engine_type: Text):\n        logger.info(f\"{engine_name} : {engine_type} engine.\")\n\n        if engine_name == 'asr' and engine_type == 'inference':\n            from paddlespeech.server.engine.asr.paddleinference.asr_engine import ASREngine\n            return ASREngine()\n        elif engine_name == 'asr' and engine_type == 'python':\n            from paddlespeech.server.engine.asr.python.asr_engine import ASREngine\n            return ASREngine()\n        elif engine_name == 'asr' and engine_type == 'online':\n            from paddlespeech.server.engine.asr.online.python.asr_engine import ASREngine\n            return ASREngine()\n        elif engine_name == 'asr' and engine_type == 'online-inference':\n            from paddlespeech.server.engine.asr.online.paddleinference.asr_engine import ASREngine\n            return ASREngine()\n        elif engine_name == 'asr' and engine_type == 'online-onnx':\n            from paddlespeech.server.engine.asr.online.onnx.asr_engine import ASREngine\n            return ASREngine()\n        elif engine_name == 'tts' and engine_type == 'inference':\n            from paddlespeech.server.engine.tts.paddleinference.tts_engine import TTSEngine\n            return TTSEngine()\n        elif engine_name == 'tts' and engine_type == 'python':\n            from paddlespeech.server.engine.tts.python.tts_engine import TTSEngine\n            return TTSEngine()\n        elif engine_name == 'tts' and engine_type == 'online':\n            from paddlespeech.server.engine.tts.online.python.tts_engine import TTSEngine\n            return TTSEngine()\n        elif engine_name == 'tts' and engine_type == 'online-onnx':\n            from paddlespeech.server.engine.tts.online.onnx.tts_engine import TTSEngine\n            return TTSEngine()\n        elif engine_name == 'cls' and engine_type == 'inference':\n            from paddlespeech.server.engine.cls.paddleinference.cls_engine import CLSEngine\n            return CLSEngine()\n        elif engine_name == 'cls' and engine_type == 'python':\n            from paddlespeech.server.engine.cls.python.cls_engine import CLSEngine\n            return CLSEngine()\n        elif engine_name.lower() == 'text' and engine_type.lower() == 'python':\n            from paddlespeech.server.engine.text.python.text_engine import TextEngine\n            return TextEngine()\n        elif engine_name.lower() == 'vector' and engine_type.lower() == 'python':\n            from paddlespeech.server.engine.vector.python.vector_engine import VectorEngine\n            return VectorEngine()\n        elif engine_name.lower() == 'acs' and engine_type.lower() == 'python':\n            from paddlespeech.server.engine.acs.python.acs_engine import ACSEngine\n            return ACSEngine()\n        else:\n            return None\n", "path": "paddlespeech/server/engine/engine_factory.py"}]}