# PaddleSpeech
**Repository Path**: DodoHan/PaddleSpeech
## Basic Information
- **Project Name**: PaddleSpeech
- **Description**: Easy-to-use Speech Toolkit including SOTA ASR pipeline, influential TTS with text frontend and End-to-End Speech Simultaneous Translation.
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: develop
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 113
- **Created**: 2022-03-13
- **Last Updated**: 2023-02-07
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
(简体中文|[English](./README.md))
------------------------------------------------------------------------------------
**PaddleSpeech** 是基于飞桨 [PaddlePaddle](https://github.com/PaddlePaddle/Paddle) 的语音方向的开源模型库,用于语音和音频中的各种关键任务的开发,包含大量基于深度学习前沿和有影响力的模型,一些典型的应用示例如下:
##### 语音识别
输入音频 |
识别结果 |

|
I knocked at the door on the ancient side of the building. |

|
我认为跑步最重要的就是给我带来了身体健康。 |
##### 语音翻译 (英译中)
输入音频 |
翻译结果 |

|
我 在 这栋 建筑 的 古老 门上 敲门。 |
##### 语音合成
输入文本 |
合成音频 |
Life was like a box of chocolates, you never know what you're gonna get. |

|
早上好,今天是2020/10/29,最低温度是-3°C。 |

|
季姬寂,集鸡,鸡即棘鸡。棘鸡饥叽,季姬及箕稷济鸡。鸡既济,跻姬笈,季姬忌,急咭鸡,鸡急,继圾几,季姬急,即籍箕击鸡,箕疾击几伎,伎即齑,鸡叽集几基,季姬急极屐击鸡,鸡既殛,季姬激,即记《季姬击鸡记》。 |

|
更多合成音频,可以参考 [PaddleSpeech 语音合成音频示例](https://paddlespeech.readthedocs.io/en/latest/tts/demo.html)。
##### 标点恢复
输入文本 |
输出文本 |
今天的天气真不错啊你下午有空吗我想约你一起去吃饭 |
今天的天气真不错啊!你下午有空吗?我想约你一起去吃饭。 |
### ⭐ 应用案例
- **[PaddleBoBo](https://github.com/JiehangXie/PaddleBoBo): 使用 PaddleSpeech 的语音合成模块生成虚拟人的声音。**
### 🔥 热门活动
- 2021.12.21~12.24
4 日直播课: 深度解读 PaddleSpeech 语音技术!
**直播回放与课件资料: https://aistudio.baidu.com/aistudio/education/group/info/25130**
### 特性
本项目采用了易用、高效、灵活以及可扩展的实现,旨在为工业应用、学术研究提供更好的支持,实现的功能包含训练、推断以及测试模块,以及部署过程,主要包括
- 📦 **易用性**: 安装门槛低,可使用 [CLI](#quick-start) 快速开始。
- 🏆 **对标 SoTA**: 提供了高速、轻量级模型,且借鉴了最前沿的技术。
- 💯 **基于规则的中文前端**: 我们的前端包含文本正则化和字音转换(G2P)。此外,我们使用自定义语言规则来适应中文语境。
- **多种工业界以及学术界主流功能支持**:
- 🛎️ 典型音频任务: 本工具包提供了音频任务如音频分类、语音翻译、自动语音识别、文本转语音、语音合成等任务的实现。
- 🔬 主流模型及数据集: 本工具包实现了参与整条语音任务流水线的各个模块,并且采用了主流数据集如 LibriSpeech、LJSpeech、AIShell、CSMSC,详情请见 [模型列表](#model-list)。
- 🧩 级联模型应用: 作为传统语音任务的扩展,我们结合了自然语言处理、计算机视觉等任务,实现更接近实际需求的产业级应用。
### 近期更新
- 🤗 2021.12.14: 我们在 Hugging Face Spaces 上的 [ASR](https://huggingface.co/spaces/KPatrick/PaddleSpeechASR) 以及 [TTS](https://huggingface.co/spaces/akhaliq/paddlespeech) Demos 上线啦!
- 👏🏻 2021.12.10: PaddleSpeech CLI 上线!覆盖了声音分类、语音识别、语音翻译(英译中)以及语音合成。
### 技术交流群
微信扫描二维码(好友申请通过后回复【语音】)加入官方交流群,获得更高效的问题答疑,与各行各业开发者充分交流,期待您的加入。
## Geek 快速开始
对于Geek community的成员只需要看本部分即可。
### 完成的功能
#### 提供中文语音转文字服务API (Server端)
#### 提供client端如何请求的demo
- 简单demo (只是发一句话的语音)
- 按住空格键说话的demo
### 安装
使用 [下载安装](./docs/source/install_cn.md) 中的“中等”来安装程序
### 使用
#### 不需要启动 server
##### 中文
###### a. Use wenet model
python wenetASR.py (under ./paddlespeech/mytool/wenetASR.py)
##### 英文
###### a. Use Whisper model
python useWhisperASR.py (under ./paddlespeech/mytool/useWhisperASR.py)
###### b. Use deepspeech model (not recommanded, Poor performance!!)
python deepspeechASR.py (under ./paddlespeech/mytool/deepspeechASR.py)
#### 需要启动Server
Python 运行环境 conda 3.9.7
在paddlespeech/server下运行 python server.js
API 定义是:
- shutdown: locallhost:9090/shutdown
- recognize: POST localhost:9090/asr
#### 使用client的demo 程序演示
Python 运行环境 conda 3.9.7
##### 中文
需要启动 server
a. 在paddlespeech/client下, 运行 python clientdemoSimple.py 只是一次性运行
b. 在paddlespeech/client下, 运行 python clientdemoPress2Speak.py 按住空格说话,抬起空格开始语音转文字
##### 英文
需要启动 server
a. 在paddlespeech/client下, 运行 python clientdemoSimpleEnglish.py 只是一次性运行
b. 在paddlespeech/client下, 运行 python clientdemoPress2Speak.py 按住空格说话,抬起空格开始语音转文字
注:目前英文是使用whisper model进行识别
#### 从别的机器调用Server端的中文语音转文字服务API
- 可能需要关闭防火墙 systemctl stop firewall? 目前看不需要
- 可能需要设置server.js里的IP? 目前看不需要
### 开发
#### 主要的修改
我们自己的主要的修改如下:
- 增加server及中文语音转文字服务API
paddlespeech/server -- 中文使用wenet model,英文使用whisper model
paddlespeech/mytool/wenetASR.py --中文
paddlespeech/mytool/deepspeechASR.py --英文
paddlespeech/mytool/useWhisperASR.py -- 英文 只是调用
- 增加 client端demo (paddlespeech/client)
- 修改wenet u2算法中的一些返回,并加入领域知识
在如下文件中搜索 Shore找到修改。
./paddlespeech/s2t/models/u2/u2.py
在如下文件里加入领域知识
def useRule4MeetingRoom(txt:str) in paddlespeech/server/server.py
Shore: note
修改code from /paddlespeech后 每次都要 install当前的项目:
请确保目前处于PaddleSpeech项目的根目录
pip install . -i https://pypi.tuna.tsinghua.edu.cn/simple
### 知识
#### Wenet算法 -- 中文
- wenet: 518M param as /exp/conformer/checkpoints/wenetspeech.pdparams.
- 10000+ hours training data.
- https://github.com/wenet-e2e/WenetSpeech
https://github.com/yeyupiaoling/PaddlePaddle-DeepSpeech/blob/master/docs/wenetspeech.md
original data size: 500G, to create dataset needs 3T
model is paddlespeech.s2t.models.u2.u2.U2Model
- AiShell conformer: 47M param CER(Charactor Error Rate) = 0.06 https://gitee.com/paddlepaddle/DeepSpeech/tree/develop/examples/aishell/asr1#https://gitee.com/link?target=http%3A%2F%2Farxiv.org%2Fabs%2F2008.03802 178 Hours
- The default client command shipped with PaddleSpeech uses wenet model.
- Shore read the source code and extract it to wenetASR to use it.
#### Whisper算法 -- 英文
Whisper is an automatic speech recognition (ASR) system trained on 680,000 hours of multilingual and multitask supervised data collected from the web.
https://openai.com/blog/whisper/
#### Deepspeech -- 英文
deepspeech2offline_librispeech-en-16k
LibriSpeech ASR corpus:该数据集是包含大约1000小时的英语语音的大型语料库。这些数据来自LibriVox项目的有声读物。它已被分割并正确对齐
#### 命令行
paddlespeech asr --lang zh --input ./ShoreTest/asrTest.wav
paddlespeech asr --lang en --model transformer_librispeech --input ./ShoreTest/english_sentence_1.wav
paddlespeech asr --lang en --model deepspeech2offline_librispeech --input ./ShoreTest/english_sentence_1.wav
## 安装
我们强烈建议用户在 **Linux** 环境下,*3.7* 以上版本的 *python* 上安装 PaddleSpeech。
目前为止,**Linux** 支持声音分类、语音识别、语音合成和语音翻译四种功能,**Mac OSX、 Windows** 下暂不支持语音翻译功能。 想了解具体安装细节,可以参考[安装文档](./docs/source/install_cn.md)。
## 快速开始
安装完成后,开发者可以通过命令行快速开始,改变 `--input` 可以尝试用自己的音频或文本测试。
**声音分类**
```shell
paddlespeech cls --input input.wav
```
**语音识别**
```shell
paddlespeech asr --lang zh --input input_16k.wav
```
**语音翻译** (English to Chinese)
```shell
paddlespeech st --input input_16k.wav
```
**语音合成**
```shell
paddlespeech tts --input "你好,欢迎使用百度飞桨深度学习框架!" --output output.wav
```
- 语音合成的 web demo 已经集成进了 [Huggingface Spaces](https://huggingface.co/spaces). 请参考: [TTS Demo](https://huggingface.co/spaces/akhaliq/paddlespeech)
**文本后处理**
- 标点恢复
```bash
paddlespeech text --task punc --input 今天的天气真不错啊你下午有空吗我想约你一起去吃饭
```
更多命令行命令请参考 [demos](https://github.com/PaddlePaddle/PaddleSpeech/tree/develop/demos)
> Note: 如果需要训练或者微调,请查看[语音识别](./docs/source/asr/quick_start.md), [语音合成](./docs/source/tts/quick_start.md)。
## 模型列表
PaddleSpeech 支持很多主流的模型,并提供了预训练模型,详情请见[模型列表](./docs/source/released_model.md)。
PaddleSpeech 的 **语音转文本** 包含语音识别声学模型、语音识别语言模型和语音翻译, 详情如下:
PaddleSpeech 的 **语音合成** 主要包含三个模块:文本前端、声学模型和声码器。声学模型和声码器模型如下:
**声音分类**
**标点恢复**
## 教程文档
对于 PaddleSpeech 的所关注的任务,以下指南有助于帮助开发者快速入门,了解语音相关核心思想。
- [下载安装](./docs/source/install_cn.md)
- [快速开始](#快速开始)
- Notebook基础教程
- [声音分类](./docs/tutorial/cls/cls_tutorial.ipynb)
- [语音识别](./docs/tutorial/asr/tutorial_transformer.ipynb)
- [语音翻译](./docs/tutorial/st/st_tutorial.ipynb)
- [声音合成](./docs/tutorial/tts/tts_tutorial.ipynb)
- [示例Demo](./demos/README.md)
- 进阶文档
- [语音识别自定义训练](./docs/source/asr/quick_start.md)
- [简介](./docs/source/asr/models_introduction.md)
- [数据准备](./docs/source/asr/data_preparation.md)
- [Ngram 语言模型](./docs/source/asr/ngram_lm.md)
- [语音合成自定义训练](./docs/source/tts/quick_start.md)
- [简介](./docs/source/tts/models_introduction.md)
- [进阶用法](./docs/source/tts/advanced_usage.md)
- [中文文本前端](./docs/source/tts/zh_text_frontend.md)
- [测试语音样本](https://paddlespeech.readthedocs.io/en/latest/tts/demo.html)
- [声音分类](./demos/audio_tagging/README_cn.md)
- [语音翻译](./demos/speech_translation/README_cn.md)
- [模型列表](#模型列表)
- [语音识别](#语音识别模型)
- [语音合成](#语音合成模型)
- [声音分类](#声音分类模型)
- [技术交流群](#技术交流群)
- [欢迎贡献](#欢迎贡献)
- [License](#License)
语音合成模块最初被称为 [Parakeet](https://github.com/PaddlePaddle/Parakeet),现在与此仓库合并。如果您对该任务的学术研究感兴趣,请参阅 [TTS 研究概述](https://github.com/PaddlePaddle/PaddleSpeech/tree/develop/docs/source/tts#overview)。此外,[模型介绍](https://github.com/PaddlePaddle/PaddleSpeech/blob/develop/docs/source/tts/models_introduction.md) 是了解语音合成流程的一个很好的指南。
## 引用
要引用 PaddleSpeech 进行研究,请使用以下格式进行引用。
```text
@misc{ppspeech2021,
title={PaddleSpeech, a toolkit for audio processing based on PaddlePaddle.},
author={PaddlePaddle Authors},
howpublished = {\url{https://github.com/PaddlePaddle/PaddleSpeech}},
year={2021}
}
```
## 参与 PaddleSpeech 的开发
热烈欢迎您在[Discussions](https://github.com/PaddlePaddle/PaddleSpeech/discussions) 中提交问题,并在[Issues](https://github.com/PaddlePaddle/PaddleSpeech/issues) 中指出发现的 bug。此外,我们非常希望您参与到 PaddleSpeech 的开发中!
### 贡献者
## 致谢
- 非常感谢 [yeyupiaoling](https://github.com/yeyupiaoling)/[PPASR](https://github.com/yeyupiaoling/PPASR)/[PaddlePaddle-DeepSpeech](https://github.com/yeyupiaoling/PaddlePaddle-DeepSpeech)/[VoiceprintRecognition-PaddlePaddle](https://github.com/yeyupiaoling/VoiceprintRecognition-PaddlePaddle)/[AudioClassification-PaddlePaddle](https://github.com/yeyupiaoling/AudioClassification-PaddlePaddle) 多年来的关注和建议,以及在诸多问题上的帮助。
- 非常感谢 [AK391](https://github.com/AK391) 在 Huggingface Spaces 上使用 Gradio 对我们的语音合成功能进行网页版演示。
- 非常感谢 [mymagicpower](https://github.com/mymagicpower) 采用PaddleSpeech 对 ASR 的[短语音](https://github.com/mymagicpower/AIAS/tree/main/3_audio_sdks/asr_sdk)及[长语音](https://github.com/mymagicpower/AIAS/tree/main/3_audio_sdks/asr_long_audio_sdk)进行 Java 实现。
- 非常感谢 [JiehangXie](https://github.com/JiehangXie)/[PaddleBoBo](https://github.com/JiehangXie/PaddleBoBo) 采用 PaddleSpeech 语音合成功能实现 Virtual Uploader(VUP)/Virtual YouTuber(VTuber) 虚拟主播。
- 非常感谢 [745165806](https://github.com/745165806)/[PaddleSpeechTask](https://github.com/745165806/PaddleSpeechTask) 贡献标点重建相关模型。
此外,PaddleSpeech 依赖于许多开源存储库。有关更多信息,请参阅 [references](./docs/source/reference.md)。
## License
PaddleSpeech 在 [Apache-2.0 许可](./LICENSE) 下提供。