(简体中文|English)
PaddleSpeech 是基于飞桨 PaddlePaddle 的语音方向的开源模型库,用于语音和音频中的各种关键任务的开发,包含大量基于深度学习前沿和有影响力的模型,一些典型的应用示例如下:
PaddleSpeech 荣获 NAACL2022 Best Demo Award, 请访问 Arxiv 论文。
更多合成音频,可以参考 PaddleSpeech 语音合成音频示例。
| 输入文本 | 输出文本 |
|---|---|
| 今天的天气真不错啊你下午有空吗我想约你一起去吃饭 | 今天的天气真不错啊!你下午有空吗?我想约你一起去吃饭。 |
本项目采用了易用、高效、灵活以及可扩展的实现,旨在为工业应用、学术研究提供更好的支持,实现的功能包含训练、推断以及测试模块,以及部署过程,主要包括
微信扫描二维码关注公众号,点击“马上报名”填写问卷加入官方交流群,获得更高效的问题答疑,与各行各业开发者充分交流,期待您的加入。
我们强烈建议用户在 Linux 环境下,3.8 以上版本的 python 上安装 PaddleSpeech。
PaddleSpeech 依赖于 paddlepaddle,安装可以参考 paddlepaddle 官网,根据自己机器的情况进行选择。这里给出 cpu 版本示例,其它版本大家可以根据自己机器的情况进行安装。
pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple
你也可以安装指定版本的paddlepaddle,或者安装 develop 版本。
# 安装2.4.1版本. 注意:2.4.1只是一个示例,请按照对paddlepaddle的最小依赖进行选择。
pip install paddlepaddle==2.4.1 -i https://mirror.baidu.com/pypi/simple
# 安装 develop 版本
pip install paddlepaddle==0.0.0 -f https://www.paddlepaddle.org.cn/whl/linux/cpu-mkl/develop.html
PaddleSpeech 快速安装方式有两种,一种是 pip 安装,一种是源码编译(推荐)。
pip install pytest-runner pip install paddlespeech
git clone https://github.com/PaddlePaddle/PaddleSpeech.git
cd PaddleSpeech
pip install pytest-runner
pip install .
# 如果需要在可编辑模式下安装,需要使用 --use-pep517,命令如下
# pip install -e . --use-pep517
更多关于安装问题,如 conda 环境,librosa 依赖的系统库,gcc 环境问题,kaldi 安装等,可以参考这篇安装文档,如安装上遇到问题可以在 #2150 上留言以及查找相关问题
安装完成后,开发者可以通过命令行或者 Python 快速开始,命令行模式下改变 --input 可以尝试用自己的音频或文本测试,支持 16k wav 格式音频。
你也可以在 aistudio 中快速体验 👉🏻一键预测,快速上手 Speech 开发任务。
测试音频示例下载
wget -c https://paddlespeech.cdn.bcebos.com/PaddleAudio/zh.wav wget -c https://paddlespeech.cdn.bcebos.com/PaddleAudio/en.wav
命令行一键体验
paddlespeech asr --lang zh --input zh.wav
Python API 一键预测
>>> from paddlespeech.cli.asr.infer import ASRExecutor
>>> asr = ASRExecutor()
>>> result = asr(audio_file="zh.wav")
>>> print(result)
我认为跑步最重要的就是给我带来了身体健康
输出 24k 采样率wav格式音频
命令行一键体验
paddlespeech tts --input "你好,欢迎使用百度飞桨深度学习框架!" --output output.wav
Python API 一键预测
>>> from paddlespeech.cli.tts.infer import TTSExecutor
>>> tts = TTSExecutor()
>>> tts(text="今天天气十分不错。", output="output.wav")
基于 AudioSet 数据集 527 个类别的声音分类模型
命令行一键体验
paddlespeech cls --input zh.wav
python API 一键预测
>>> from paddlespeech.cli.cls.infer import CLSExecutor
>>> cls = CLSExecutor()
>>> result = cls(audio_file="zh.wav")
>>> print(result)
Speech 0.9027186632156372
命令行一键体验
paddlespeech vector --task spk --input zh.wav
Python API 一键预测
>>> from paddlespeech.cli.vector import VectorExecutor
>>> vec = VectorExecutor()
>>> result = vec(audio_file="zh.wav")
>>> print(result) # 187维向量
[ -0.19083306 9.474295 -14.122263 -2.0916545 0.04848729
4.9295826 1.4780062 0.3733844 10.695862 3.2697146
-4.48199 -0.6617882 -9.170393 -11.1568775 -1.2358263 ...]
命令行一键体验
paddlespeech text --task punc --input 今天的天气真不错啊你下午有空吗我想约你一起去吃饭
Python API 一键预测
>>> from paddlespeech.cli.text.infer import TextExecutor
>>> text_punc = TextExecutor()
>>> result = text_punc(text="今天的天气真不错啊你下午有空吗我想约你一起去吃饭")
今天的天气真不错啊!你下午有空吗?我想约你一起去吃饭。
使用预编译的 kaldi 相关工具,只支持在 Ubuntu 系统中体验
命令行一键体验
paddlespeech st --input en.wav
python API 一键预测
>>> from paddlespeech.cli.st.infer import STExecutor
>>> st = STExecutor()
>>> result = st(audio_file="en.wav")
['我 在 这栋 建筑 的 古老 门上 敲门 。']
安装完成后,开发者可以通过命令行一键启动语音识别,语音合成,音频分类等多种服务。
你可以在 AI Studio 中快速体验:SpeechServer 一键部署
启动服务
paddlespeech_server start --config_file ./demos/speech_server/conf/application.yaml
访问语音识别服务
paddlespeech_client asr --server_ip 127.0.0.1 --port 8090 --input input_16k.wav
访问语音合成服务
paddlespeech_client tts --server_ip 127.0.0.1 --port 8090 --input "您好,欢迎使用百度飞桨语音合成服务。" --output output.wav
访问音频分类服务
paddlespeech_client cls --server_ip 127.0.0.1 --port 8090 --input input.wav
更多服务相关的命令行使用信息,请参考 demos
启动流式 ASR 服务
paddlespeech_server start --config_file ./demos/streaming_asr_server/conf/application.yaml
访问流式 ASR 服务
paddlespeech_client asr_online --server_ip 127.0.0.1 --port 8090 --input input_16k.wav
启动流式 TTS 服务
paddlespeech_server start --config_file ./demos/streaming_tts_server/conf/tts_online_application.yaml
访问流式 TTS 服务
paddlespeech_client tts_online --server_ip 127.0.0.1 --port 8092 --protocol http --input "您好,欢迎使用百度飞桨语音合成服务。" --output output.wav
PaddleSpeech 支持很多主流的模型,并提供了预训练模型,详情请见模型列表。
PaddleSpeech 的 语音转文本 包含语音识别声学模型、语音识别语言模型和语音翻译, 详情如下:
| 语音转文本模块类型 | 数据集 | 模型类型 | 脚本 |
|---|---|---|---|
| 语音识别 | Aishell | DeepSpeech2 RNN + Conv based Models | deepspeech2-aishell |
| Transformer based Attention Models | u2.transformer.conformer-aishell | ||
| Librispeech | Transformer based Attention Models | deepspeech2-librispeech / transformer.conformer.u2-librispeech / transformer.conformer.u2-kaldi-librispeech | |
| TIMIT | Unified Streaming & Non-streaming Two-pass | u2-timit | |
| 对齐 | THCHS30 | MFA | mfa-thchs30 |
| 语言模型 | Ngram 语言模型 | kenlm | |
| 语音翻译(英译中) | TED En-Zh | Transformer + ASR MTL | transformer-ted |
| FAT + Transformer + ASR MTL | fat-st-ted | ||
PaddleSpeech 的 语音合成 主要包含三个模块:文本前端、声学模型和声码器。声学模型和声码器模型如下:
| 语音合成模块类型 | 模型类型 | 数据集 | 脚本 |
|---|---|---|---|
| 文本前端 | tn / g2p | ||
| 声学模型 | Tacotron2 | LJSpeech / CSMSC | tacotron2-ljspeech / tacotron2-csmsc |
| Transformer TTS | LJSpeech | transformer-ljspeech | |
| SpeedySpeech | CSMSC | speedyspeech-csmsc | |
| FastSpeech2 | LJSpeech / VCTK / CSMSC / AISHELL-3 / ZH_EN / finetune | fastspeech2-ljspeech / fastspeech2-vctk / fastspeech2-csmsc / fastspeech2-aishell3 / fastspeech2-zh_en / fastspeech2-finetune | |
| ERNIE-SAT | VCTK / AISHELL-3 / ZH_EN | ERNIE-SAT-vctk / ERNIE-SAT-aishell3 / ERNIE-SAT-zh_en | |
| DiffSinger | Opencpop | DiffSinger-opencpop | |
| 声码器 | WaveFlow | LJSpeech | waveflow-ljspeech |
| Parallel WaveGAN | LJSpeech / VCTK / CSMSC / AISHELL-3 / Opencpop | PWGAN-ljspeech / PWGAN-vctk / PWGAN-csmsc / PWGAN-aishell3 / PWGAN-opencpop | |
| Multi Band MelGAN | CSMSC | Multi Band MelGAN-csmsc | |
| Style MelGAN | CSMSC | Style MelGAN-csmsc | |
| HiFiGAN | LJSpeech / VCTK / CSMSC / AISHELL-3 / Opencpop | HiFiGAN-ljspeech / HiFiGAN-vctk / HiFiGAN-csmsc / HiFiGAN-aishell3 / HiFiGAN-opencpop | |
| WaveRNN | CSMSC | WaveRNN-csmsc | |
| 声音克隆 | GE2E | Librispeech, etc. | GE2E |
| SV2TTS (GE2E + Tacotron2) | AISHELL-3 | VC0 | |
| SV2TTS (GE2E + FastSpeech2) | AISHELL-3 | VC1 | |
| SV2TTS (ECAPA-TDNN + FastSpeech2) | AISHELL-3 | VC2 | |
| GE2E + VITS | AISHELL-3 | VITS-VC | |
| 端到端 | VITS | CSMSC / AISHELL-3 | VITS-csmsc / VITS-aishell3 |
声音分类
| 任务 | 数据集 | 模型类型 | 脚本 |
|---|---|---|---|
| 声音分类 | ESC-50 | PANN | pann-esc50 |
语音唤醒
| 任务 | 数据集 | 模型类型 | 脚本 |
|---|---|---|---|
| 语音唤醒 | hey-snips | MDTC | mdtc-hey-snips |
声纹识别
| 任务 | 数据集 | 模型类型 | 脚本 |
|---|---|---|---|
| 声纹识别 | VoxCeleb1/2 | ECAPA-TDNN | ecapa-tdnn-voxceleb12 |
说话人日志
| 任务 | 数据集 | 模型类型 | 脚本 |
|---|---|---|---|
| 说话人日志 | AMI | ECAPA-TDNN + AHC / SC | ecapa-tdnn-ami |
标点恢复
| 任务 | 数据集 | 模型类型 | 脚本 |
|---|---|---|---|
| 标点恢复 | IWLST2012_zh | Ernie Linear | iwslt2012-punc0 |
对于 PaddleSpeech 的所关注的任务,以下指南有助于帮助开发者快速入门,了解语音相关核心思想。
语音合成模块最初被称为 Parakeet,现在与此仓库合并。如果您对该任务的学术研究感兴趣,请参阅 TTS 研究概述。此外,模型介绍 是了解语音合成流程的一个很好的指南。
VTuberTalk: 使用 PaddleSpeech 的语音合成和语音识别从视频中克隆人声。
要引用 PaddleSpeech 进行研究,请使用以下格式进行引用。
@InProceedings{pmlr-v162-bai22d, title = {{A}$^3${T}: Alignment-Aware Acoustic and Text Pretraining for Speech Synthesis and Editing}, author = {Bai, He and Zheng, Renjie and Chen, Junkun and Ma, Mingbo and Li, Xintong and Huang, Liang}, booktitle = {Proceedings of the 39th International Conference on Machine Learning}, pages = {1399--1411}, year = {2022}, volume = {162}, series = {Proceedings of Machine Learning Research}, month = {17--23 Jul}, publisher = {PMLR}, pdf = {https://proceedings.mlr.press/v162/bai22d/bai22d.pdf}, url = {https://proceedings.mlr.press/v162/bai22d.html}, } @inproceedings{zhang2022paddlespeech, title = {PaddleSpeech: An Easy-to-Use All-in-One Speech Toolkit}, author = {Hui Zhang, Tian Yuan, Junkun Chen, Xintong Li, Renjie Zheng, Yuxin Huang, Xiaojie Chen, Enlei Gong, Zeyu Chen, Xiaoguang Hu, dianhai yu, Yanjun Ma, Liang Huang}, booktitle = {Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies: Demonstrations}, year = {2022}, publisher = {Association for Computational Linguistics}, } @inproceedings{zheng2021fused, title={Fused acoustic and text encoding for multimodal bilingual pretraining and speech translation}, author={Zheng, Renjie and Chen, Junkun and Ma, Mingbo and Huang, Liang}, booktitle={International Conference on Machine Learning}, pages={12736--12746}, year={2021}, organization={PMLR} }
热烈欢迎您在 Discussions 中提交问题,并在 Issues 中指出发现的 bug。此外,我们非常希望您参与到 PaddleSpeech 的开发中!
此外,PaddleSpeech 依赖于许多开源存储库。有关更多信息,请参阅 references。
PaddleSpeech 在 Apache-2.0 许可 下提供。