一、参考
【PaddleSpeech】Speech Server 一键部署语音服务 —— 端到端服务篇
创建conda环境
conda create -n paddlespeech python=3.9
conda activate paddlespeech
安装
下载源码
mkdir /home/aistudio
git clone -b r1.2 https://gitee.com/paddlepaddle/PaddleSpeech
安装依赖
pip install pytest-runner -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install . -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install uvicorn==0.18.3
# 不是必须,如果启动报错,则需要安装
yum install -y libsndfile
删除软连接
# 删除软链接
# aistudio会报错: paddlespeech 的 repo中存在失效软链接
# 执行下面这行命令!!
find -L /home/aistudio -type l -delete
nltk数据
# 进入主目录
cd /home/aistudio
# 下载nltk数据包,放入到nltk可以检索的路径下
wget -P data https://paddlespeech.bj.bcebos.com/Parakeet/tools/nltk_data.tar.gz
tar zxvf data/nltk_data.tar.gz
# 下载示例音频
wget -c https://paddlespeech.bj.bcebos.com/PaddleAudio/zh.wav
并且把nltk_data拷贝到root目录,避免运行时重复下载超时
1. 一键开启五种后端服务
这里Server开启哪些服务,主要是由/home/aistudio/PaddleSpeech/paddlespeech/server/conf/application.yaml
文件控制,这里先带大家一起解读这个文件。
host: 0.0.0.0
port: 8090
# The task format in the engin_list is: <speech task>_<engine type>
# task choices = ['asr_python', 'asr_inference', 'tts_python', 'tts_inference', 'cls_python', 'cls_inference']
protocol: 'http'
engine_list: ['asr_python', 'tts_python', 'cls_python', 'text_python', 'vector_python']
- host定义的是主机的网络服务信息
- port开启8090端口
- protocol定义了协议类型为http
- engine_list表示开启了哪些服务类型,我们可以看到开启了asr(语音识别),tts(语音合成),cls(声音分类),text(标点恢复),vector(声纹向量提取)
如果我们只想开启其中某个服务,只需修改engine_list配置参数,只保留对应项即可
1.1 开启服务
在aistudo中新建终端(点击左上方↖加号键,新建终端),开启服务
# 进入根目录
cd /home/aistudio/PaddleSpeech
# 开启服务
paddlespeech_server start --config_file ./paddlespeech/server/conf/application.yaml
出现以下输出,表示服务开启成功
INFO: Started server process [4697]
[2022-07-29 14:19:03] [INFO] [server.py:75] Started server process [4697]
INFO: Waiting for application startup.
[2022-07-29 14:19:03] [INFO] [on.py:47] Waiting for application startup.
INFO: Application startup complete.
[2022-07-29 14:19:03] [INFO] [on.py:61] Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:8090 (Press CTRL+C to quit)
[2022-07-29 14:19:03] [INFO] [server.py:212] Uvicorn running on http://0.0.0.0:8090 (Press CTRL+C to quit)
调用
<!doctype html>
<html lang="zh-cmn-Hans-CN">
<head>
<style type="text/css">
.background {
display: block;
width: 100%;
height: 100%