开发python语音匹配度_Text2Speech深度学习文字语音合成

该项目是Mozilla Common Voice的一部分,提供基于Tacotron的深度学习Text2Speech引擎,旨在实现低成本、高质量的语音合成。包含Tacotron和Tacotron2两种模型,支持与各种Neural Vocoders集成,提供训练代码、转换工具和详尽的训练分析。
摘要由CSDN通过智能技术生成

e78f85ac4d095bcf1c03464000a28336.png

68747470733a2f2f7472617669732d63692e6f72672f6d6f7a696c6c612f5454532e7376673f6272616e63683d646576

This project is a part of Mozilla Common Voice. TTS aims a deep learning based Text2Speech engine, low in cost and high in quality. To begin with, you can hear a sample generated voice from here.

TTS includes two different model implementations which are based on Tacotron and Tacotron2. Tacotron is smaller, efficient and easier to train but Tacotron2 provides better results, especially when it is combined with a Neural vocoder. Therefore, choose depending on your project requirements.

If you are new, you can also find here a brief post about TTS architectures and their comparisons.

68747470733a2f2f736f757263657265722e696f2f66616d652f65726f676f6c2f65726f676f6c2f5454532f696d616765732f3068747470733a2f2f736f757263657265722e696f2f66616d652f65726f676f6c2f65726f676f6c2f5454532f696d616765732f3168747470733a2f2f736f757263657265722e696f2f66616d652f65726f676f6c2f65726f676f6c2f5454532f696d616765732f3268747470733a2f2f736f757263657265722e696f2f66616d652f65726f676f6c2f65726f676f6c2f5454532f696d616765732f3368747470733a2f2f736f757263657265722e696f2f66616d652f65726f676f6c2f65726f676f6c2f5454532f696d616765732f3468747470733a2f2f736f757263657265722e696f2f66616d652f65726f676f6c2f65726f676f6c2f5454532f696d616765732f3568747470733a2f2f736f757263657265722e696f2f66616d652f65726f676f6c2f65726f676f6c2f5454532f696d616765732f3668747470733a2f2f736f757263657265722e696f2f66616d652f65726f676f6c2f65726f676f6c2f5454532f696d616765732f37

TTS Performance

68747470733a2f2f646973636f757273652d706161732d70726f64756374696f6e2d636f6e74656e742e73332e6475616c737461636b2e75732d656173742d312e616d617a6f6e6177732e636f6d2f6f7074696d697a65642f33582f362f342f363432386639383065396563373531633234386535393134363038393566373838316165633063365f325f363930783339342e706e67

Features

High performance Text2Speech models on Torch and Tensorflow 2.0.

High performance Speaker Encoder to compute speaker embeddings efficiently.

Integration with various Neural Vocoders (PWGAN, MelGAN, WaveRNN)

Released trained models.

Efficient training codes for PyTorch. (soon for Tensorflow 2.0)

Codes to convert Torch models to Tensorflow 2.0.

Detailed training anlaysis on console and Tensorboard.

Tools to curate Text2Speech datasets underdataset_analysis.

Demo server for model testing.

Notebooks for extensive model benchmarking.

Modular (but not too much) code base enabling easy testing for new ideas.

Requirements and Installation

Highly recommended to use miniconda for easier installation.

python>=3.6

pytorch>=0.4.1

librosa

tensorboard

tensorboardX

matplotlib

unidecode

Install TTS using setup.py. It will install all of the requirements automatically and make TTS available to all the python environment as an ordinary python module.

python setup.py develop

Or you can use requirements.txt to install the requirements only.

pip install -r requirements.txt

Docker

A barebone Dockerfile exists at the root of the project, which should let you quickly setup the environment. By default, it will start the server and let you query it. Make sure to use nvidia-docker to use your GPUs. Make sure you follow the instructions in the server README before you build your image so that the server can find the model within the image.

docker build -t mozilla-tts .

nvidia-docker run -it --rm -p 5002:5002 mozilla-tts

Checkpoints and Audio Samples

Please visit our wiki.

Example Model Outputs

Below you see Tacotron model state after 16K iterations with batch-size 32 with LJSpeech dataset.

"Recent research at Harvard has shown meditating for as little as 8 weeks can actually increase the grey matter in the parts of the brain responsible for emotional regulation and learning."

Audio examples: soundcloud

example_model_output.png?raw=true

Runtime

The most time-consuming part is the vocoder algorithm (Griffin-Lim) which runs on CPU. By setting its number of iterations lower, you might have faster execution with a small loss of quality. Some of the experimental values are below.

Sentence: "It took me quite a long time to develop a voice, and now that I have it I'm not going to be silent."

Audio length is approximately 6 secs.

Time (secs)

System

# GL iters

Model

2.00

GTX1080Ti

30

Tacotron

3.01

GTX1080Ti

60

Tacotron

3.57

CPU

60

Tacotron

5.27

GTX1080Ti

60

Tacotron2

6.50

CPU

60

Tacotron2

Datasets and Data-Loading

TTS provides a generic dataloder easy to use for new datasets. You need to write an preprocessor function to integrate your own dataset.Check datasets/preprocess.py to see some examples. After the function, you need to set dataset field in config.json. Do not forget other data related fields too.

Some of the open-sourced datasets that we successfully applied TTS, are linked below.

Training and Fine-tuning LJ-Speech

Here you can find a CoLab notebook for a hands-on example, training LJSpeech. Or you can manually follow the guideline below.

To start with, split metadata.csv into train and validation subsets respectively metadata_train.csv and metadata_val.csv. Note that for text-to-speech, validation performance might be misleading since the loss value does not directly measure the voice quality to the human ear and it also does not measure the attention module performance. Therefore, running the model with new sentences and listening to the results is the best way to go.

shuf metadata.csv > metadata_shuf.csv

head -n 12000 metadata_shuf.csv > metadata_train.csv

tail -n 1100 metadata_shuf.csv > metadata_val.csv

To train a new model, you need to define your own config.json file (check the example) and call with the command below. You also set the model architecture in config.json.

train.py --config_path config.json

To fine-tune a model, use --restore_path.

train.py --config_path config.json --restore_path /path/to/your/model.pth.tar

For multi-GPU training use distribute.py. It enables process based multi-GPU training where each process uses a single GPU.

CUDA_VISIBLE_DEVICES="0,1,4" distribute.py --config_path config.json

Each run creates a new output folder and config.json is copied under this folder.

In case of any error or intercepted execution, if there is no checkpoint yet under the output folder, the whole folder is going to be removed.

You can also enjoy Tensorboard, if you point Tensorboard argument--logdir to the experiment folder.

Contribution guidelines

This repository is governed by Mozilla's code of conduct and etiquette guidelines. For more details, please read the Mozilla Community Participation Guidelines.

Please send your Pull Request to dev branch. Before making a Pull Request, check your changes for basic mistakes and style problems by using a linter. We have cardboardlinter setup in this repository, so for example, if you've made some changes and would like to run the linter on just the changed code, you can use the follow command:

pip install pylint cardboardlint

cardboardlinter --refspec master

Collaborative Experimentation Guide

If you like to use TTS to try a new idea and like to share your experiments with the community, we urge you to use the following guideline for a better collaboration. (If you have an idea for better collaboration, let us know)

Create a new branch.

Open an issue pointing your branch.

Explain your experiment.

Share your results as you proceed. (Tensorboard log files, audio results, visuals etc.)

Use LJSpeech dataset (for English) if you like to compare results with the released models. (It is the most open scalable dataset for quick experimentation)

Major TODOs

Implement the model.

Generate human-like speech on LJSpeech dataset.

Generate human-like speech on a different dataset (Nancy) (TWEB).

Train TTS with r=1 successfully.

Enable process based distributed training. Similar to (https://github.com/fastai/imagenet-fast/).

Multi-speaker embedding.

Model optimization (model export, model pruning etc.)

References

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值