Merge pull request #1454 from lym0302/move-dir2

[server] move dir
pull/1466/head
Hui Zhang 3 years ago committed by GitHub
commit 0d1f90adc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -12,15 +12,14 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import argparse import argparse
import uvicorn import uvicorn
import yaml import yaml
from engine.engine_factory import EngineFactory
from fastapi import FastAPI from fastapi import FastAPI
from restful.api import setup_router
from utils.config import get_config from paddlespeech.server.engine.engine_factory import EngineFactory
from utils.log import logger from paddlespeech.server.restful.api import setup_router
from paddlespeech.server.utils.config import get_config
from paddlespeech.server.utils.log import logger
app = FastAPI( app = FastAPI(
title="PaddleSpeech Serving API", description="Api", version="0.0.1") title="PaddleSpeech Serving API", description="Api", version="0.0.1")

@ -13,5 +13,5 @@ port: 8090
engine_backend: engine_backend:
asr: 'conf/asr/asr.yaml' asr: 'conf/asr/asr.yaml'
tts: 'conf/tts/tts.yaml' tts: 'conf/tts/tts_pd.yaml'

@ -20,7 +20,6 @@ from typing import Union
import librosa import librosa
import paddle import paddle
import soundfile import soundfile
from engine.base_engine import BaseEngine
from paddlespeech.cli.asr.infer import ASRExecutor from paddlespeech.cli.asr.infer import ASRExecutor
from paddlespeech.cli.log import logger from paddlespeech.cli.log import logger
@ -28,7 +27,8 @@ from paddlespeech.s2t.frontend.featurizer.text_featurizer import TextFeaturizer
from paddlespeech.s2t.transform.transformation import Transformation from paddlespeech.s2t.transform.transformation import Transformation
from paddlespeech.s2t.utils.dynamic_import import dynamic_import from paddlespeech.s2t.utils.dynamic_import import dynamic_import
from paddlespeech.s2t.utils.utility import UpdateConfig from paddlespeech.s2t.utils.utility import UpdateConfig
from utils.config import get_config from paddlespeech.server.engine.base_engine import BaseEngine
from paddlespeech.server.utils.config import get_config
__all__ = ['ASREngine'] __all__ = ['ASREngine']

@ -13,8 +13,9 @@
# limitations under the License. # limitations under the License.
from typing import Text from typing import Text
from engine.asr.python.asr_engine import ASREngine from paddlespeech.server.engine.asr.python.asr_engine import ASREngine
from engine.tts.python.tts_engine import TTSEngine #from paddlespeech.server.engine.tts.python.tts_engine import TTSEngine
from paddlespeech.server.engine.tts.paddleinference.tts_engine import TTSEngine
__all__ = ['EngineFactory'] __all__ = ['EngineFactory']

@ -20,7 +20,6 @@ import librosa
import numpy as np import numpy as np
import paddle import paddle
import soundfile as sf import soundfile as sf
from engine.base_engine import BaseEngine
from scipy.io import wavfile from scipy.io import wavfile
from paddlespeech.cli.log import logger from paddlespeech.cli.log import logger
@ -29,12 +28,13 @@ from paddlespeech.cli.utils import download_and_decompress
from paddlespeech.cli.utils import MODEL_HOME from paddlespeech.cli.utils import MODEL_HOME
from paddlespeech.t2s.frontend import English from paddlespeech.t2s.frontend import English
from paddlespeech.t2s.frontend.zh_frontend import Frontend from paddlespeech.t2s.frontend.zh_frontend import Frontend
from utils.audio_process import change_speed from paddlespeech.server.engine.base_engine import BaseEngine
from utils.config import get_config from paddlespeech.server.utils.audio_process import change_speed
from utils.errors import ErrorCode from paddlespeech.server.utils.config import get_config
from utils.exception import ServerBaseException from paddlespeech.server.utils.errors import ErrorCode
from utils.paddle_predictor import init_predictor from paddlespeech.server.utils.exception import ServerBaseException
from utils.paddle_predictor import run_model from paddlespeech.server.utils.paddle_predictor import init_predictor
from paddlespeech.server.utils.paddle_predictor import run_model
__all__ = ['TTSEngine'] __all__ = ['TTSEngine']
@ -339,7 +339,7 @@ class TTSEngine(BaseEngine):
""" """
super(TTSEngine, self).__init__() super(TTSEngine, self).__init__()
def init(self, config_file: str): def init(self, config_file: str) -> bool:
self.executor = TTSServerExecutor() self.executor = TTSServerExecutor()
self.config_file = config_file self.config_file = config_file
self.config = get_config(config_file) self.config = get_config(config_file)
@ -361,6 +361,7 @@ class TTSEngine(BaseEngine):
voc_predictor_conf=self.config.voc_predictor_conf, ) voc_predictor_conf=self.config.voc_predictor_conf, )
logger.info("Initialize TTS server engine successfully.") logger.info("Initialize TTS server engine successfully.")
return True
def postprocess(self, def postprocess(self,
wav, wav,

@ -17,15 +17,15 @@ import io
import librosa import librosa
import numpy as np import numpy as np
import soundfile as sf import soundfile as sf
from engine.base_engine import BaseEngine
from scipy.io import wavfile from scipy.io import wavfile
from paddlespeech.cli.log import logger from paddlespeech.cli.log import logger
from paddlespeech.cli.tts.infer import TTSExecutor from paddlespeech.cli.tts.infer import TTSExecutor
from utils.audio_process import change_speed from paddlespeech.server.utils.audio_process import change_speed
from utils.config import get_config from paddlespeech.server.engine.base_engine import BaseEngine
from utils.errors import ErrorCode from paddlespeech.server.utils.config import get_config
from utils.exception import ServerBaseException from paddlespeech.server.utils.errors import ErrorCode
from paddlespeech.server.utils.exception import ServerBaseException
__all__ = ['TTSEngine'] __all__ = ['TTSEngine']
@ -48,7 +48,7 @@ class TTSEngine(BaseEngine):
""" """
super(TTSEngine, self).__init__() super(TTSEngine, self).__init__()
def init(self, config_file: str): def init(self, config_file: str) -> bool:
self.executor = TTSServerExecutor() self.executor = TTSServerExecutor()
self.config_file = config_file self.config_file = config_file
self.config = get_config(config_file) self.config = get_config(config_file)
@ -68,6 +68,7 @@ class TTSEngine(BaseEngine):
lang=self.config.lang) lang=self.config.lang)
logger.info("Initialize TTS server engine successfully.") logger.info("Initialize TTS server engine successfully.")
return True
def postprocess(self, def postprocess(self,
wav, wav,

@ -15,8 +15,8 @@ from typing import List
from fastapi import APIRouter from fastapi import APIRouter
from .asr_api import router as asr_router from paddlespeech.server.restful.asr_api import router as asr_router
from .tts_api import router as tts_router from paddlespeech.server.restful.tts_api import router as tts_router
_router = APIRouter() _router = APIRouter()

@ -14,16 +14,15 @@
import base64 import base64
import traceback import traceback
from typing import Union from typing import Union
from engine.asr.python.asr_engine import ASREngine
from fastapi import APIRouter from fastapi import APIRouter
from .request import ASRRequest from paddlespeech.server.engine.asr.python.asr_engine import ASREngine
from .response import ASRResponse from paddlespeech.server.restful.request import ASRRequest
from .response import ErrorResponse from paddlespeech.server.restful.response import ASRResponse
from utils.errors import ErrorCode from paddlespeech.server.restful.response import ErrorResponse
from utils.errors import failed_response from paddlespeech.server.utils.errors import ErrorCode
from utils.exception import ServerBaseException from paddlespeech.server.utils.errors import failed_response
from paddlespeech.server.utils.exception import ServerBaseException
router = APIRouter() router = APIRouter()

@ -13,16 +13,16 @@
# limitations under the License. # limitations under the License.
import traceback import traceback
from typing import Union from typing import Union
from engine.tts.python.tts_engine import TTSEngine
from fastapi import APIRouter from fastapi import APIRouter
from .request import TTSRequest #from paddlespeech.server.engine.tts.python.tts_engine import TTSEngine
from .response import ErrorResponse from paddlespeech.server.engine.tts.paddleinference.tts_engine import TTSEngine
from .response import TTSResponse from paddlespeech.server.restful.request import TTSRequest
from utils.errors import ErrorCode from paddlespeech.server.restful.response import ErrorResponse
from utils.errors import failed_response from paddlespeech.server.restful.response import TTSResponse
from utils.exception import ServerBaseException from paddlespeech.server.utils.errors import ErrorCode
from paddlespeech.server.utils.errors import failed_response
from paddlespeech.server.utils.exception import ServerBaseException
router = APIRouter() router = APIRouter()

@ -23,14 +23,7 @@ import numpy as np
import requests import requests
import soundfile import soundfile
from paddlespeech.server.utils.audio_process import wav2pcm
def wav2pcm(wavfile: str, pcmfile: str, data_type=np.int16):
with open(wavfile, "rb") as f:
f.seek(0)
f.read(44)
data = np.fromfile(f, dtype=data_type)
data.tofile(pcmfile)
# Request and response # Request and response
def tts_client(args): def tts_client(args):

@ -13,7 +13,7 @@
# limitations under the License. # limitations under the License.
import traceback import traceback
from utils.errors import ErrorMsg from paddlespeech.server.utils.errors import ErrorMsg
class ServerBaseException(Exception): class ServerBaseException(Exception):

@ -1,13 +0,0 @@
# 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.

@ -1,13 +0,0 @@
# 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.
Loading…
Cancel
Save