Update paddlespeech-deploy.md

This commit is contained in:
Alireza Jahanshahlou 2025-10-12 17:36:15 +03:30 committed by GitHub
parent 8ea10d6007
commit 3b5a146740
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,64 +1,64 @@
# PaddleSpeechTTS集成xiaozhi服务
# PaddleSpeechTTS integrates xiaozhi service
## 重点说明
- 优点:本地离线部署、速度快
- 缺点:截止2025年9月25日,默认的模型是中文模型,不支持英文转语音。如果含英文会发不出声音,如需同时支持中英文需要自己训练。
## Key Points
- Advantages: local offline deployment, fast speed
- Disadvantages: As of September 25, 2025, the default model is the Chinese model and does not support English-to-speech conversion. If English is included, no sound will be produced. If you need to support both Chinese and English, you need to train it yourself.
## 一、基础环境要求
操作系统:Windows / Linux / WSL 2
## 1. Basic environment requirements
Operating System: Windows / Linux / WSL 2
Python 版本:3.9以上(请根据Paddle官方教程调整)
Python version: 3.9 or above (please adjust according to the Paddle official tutorial)
Paddle 版本:官方最新版本 ```https://www.paddlepaddle.org.cn/install```
Paddle version: Official latest version ```https://www.paddlepaddle.org.cn/install```
依赖管理工具:conda 或 venv
Dependency management tools: conda or venv
## 二、启动paddlespeech服务
### 1.从paddlespeech官方仓库拉取源码
## 2. Start the paddlespeech service
### 1. Pull the source code from the paddlespeech official repository
```bash
git clone https://github.com/PaddlePaddle/PaddleSpeech.git
```
### 2.建立虚拟环境
### 2. Create a virtual environment
```bash
conda create -n paddle_env python=3.10 -y
conda activate paddle_env
```
### 3.安装paddle
因CPU架构、GPU架构不同,请根据Paddle官方支持的python版本建立环境
### 3. Install paddle
Due to different CPU and GPU architectures, please build the environment according to the Python version officially supported by Paddle.
```
https://www.paddlepaddle.org.cn/install
```
### 4.进入paddlespeech目录
### 4. Enter the paddlespeech directory
```bash
cd PaddleSpeech
```
### 5.安装paddlespeech
### 5. Install paddlespeech
```bash
pip install pytest-runner -i https://pypi.tuna.tsinghua.edu.cn/simple
#以下命令使用任意一个
#The following commands use any one
pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple
pip install paddlespeech -i https://pypi.tuna.tsinghua.edu.cn/simple
```
### 6.使用命令自动下载语音模型
### 6. Use commands to automatically download the voice model
```bash
paddlespeech tts --input "你好,这是一次测试"
paddlespeech tts --input "Hello, this is a test"
```
此步骤会自动下载模型缓存至本地 .paddlespeech/models 目录
This step will automatically download the model cache to the local .paddlespeech/models directory
### 7.修改tts_online_application.yaml配置
参考目录 ```"PaddleSpeech\demos\streaming_tts_server\conf\tts_online_application.yaml"```
选择```tts_online_application.yaml```文件用编辑器打开,设置```protocol```为```websocket```
### 7. Modify tts_online_application.yaml configuration
Reference directory ```"PaddleSpeech\demos\streaming_tts_server\conf\tts_online_application.yaml"```
Select ```tts_online_application.yaml``` file and open it with an editor. Set ```protocol``` to ```websocket```
### 8.启动服务
### 8. Start the service
```yaml
paddlespeech_server start --config_file ./demos/streaming_tts_server/conf/tts_online_application.yaml
#官方默认启动命令:
#Official default startup command:
paddlespeech_server start --config_file ./conf/tts_online_application.yaml
```
请根据你的```tts_online_application.yaml```的实际目录来启动命令,看到如下日志即启动成功
Please start the command according to the actual directory of your ```tts_online_application.yaml```. The startup is successful when you see the following log
```
Prefix dict has been built successfully.
[2025-08-07 10:03:11,312] [ DEBUG] __init__.py:166 - Prefix dict has been built successfully.
@ -68,11 +68,11 @@ INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:8092 (Press CTRL+C to quit)
```
## 三、修改小智的配置文件
## 3. Modify Xiaozhi's configuration file
### 1.```main/xiaozhi-server/core/providers/tts/paddle_speech.py```
### 2.```main/xiaozhi-server/data/.config.yaml```
使用单模块部署
Using single module deployment
```yaml
selected_module:
TTS: PaddleSpeechTTS
@ -80,24 +80,24 @@ TTS:
PaddleSpeechTTS:
type: paddle_speech
protocol: websocket
url: ws://127.0.0.1:8092/paddlespeech/tts/streaming # TTS 服务的 URL 地址,指向本地服务器 [websocket默认ws://127.0.0.1:8092/paddlespeech/tts/streaming]
spk_id: 0 # 发音人 ID,0 通常表示默认的发音人
sample_rate: 24000 # 采样率 [websocket默认24000,http默认0 自动选择]
speed: 1.0 # 语速,1.0 表示正常语速,>1 表示加快,<1 表示减慢
volume: 1.0 # 音量,1.0 表示正常音量,>1 表示增大,<1 表示减小
save_path: # 保存路径
url: ws://127.0.0.1:8092/paddlespeech/tts/streaming # URL of TTS service, pointing to local server [websocket default is ws://127.0.0.1:8092/paddlespeech/tts/streaming]
spk_id: 0 # Pronouncer ID, 0 usually indicates the default speaker
sample_rate: 24000 # sampling rate [websocket default is 24000, http default is 0 automatic selection]
speed: 1.0 # speaking speed, 1.0 means normal speaking speed, >1 means faster speaking speed, <1 means slower speaking speed
volume: 1.0 # volume, 1.0 means normal volume, >1 means increase, <1 means decrease
save_path: # Save path
```
### 3.启动xiaozhi服务
### 3. Start the xiaozhi service
```py
python app.py
```
打开test目录下的test_page.html,测试连接和发送消息时paddlespeech端是否有输出日志
Open test_page.html in the test directory to test the connection and whether there is output log on the paddlespeech side when sending messages
输出日志参考:
Output log reference:
```
INFO: 127.0.0.1:44312 - "WebSocket /paddlespeech/tts/streaming" [accepted]
INFO: connection open
[2025-08-07 11:16:33,355] [ INFO] - sentence: 哈哈,怎么突然找我聊天啦?
[2025-08-07 11:16:33,355] [ INFO] - sentence: Haha, why are you suddenly chatting with me?
[2025-08-07 11:16:33,356] [ INFO] - The durations of audio is: 2.4625 s
[2025-08-07 11:16:33,356] [ INFO] - first response time: 0.1143045425415039 s
[2025-08-07 11:16:33,356] [ INFO] - final response time: 0.4777836799621582 s