move dir, test=doc

pull/1454/head
lym0302 3 years ago
parent 76391275fc
commit 07158b2f12

@ -16,10 +16,10 @@ import uvicorn
import yaml import yaml
from fastapi import FastAPI from fastapi import FastAPI
from engine.engine_factory import EngineFactory from paddlespeech.server.engine.engine_factory import EngineFactory
from restful.api import setup_router from paddlespeech.server.restful.api import setup_router
from utils.config import get_config from paddlespeech.server.utils.config import get_config
from utils.log import logger 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")

@ -12,6 +12,6 @@ port: 8090
# add engine type (Options: asr, tts) and config file here. # add engine type (Options: asr, tts) and config file here.
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']

@ -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']

@ -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()

@ -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,25 +0,0 @@
# PaddleSpeech Server
## The environment variables
The path.sh contains the environment variable.
```bash
source ./bin/path.sh
```
## Add engine_backend on conf/application.yaml
```
engine_backend:
asr: 'conf/asr/asr.yaml'
[server name]: [conf yaml file]
```
Currently supporting asr and tts services.
## Start service(command line todo)
```bash
python ./bin/main.py
```
## Client access
Refer to `../tests`

@ -1,3 +0,0 @@
export MAIN_ROOT=`realpath ${PWD}/../`
export PYTHONIOENCODING=UTF-8
export PYTHONPATH=${MAIN_ROOT}:${PYTHONPATH}

@ -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):
Loading…
Cancel
Save