RapidTTS项目(文本转语音):更快、更容易部署、开箱即用

507 阅读3分钟

引言

  • 对于一个工具,大部分情况是我们会先在自己数据集上跑一下,看看效果如何,才会来决定是否引入这个工具。
  • 但是目前大部分项目的情况是,只是想简单试验一下也比较困难。虽说有着完善的说明文档,但是复杂的运行环境往往让人筋疲力竭。
  • 这次想要介绍的是我们Team-RapidAI-NG整理的RapidTTS项目

RapidTTS

  • 支持合成语言: 中文和数字
  • 基于PaddleSpeech下的TTS2TTS3整理而来
  • csmsc_tts2: 基于Paddle和ONNXRuntime作为推理引擎,支持中文和数字
  • csmsc_tts3: 基于ONNXRuntime作为推理引擎,支持中文和数字

csmsc_tts2

  • 共分为三步,frontendacousticvocoder

    • 其中acoustic这一步模型推理目前基于PaddlePaddle,
    • vocoder模型推理基于ONNXRuntime
  • 其中PaddleSpeech中提供的预训练模型可以参见link。在RapidTTS2中使用的是:

    主要部分具体模型支持语言
    声学模型speedyspeech_csmsczh
    声码器pwgan_csmsczh
使用步骤
  1. 下载resources, Google Drive | 百度网盘,提取码:kmcf, 解压到RapidTTS/csmsc_tts2目录下

  2. 安装requirements.txt

    pip install -r requirements.txt -i https://pypi.douban.com/simple/
    
  3. 运行tts2.py

    python tts2.py
    
  4. 运行日志如下:

    初始化前处理部分
     frontend done!
     初始化提取特征模型
     am_predictor done!
     初始化合成wav模型
     合成指定句子
     Building prefix dict from the default dictionary ...
     Loading model from cache /tmp/jieba.cache
     Loading model cost 1.431 seconds.
     Prefix dict has been built successfully.
     infer_result/001.wav done!      cost: 7.226019859313965s
     infer_result/002.wav done!      cost: 9.149477005004883s
     infer_result/003.wav done!      cost: 3.4020116329193115s
     infer_result/004.wav done!      cost: 14.5472412109375s
     infer_result/005.wav done!      cost: 14.142913818359375s
     infer_result/006.wav done!      cost: 10.191686630249023s
     infer_result/007.wav done!      cost: 15.726643800735474s
     infer_result/008.wav done!      cost: 15.421608209609985s
     infer_result/009.wav done!      cost: 8.083441972732544s
     infer_result/010.wav done!      cost: 10.538750886917114s
     infer_result/011.wav done!      cost: 7.974739074707031s
     infer_result/012.wav done!      cost: 7.274432897567749s
     infer_result/013.wav done!      cost: 8.204563856124878s
     infer_result/014.wav done!      cost: 8.994312286376953s
     infer_result/015.wav done!      cost: 5.084768056869507s
     infer_result/016.wav done!      cost: 5.3102569580078125s
    

csmsc_tt3

  • 支持合成语言: 中文和数字,不支持英文字母

  • 基于PaddleSpeech下的TTS3整理而来

  • 整个推理引擎只采用ONNXRuntime

  • 其中PaddleSpeech中提供的预训练模型可以参见link。在csmsc_tts3中使用的是:

    主要部分具体模型支持语言
    声学模型fastspeech2_csmsczh
    声码器hifigan_csmsczh
使用步骤
  1. 下载resources, Google Drive | 百度网盘,提取码:a2nw, 解压到csmsc_tts3目录下,最终目录结构如下:

     csmsc_tts3
     ├── csmsc_test.txt
     ├── requirements.txt
     ├── frontend
     ├── main.sh
     ├── tts3.py
     ├── infer_result
     ├── resources
     │   ├── fastspeech2_csmsc_onnx_0.2.0
     │   │   ├── fastspeech2_csmsc.onnx
     │   │   └── phone_id_map.txt
     │   └── hifigan_csmsc.onnx
     └──syn_utils.py
    
  2. 安装requirements.txt

    pip install -r requirements.txt -i https://pypi.douban.com/simple/
    
  3. 运行tts3.py

    python tts3.py
    
  4. 运行日志如下:

     frontend done!
     warm up done!
     Building prefix dict from the default dictionary ...
     Loading model from cache C:\Users\WANGJI~1\AppData\Local\Temp\jieba.cache
     Loading model cost 0.836 seconds.
     Prefix dict has been built successfully.
     009901, mel: (331, 80), wave: 99300, time: 1.3718173s, Hz: 72385.938204132, RTF: 0.33155610876132857.
     009902, mel: (288, 80), wave: 86400, time: 1.1350326000000024s, Hz: 76121.49025085453, RTF: 0.3152854722222228.
     009903, mel: (341, 80), wave: 102300, time: 1.4687841000000006s, Hz: 69649.7502651354, RTF: 0.3445812785923755.
     generation speed: 72441.68237053939Hz, RTF: 0.33130097499999983
    

    生成结果会保存到infer_result目录下

写在最后

  • 因为我们只做了模型转换和推理代码整理的工作,因此可以保证效果与原始PaddleSpeech模型相当
  • 我们做的意义在于解决部署落地的最后一公里,更加便捷。
  • 最近我们也在积极尝试,采用更快的OpenVINO引擎来推理涉及到的各个模型,具体进展参见Paddle模型尝试转换