diff --git a/speechserving/speechserving/__init__.py b/paddlespeech/server/__init__.py similarity index 100% rename from speechserving/speechserving/__init__.py rename to paddlespeech/server/__init__.py diff --git a/speechserving/speechserving/main.py b/paddlespeech/server/bin/main.py similarity index 89% rename from speechserving/speechserving/main.py rename to paddlespeech/server/bin/main.py index 6d4891c7d..af51f3f2e 100644 --- a/speechserving/speechserving/main.py +++ b/paddlespeech/server/bin/main.py @@ -12,15 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. import argparse - import uvicorn import yaml -from engine.engine_factory import EngineFactory from fastapi import FastAPI -from restful.api import setup_router -from utils.config import get_config -from utils.log import logger +from paddlespeech.server.engine.engine_factory import EngineFactory +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( title="PaddleSpeech Serving API", description="Api", version="0.0.1") diff --git a/speechserving/speechserving/bin/paddlespeech-client.py b/paddlespeech/server/bin/paddlespeech-client.py similarity index 100% rename from speechserving/speechserving/bin/paddlespeech-client.py rename to paddlespeech/server/bin/paddlespeech-client.py diff --git a/speechserving/speechserving/bin/paddlespeech-server.py b/paddlespeech/server/bin/paddlespeech-server.py similarity index 100% rename from speechserving/speechserving/bin/paddlespeech-server.py rename to paddlespeech/server/bin/paddlespeech-server.py diff --git a/speechserving/speechserving/conf/application.yaml b/paddlespeech/server/conf/application.yaml similarity index 94% rename from speechserving/speechserving/conf/application.yaml rename to paddlespeech/server/conf/application.yaml index c8d71f2f6..67cc3b34b 100644 --- a/speechserving/speechserving/conf/application.yaml +++ b/paddlespeech/server/conf/application.yaml @@ -13,5 +13,5 @@ port: 8090 engine_backend: asr: 'conf/asr/asr.yaml' - tts: 'conf/tts/tts.yaml' + tts: 'conf/tts/tts_pd.yaml' diff --git a/speechserving/speechserving/conf/asr/asr.yaml b/paddlespeech/server/conf/asr/asr.yaml similarity index 100% rename from speechserving/speechserving/conf/asr/asr.yaml rename to paddlespeech/server/conf/asr/asr.yaml diff --git a/speechserving/speechserving/conf/tts/tts.yaml b/paddlespeech/server/conf/tts/tts.yaml similarity index 100% rename from speechserving/speechserving/conf/tts/tts.yaml rename to paddlespeech/server/conf/tts/tts.yaml diff --git a/speechserving/speechserving/conf/tts/tts_pd.yaml b/paddlespeech/server/conf/tts/tts_pd.yaml similarity index 100% rename from speechserving/speechserving/conf/tts/tts_pd.yaml rename to paddlespeech/server/conf/tts/tts_pd.yaml diff --git a/speechserving/speechserving/engine/__init__.py b/paddlespeech/server/engine/__init__.py similarity index 100% rename from speechserving/speechserving/engine/__init__.py rename to paddlespeech/server/engine/__init__.py diff --git a/speechserving/speechserving/engine/asr/python/asr_engine.py b/paddlespeech/server/engine/asr/python/asr_engine.py similarity index 98% rename from speechserving/speechserving/engine/asr/python/asr_engine.py rename to paddlespeech/server/engine/asr/python/asr_engine.py index a18f906a3..b11549832 100644 --- a/speechserving/speechserving/engine/asr/python/asr_engine.py +++ b/paddlespeech/server/engine/asr/python/asr_engine.py @@ -20,7 +20,6 @@ from typing import Union import librosa import paddle import soundfile -from engine.base_engine import BaseEngine from paddlespeech.cli.asr.infer import ASRExecutor 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.utils.dynamic_import import dynamic_import 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'] diff --git a/speechserving/speechserving/engine/base_engine.py b/paddlespeech/server/engine/base_engine.py similarity index 100% rename from speechserving/speechserving/engine/base_engine.py rename to paddlespeech/server/engine/base_engine.py diff --git a/speechserving/speechserving/engine/engine_factory.py b/paddlespeech/server/engine/engine_factory.py similarity index 80% rename from speechserving/speechserving/engine/engine_factory.py rename to paddlespeech/server/engine/engine_factory.py index bc0c45656..79319fd95 100644 --- a/speechserving/speechserving/engine/engine_factory.py +++ b/paddlespeech/server/engine/engine_factory.py @@ -13,8 +13,9 @@ # limitations under the License. from typing import Text -from engine.asr.python.asr_engine import ASREngine -from engine.tts.python.tts_engine import TTSEngine +from paddlespeech.server.engine.asr.python.asr_engine import ASREngine +#from paddlespeech.server.engine.tts.python.tts_engine import TTSEngine +from paddlespeech.server.engine.tts.paddleinference.tts_engine import TTSEngine __all__ = ['EngineFactory'] diff --git a/speechserving/speechserving/engine/tts/paddleinference/tts_engine.py b/paddlespeech/server/engine/tts/paddleinference/tts_engine.py similarity index 97% rename from speechserving/speechserving/engine/tts/paddleinference/tts_engine.py rename to paddlespeech/server/engine/tts/paddleinference/tts_engine.py index 2ab8bcb45..fbaf372b4 100644 --- a/speechserving/speechserving/engine/tts/paddleinference/tts_engine.py +++ b/paddlespeech/server/engine/tts/paddleinference/tts_engine.py @@ -20,7 +20,6 @@ import librosa import numpy as np import paddle import soundfile as sf -from engine.base_engine import BaseEngine from scipy.io import wavfile 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.t2s.frontend import English from paddlespeech.t2s.frontend.zh_frontend import Frontend -from utils.audio_process import change_speed -from utils.config import get_config -from utils.errors import ErrorCode -from utils.exception import ServerBaseException -from utils.paddle_predictor import init_predictor -from utils.paddle_predictor import run_model +from paddlespeech.server.engine.base_engine import BaseEngine +from paddlespeech.server.utils.audio_process import change_speed +from paddlespeech.server.utils.config import get_config +from paddlespeech.server.utils.errors import ErrorCode +from paddlespeech.server.utils.exception import ServerBaseException +from paddlespeech.server.utils.paddle_predictor import init_predictor +from paddlespeech.server.utils.paddle_predictor import run_model __all__ = ['TTSEngine'] @@ -339,7 +339,7 @@ class TTSEngine(BaseEngine): """ super(TTSEngine, self).__init__() - def init(self, config_file: str): + def init(self, config_file: str) -> bool: self.executor = TTSServerExecutor() self.config_file = config_file self.config = get_config(config_file) @@ -361,6 +361,7 @@ class TTSEngine(BaseEngine): voc_predictor_conf=self.config.voc_predictor_conf, ) logger.info("Initialize TTS server engine successfully.") + return True def postprocess(self, wav, diff --git a/speechserving/speechserving/engine/tts/python/tts_engine.py b/paddlespeech/server/engine/tts/python/tts_engine.py similarity index 94% rename from speechserving/speechserving/engine/tts/python/tts_engine.py rename to paddlespeech/server/engine/tts/python/tts_engine.py index 32a0dca32..b323551b1 100644 --- a/speechserving/speechserving/engine/tts/python/tts_engine.py +++ b/paddlespeech/server/engine/tts/python/tts_engine.py @@ -17,15 +17,15 @@ import io import librosa import numpy as np import soundfile as sf -from engine.base_engine import BaseEngine from scipy.io import wavfile from paddlespeech.cli.log import logger from paddlespeech.cli.tts.infer import TTSExecutor -from utils.audio_process import change_speed -from utils.config import get_config -from utils.errors import ErrorCode -from utils.exception import ServerBaseException +from paddlespeech.server.utils.audio_process import change_speed +from paddlespeech.server.engine.base_engine import BaseEngine +from paddlespeech.server.utils.config import get_config +from paddlespeech.server.utils.errors import ErrorCode +from paddlespeech.server.utils.exception import ServerBaseException __all__ = ['TTSEngine'] @@ -48,7 +48,7 @@ class TTSEngine(BaseEngine): """ super(TTSEngine, self).__init__() - def init(self, config_file: str): + def init(self, config_file: str) -> bool: self.executor = TTSServerExecutor() self.config_file = config_file self.config = get_config(config_file) @@ -68,6 +68,7 @@ class TTSEngine(BaseEngine): lang=self.config.lang) logger.info("Initialize TTS server engine successfully.") + return True def postprocess(self, wav, diff --git a/speechserving/speechserving/restful/__init__.py b/paddlespeech/server/restful/__init__.py similarity index 100% rename from speechserving/speechserving/restful/__init__.py rename to paddlespeech/server/restful/__init__.py diff --git a/speechserving/speechserving/restful/api.py b/paddlespeech/server/restful/api.py similarity index 87% rename from speechserving/speechserving/restful/api.py rename to paddlespeech/server/restful/api.py index bdff935ac..9ce5cad0e 100644 --- a/speechserving/speechserving/restful/api.py +++ b/paddlespeech/server/restful/api.py @@ -15,8 +15,8 @@ from typing import List from fastapi import APIRouter -from .asr_api import router as asr_router -from .tts_api import router as tts_router +from paddlespeech.server.restful.asr_api import router as asr_router +from paddlespeech.server.restful.tts_api import router as tts_router _router = APIRouter() diff --git a/speechserving/speechserving/restful/asr_api.py b/paddlespeech/server/restful/asr_api.py similarity index 82% rename from speechserving/speechserving/restful/asr_api.py rename to paddlespeech/server/restful/asr_api.py index c63cd76c2..fcdb2f41f 100644 --- a/speechserving/speechserving/restful/asr_api.py +++ b/paddlespeech/server/restful/asr_api.py @@ -14,16 +14,15 @@ import base64 import traceback from typing import Union - -from engine.asr.python.asr_engine import ASREngine from fastapi import APIRouter -from .request import ASRRequest -from .response import ASRResponse -from .response import ErrorResponse -from utils.errors import ErrorCode -from utils.errors import failed_response -from utils.exception import ServerBaseException +from paddlespeech.server.engine.asr.python.asr_engine import ASREngine +from paddlespeech.server.restful.request import ASRRequest +from paddlespeech.server.restful.response import ASRResponse +from paddlespeech.server.restful.response import ErrorResponse +from paddlespeech.server.utils.errors import ErrorCode +from paddlespeech.server.utils.errors import failed_response +from paddlespeech.server.utils.exception import ServerBaseException router = APIRouter() diff --git a/speechserving/speechserving/restful/request.py b/paddlespeech/server/restful/request.py similarity index 100% rename from speechserving/speechserving/restful/request.py rename to paddlespeech/server/restful/request.py diff --git a/speechserving/speechserving/restful/response.py b/paddlespeech/server/restful/response.py similarity index 100% rename from speechserving/speechserving/restful/response.py rename to paddlespeech/server/restful/response.py diff --git a/speechserving/speechserving/restful/tts_api.py b/paddlespeech/server/restful/tts_api.py similarity index 84% rename from speechserving/speechserving/restful/tts_api.py rename to paddlespeech/server/restful/tts_api.py index a160e31dc..36c4be628 100644 --- a/speechserving/speechserving/restful/tts_api.py +++ b/paddlespeech/server/restful/tts_api.py @@ -13,16 +13,16 @@ # limitations under the License. import traceback from typing import Union - -from engine.tts.python.tts_engine import TTSEngine from fastapi import APIRouter -from .request import TTSRequest -from .response import ErrorResponse -from .response import TTSResponse -from utils.errors import ErrorCode -from utils.errors import failed_response -from utils.exception import ServerBaseException +#from paddlespeech.server.engine.tts.python.tts_engine import TTSEngine +from paddlespeech.server.engine.tts.paddleinference.tts_engine import TTSEngine +from paddlespeech.server.restful.request import TTSRequest +from paddlespeech.server.restful.response import ErrorResponse +from paddlespeech.server.restful.response import TTSResponse +from paddlespeech.server.utils.errors import ErrorCode +from paddlespeech.server.utils.errors import failed_response +from paddlespeech.server.utils.exception import ServerBaseException router = APIRouter() diff --git a/speechserving/tests/16_audio.wav b/paddlespeech/server/tests/16_audio.wav similarity index 100% rename from speechserving/tests/16_audio.wav rename to paddlespeech/server/tests/16_audio.wav diff --git a/speechserving/tests/http_client.py b/paddlespeech/server/tests/http_client.py similarity index 100% rename from speechserving/tests/http_client.py rename to paddlespeech/server/tests/http_client.py diff --git a/speechserving/tests/tts/test_client.py b/paddlespeech/server/tests/tts/test_client.py similarity index 93% rename from speechserving/tests/tts/test_client.py rename to paddlespeech/server/tests/tts/test_client.py index 71fb36d97..65f4ccfec 100644 --- a/speechserving/tests/tts/test_client.py +++ b/paddlespeech/server/tests/tts/test_client.py @@ -23,14 +23,7 @@ import numpy as np import requests import soundfile - -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) - +from paddlespeech.server.utils.audio_process import wav2pcm # Request and response def tts_client(args): diff --git a/speechserving/speechserving/utils/__init__.py b/paddlespeech/server/utils/__init__.py similarity index 100% rename from speechserving/speechserving/utils/__init__.py rename to paddlespeech/server/utils/__init__.py diff --git a/speechserving/speechserving/utils/audio_process.py b/paddlespeech/server/utils/audio_process.py similarity index 100% rename from speechserving/speechserving/utils/audio_process.py rename to paddlespeech/server/utils/audio_process.py diff --git a/speechserving/speechserving/utils/config.py b/paddlespeech/server/utils/config.py similarity index 100% rename from speechserving/speechserving/utils/config.py rename to paddlespeech/server/utils/config.py diff --git a/speechserving/speechserving/utils/errors.py b/paddlespeech/server/utils/errors.py similarity index 100% rename from speechserving/speechserving/utils/errors.py rename to paddlespeech/server/utils/errors.py diff --git a/speechserving/speechserving/utils/exception.py b/paddlespeech/server/utils/exception.py similarity index 94% rename from speechserving/speechserving/utils/exception.py rename to paddlespeech/server/utils/exception.py index 03a6deee2..58ea777ca 100644 --- a/speechserving/speechserving/utils/exception.py +++ b/paddlespeech/server/utils/exception.py @@ -13,7 +13,7 @@ # limitations under the License. import traceback -from utils.errors import ErrorMsg +from paddlespeech.server.utils.errors import ErrorMsg class ServerBaseException(Exception): diff --git a/speechserving/speechserving/utils/log.py b/paddlespeech/server/utils/log.py similarity index 100% rename from speechserving/speechserving/utils/log.py rename to paddlespeech/server/utils/log.py diff --git a/speechserving/speechserving/utils/paddle_predictor.py b/paddlespeech/server/utils/paddle_predictor.py similarity index 100% rename from speechserving/speechserving/utils/paddle_predictor.py rename to paddlespeech/server/utils/paddle_predictor.py diff --git a/speechserving/speechserving/utils/util.py b/paddlespeech/server/utils/util.py similarity index 100% rename from speechserving/speechserving/utils/util.py rename to paddlespeech/server/utils/util.py diff --git a/speechserving/setup.py b/speechserving/setup.py deleted file mode 100644 index 97043fd7b..000000000 --- a/speechserving/setup.py +++ /dev/null @@ -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. diff --git a/speechserving/speechserving/bin/main.py b/speechserving/speechserving/bin/main.py deleted file mode 100644 index 97043fd7b..000000000 --- a/speechserving/speechserving/bin/main.py +++ /dev/null @@ -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.