[Server] added engine factory and config (#1399)
* added engine other works, test=server * fix comments, test=docpull/1415/head
parent
450a4719a0
commit
b5a2675e2b
@ -0,0 +1,4 @@
|
||||
model: 'conformer_wenetspeech'
|
||||
lang: 'zh'
|
||||
sample_rate: 16000
|
||||
decode_method: 'attention_rescoring'
|
@ -0,0 +1,26 @@
|
||||
# Copyright (c) 2022 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.
|
||||
from engine.asr.python.asr_engine import ASREngine
|
||||
from engine.tts.python.tts_engine import TTSEngine
|
||||
|
||||
|
||||
class EngineFactory(object):
|
||||
@staticmethod
|
||||
def get_engine(engine_name):
|
||||
if engine_name == 'asr':
|
||||
return ASREngine()
|
||||
elif engine_name == 'tts':
|
||||
return TTSEngine()
|
||||
else:
|
||||
return None
|
@ -0,0 +1,30 @@
|
||||
# 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 yaml
|
||||
from yacs.config import CfgNode
|
||||
|
||||
|
||||
def get_config(config_file):
|
||||
"""[summary]
|
||||
|
||||
Args:
|
||||
config_file (str): config_file
|
||||
|
||||
Returns:
|
||||
CfgNode:
|
||||
"""
|
||||
with open(config_file, 'rt') as f:
|
||||
config = CfgNode(yaml.safe_load(f))
|
||||
|
||||
return config
|
@ -0,0 +1,35 @@
|
||||
# Copyright (c) 2022 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
|
||||
import base64
|
||||
|
||||
|
||||
def wav2base64(wav_file):
|
||||
"""
|
||||
read wave file and covert to base64 string
|
||||
"""
|
||||
with open(wav_file, 'rb') as f:
|
||||
base64_bytes = base64.b64encode(f.read())
|
||||
base64_string = base64_bytes.decode('utf-8')
|
||||
return base64_string
|
||||
|
||||
|
||||
def base64towav(base64_string):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
def self_check():
|
||||
""" self check resource
|
||||
"""
|
||||
return True
|
Loading…
Reference in new issue