PaddlePaddleSpeech

https://github.com/PaddlePaddle/PaddleSpeech

(只学怎么用, 训练免了吧)

PaddleSpeech 是基于飞桨 PaddlePaddle 的语音方向的开源模型库,用于语音和音频中的各种关键任务的开发,包含大量基于深度学习前沿和有影响力的模型

安装

PaddleSpeech 有三种安装方法。根据安装的难易程度,这三种方法可以分为 简单中等 和 困难.

方式功能支持系统
简单(1) 使用 PaddleSpeech 的命令行功能.
(2) 在 Aistudio上体验 PaddleSpeech.
Linux, Mac(不支持M1芯片),Windows (安装详情查看#1195)
中等支持 PaddleSpeech 主要功能,比如使用已有 examples 中的模型和使用 PaddleSpeech 来训练自己的模型.Linux, Mac(不支持M1芯片,不支持训练), Windows(不支持训练)
困难支持 PaddleSpeech 的各项功能,包含结合 kaldi 使用 join ctc decoder 方式解码 (asr2),训练语言模型,使用强制对齐等。并且你更能成为一名开发者!Ubuntu

依赖

PaddleSpeech 依赖于 paddlepaddle,安装可以参考 paddlepaddle 官网,根据自己机器的情况进行选择。这里给出 cpu 版本示例,其它版本大家可以根据自己机器的情况进行安装。

依赖

# paddlepaddle
pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple

for 命令行

# paddlespeech
pip install pytest-runner
pip install paddlespeech
 

合成测试

paddlespeech tts --input "你好,欢迎使用百度飞桨深度学习框架!" --output output.wav

for 源码编译

git clone https://github.com/PaddlePaddle/PaddleSpeech.git
cd PaddleSpeech
pip install pytest-runner
pip install .

安装完成后,开发者可以通过命令行或者 Python 快速开始,命令行模式下改变 --input 可以尝试用自己的音频或文本测试,支持 16k wav 格式音频。

踩坑指南

AttributeError: module ‘numpy’ has no attribute ‘complex’.

降低一下 numpy 版本

pip uninstall numpy
pip install numpy==1.23.5 -i https://pypi.tuna.tsinghua.edu.cn/simple

No module named ‘paddle.fluid’

安装GPU版本的 paddlepaddle pip install paddlepaddle-gpu -i https://mirror.baidu.com/pypi/simple

ModuleNotFoundError: No module named ‘paddle.nn.layer.layers’

修改paddlenlp的版本 pip install paddlenlp==2.5.2 -i https://mirror.baidu.com/pypi/simple

fastspeech2_nosil_baker_ckpt_0.4.zip

RuntimeError: Download from https://paddlespeech.bj.bcebos.com/Parakeet/released_models/fastspeech2/fastspeech2_nosil_baker_ckpt_0.4.zip failed. Retry limit reached

就报个下载错误, 完全没有用的信息, 得用源码调试!!

 
def _download(url, path, md5sum=None, method='get'):
    """
    Download from url, save to path.
    url (str): download url
    path (str): download to given path
    md5sum (str): md5 sum of download package
    method (str): which download method to use. Support `wget` and `get`. Default is `get`.
    """
    assert method in _download_methods, 'make sure `{}` implemented'.format(
        method)
 
    if not osp.exists(path):
        os.makedirs(path)
 
    fname = osp.split(url)[-1]
    fullname = osp.join(path, fname)
    retry_cnt = 0
 
	//具体就是这里下载错误
    logger.debug("Downloading {} from {}".format(fname, url))
    // 位置是: 'C:\\Users\\yang\\.paddlespeech\\models\\fastspeech2_csmsc-zh\\1.0\\fastspeech2_nosil_baker_ckpt_0.4.zip'
    while not (osp.exists(fullname) and _md5check(fullname, md5sum)):
        if retry_cnt < DOWNLOAD_RETRY_LIMIT:
            retry_cnt += 1
        else:
            raise RuntimeError("Download from {} failed. "
                               "Retry limit reached".format(url))
 
        if not _download_methods[method](url, fullname):
            time.sleep(1)
            continue
 
    return fullname

https://paddlespeech.bj.bcebos.com/Parakeet/released_models/fastspeech2/fastspeech2_nosil_baker_ckpt_0.4.zip 放到: C:\Users\yang\.paddlespeech\models\fastspeech2_csmsc-zh\1.0\

https://paddlespeech.bj.bcebos.com/Parakeet/released_models/g2p/G2PWModel_1.1.zip, C:\Users\yang\.paddlespeech\models\G2PWModel_1.1.zip

语音识别

for command line

paddlespeech asr --lang zh --input zh.wav

for api

>>> from paddlespeech.cli.asr.infer import ASRExecutor
>>> asr = ASRExecutor()
>>> result = asr(audio_file="zh.wav")
>>> print(result)
我认为跑步最重要的就是给我带来了身体健康

语音合成

for command line

paddlespeech tts --input "你好,欢迎使用百度飞桨深度学习框架!" --output output.wav

for api

>>> from paddlespeech.cli.tts.infer import TTSExecutor
>>> tts = TTSExecutor()
>>> tts(text="今天天气十分不错。", output="output.wav")

接口服务

启动服务

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