推荐 Python 3.10,Linux 需先装 libsndfile1、espeak-ng、ffmpeg 等系统包;非 Linux 系统装完 espeak-ng 后要设置 PHONEMIZER_ESPEAK_LIBRARY 环境变量;多卡训练必须用 torchrun 启动,且与 nohup 不兼容,需改用 tmux。
IMS-Toucan
DigitalPhoneticsApache-2.0更新放缓基于 PyTorch 的多语言语音合成工具包,支持 7000 多种语言的可控快速 TTS,可训练和微调自己的语音模型。
Controllable and fast Text-to-Speech for over 7000 languages!
python -m venv <path_to_where_you_want_your_env_to_be>
source <path_to_where_you_want_your_env_to_be>/bin/activate
pip install --no-cache-dir -r requirements.txt推理不需要 GPU,训练建议至少一块 CUDA 显卡;README 未说明具体显存要求。
斯图加特大学开源的多语言 TTS 工具包,可训练、微调并合成 7000 多种语言的语音
基于 PyTorch 的多语言语音合成工具包,支持 7000 多种语言的可控快速 TTS,可训练和微调自己的语音模型。
核心能力
- 支持 7000 多种语言的语音合成与训练
- 提供预训练 ToucanTTS 模型,首次使用时自动下载
- 可调节语速、音高曲线和能量曲线的方差
- 提供 read_to_file 和 read_aloud 两种推理接口
- 支持单卡或多卡 torchrun 分布式训练
容易踩的坑
- v3.1.2GUI for precise control最新正式版2024-10-07 · 2024-10-07 13:22 UTC
This release includes a new GUI that allows you to control exactly how an utterance sounds.
You can generate a bunch of different realizations until you get one that you like. Then you can modify it further by dragging around the pitch values and the durations of individual phones. You can also exchange the voice for a different one while keeping your changes to the intonation and duration exactly as they are. And of course you can do so in over 7000 languages.
Just update the new requirements and run the
run_advanced_GUI_demo.pyscript. By default it will load the pretrained models from Hugging Face🤗, but you can also specify our own. - v3.1.1Improved Vocoder through end-to-end Training2024-09-22 · 2024-09-22 14:41 UTC
查看更新说明
This is a minor release that does not change much, however the impact on the audio quality is pretty big. Previously, we trained the vocoder on spectrograms extracted from ground-truth audio files. Despite our best efforts of making the synthetic spectrograms as natural as possible, there always remained a gap between the synthetic spectrograms and the genuine spectrograms. We previously thought, that the impact of this was very small and unimportant, but upon experimentation we now noticed, that it actually does make a big difference. The vocoder is the last piece of the pipeline, it is what actually connects the generated spectrograms to your ears. So using a bad vocoder is a bit like putting cheap tires on an expensive sports car.
We have finally fixed this by generating synthetic spectrograms and then training the vocoder on these. We also increased the capacity of the vocoder by giving it more parameters. The inference speed is still just as fast, but the quality is improved greatly. This release is part of the cleanup towards finishing my PhD thesis and is not associated with its own paper or proper evaluation besides internal pilot studies.
Update your code and run the model downloader script for an immediate major quality boost.
Full Changelog: https://github.com/DigitalPhonetics/IMS-Toucan/compare/v3.1...v3.1.1
- v3.1Improved TTS in 7000 Languages2024-07-25 · 2024-07-25 07:16 UTC
查看更新说明
What's Changed
This release provides new checkpoints and improves some aspects of the previous release that were not included due to time constraints. For more information on the universal TTS model for 7000 languages, please refer to the previous release v3.0
- Prosody prediction in terms of pitch, energy and durations are now stochastic and sample from a distribution instead of assuming a one-to-one mapping.
- Added support for more IPA modifiers to cover more languages
- Added more languages into the pretraining
- Overhauled language similarity prediction modules and visualization
Full Changelog: https://github.com/DigitalPhonetics/IMS-Toucan/compare/v3.0...v3.1
- v3.0TTS in 7000 Languages2024-06-10 · 2024-06-10 15:21 UTC
查看更新说明
This release extends the toolkits' functionality and provides new checkpoints.
- We improved the overall TTS quality, with further enhancements already on their way
- Watermarking is added to prevent misuse
- We extend the support for almost all languages in the ISO-639-3 standard (that's over 7000 languages!)
- With a few clever designs, we were able to extrapolate from a pretrained checkpoint using 462 languages to a checkpoint that can speak all languages for which we now support a text frontend!
- Lots of simplifications and quality of life changes.
This is the outcome of a collaboration with colleagues from the University of Groningen and the Fraunhofer IIS in Erlangen. Together with our group from the University of Stuttgart, we have built this model, which is the first of its kind.
We will present this at the Interspeech 2024, the full list of authors is Florian Lux, Sarina Meyer, Lyonel Behringer, Frank Zalkow, Phat Do, Matt Coler, Emanuël Habets and Thang Vu.
Paper: https://arxiv.org/abs/2406.06403 Dataset: https://huggingface.co/datasets/Flux9665/BibleMMS Interactive Demo: https://huggingface.co/spaces/Flux9665/MassivelyMultilingualTTS Static Demo: https://anondemos.github.io/MMDemo/
- 2.pPrompting Controlled Emotional TTS2024-06-10 · 2024-06-10 14:03 UTC
查看更新说明
In this release you can condition your TTS model on emotional prompts during training and transfer the emotion in any prompt to synthesized speech during inference.
Demo samples are available at https://anondemos.github.io/Prompting/ A demo space is available at https://huggingface.co/spaces/Thommy96/promptingtoucan
Using pretrained models: You can use the pretrained models for inference by simply providing an instance of the sentence embedding extractor, a speaker id and a prompt (see run_sent_emb_test_suite.py).
Training your own model: You will need to extract a number of prompts and their sentence embeddings for all emotion categories which you want to include during training (see e.g. extract_yelp_sent_embs.py). Then in your training pipeline you need to load these sentence embeddings and pass them to the train loop. You should also provide the dimensionality of the embeddings in the instantiation of the TTS model and set static_speaker_embedding=True (see TrainingInterfaces\TrainingPipelines\ToucanTTS_Sent_Finetuning.py). Depending on how many speakers there are in the datasets you use for training, you need to adapt the dimensionality of the speaker embedding table in the TTS model. Finally you should check if the datasets you use are included in the functions for extracting emotion and speaker id from the filepath (Utility\utils.py).
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Text-to-Speech for over 7000 Languages
IMS Toucan is a toolkit for training, using, and teaching state-of-the-art Text-to-Speech Synthesis, developed at the Institute for Natural Language Processing (IMS), University of Stuttgart, Germany, official home of the massively multilingual ToucanTTS system. Our system is fast, controllable, and doesn't require a ton of compute.

If you find this repo useful, consider giving it a star. ⭐ Large numbers make me happy, and they are very motivating. If you want to motivate me even more, you can even consider sponsoring this toolkit. We only use GitHub Sponsors for this, there are scammers on other platforms that pretend to be the creator. Don't let them fool you. The code and the models are absolutely free, and thanks to the generous support of Hugging Face🤗, we even have an instance of the model running on GPU free for anyone to use.
Links 🦚
Interactive Demo
Check out our interactive massively-multi-lingual demo on Hugging Face🤗
Dataset
We have also published a massively multilingual TTS dataset on Hugging Face🤗
Languages
A list of supported languages can be found here
Installation 🦉
Basic Requirements
Python 3.10 is the recommended version.
To install this toolkit, clone it onto the machine you want to use it on (should have at least one cuda enabled GPU if you intend to train models on that machine. For inference, you don't need a GPU).
If you're using Linux, you should have the following packages installed, or install them with apt-get if you haven't (on most distributions they come pre-installed):
libsndfile1
espeak-ng
ffmpeg
libasound-dev
libportaudio2
libsqlite3-dev
Navigate to the directory you have cloned. We recommend creating and activating a virtual environment to install the basic requirements into. The commands below summarize everything you need to do under Linux. If you are running Windows, the second line needs to be changed, please have a look at the venv documentation.
python -m venv <path_to_where_you_want_your_env_to_be>
source <path_to_where_you_want_your_env_to_be>/bin/activate
pip install --no-cache-dir -r requirements.txt
Run the second line everytime you start using the tool again to activate the virtual environment again, if you e.g. logged out in the meantime. To make use of a GPU, you don't need to do anything else on a Linux machine. On a Windows machine, have a look at the official PyTorch website for the install-command that enables GPU support.
Storage configuration
If you don't want the pretrained and trained models as well as the cache files resulting from preprocessing your
datasets to be stored in the default subfolders, you can set corresponding directories globally by
editing Utility/storage_config.py to suit your needs (the path can be relative to the repository root directory or
absolute).
Pretrained Models
You don't need to use pretrained models, but it can speed things up tremendously. They will be downloaded on the fly automatically when they are needed, thanks to Hugging Face🤗 and VB in particular.
[optional] eSpeak-NG
eSpeak-NG is an optional requirement, that handles lots of special cases in many languages, so it's good to have.
On most Linux environments it will be installed already, and if it is not, and you have the sufficient rights, you can install it by simply running
apt-get install espeak-ng
For Windows, they provide a convenient .msi installer file
on their GitHub release page. After installation on non-linux
systems, you'll also need to tell the phonemizer library where to find your espeak installation by setting the
PHONEMIZER_ESPEAK_LIBRARY environment variable, which is discussed in
this issue.
For Mac it's unfortunately a lot more complicated. Thanks to Sang Hyun Park, here is a guide for installing it on Mac: For M1 Macs, the most convenient method to install espeak-ng onto your system is via a MacPorts port of espeak-ng. MacPorts itself can be installed from the MacPorts website, which also requires Apple's XCode. Once XCode and MacPorts have been installed, you can install the port of espeak-ng via
sudo port install espeak-ng
As stated in the Windows install instructions, the espeak-ng installation will need to be set as a variable for the
phonemizer library. The environment variable is PHONEMIZER_ESPEAK_LIBRARY as given in the
GitHub thread linked above.
However, the espeak-ng installation file you need to set this variable to is a .dylib file rather than a .dll file on
Mac. In order to locate the espeak-ng library file, you can run port contents espeak-ng. The specific file you are
looking for is named libespeak-ng.dylib.
Inference 🦢
You can load your trained models, or the pretrained provided one, using the InferenceInterfaces/ToucanTTSInterface.py.
Simply create an object from it with the proper directory handle
identifying the model you want to use. The rest should work out in the background. You might want to set a language
embedding or a speaker embedding using the set_language and set_speaker_embedding functions. Most things should be
self-explanatory.
An InferenceInterface contains two methods to create audio from text. They are read_to_file and read_aloud.
-
read_to_file takes as input a list of strings and a filename. It will synthesize the sentences in the list and concatenate them with a short pause inbetween and write them to the filepath you supply as the other argument.
-
read_aloud takes just a string, which it will then convert to speech and immediately play using the system's speakers. If you set the optional argument view to True, a visualization will pop up, that you need to close for the program to continue.
Their use is demonstrated in run_interactive_demo.py and run_text_to_file_reader.py.
There are simple scaling parameters to control the duration, the variance of the pitch curve and the variance of the energy curve. You can either change them in the code when using the interactive demo or the reader, or you can simply pass them to the interface when you use it in your own code.
To change the language of the model and see which languages are available in our pretrained model, have a look at the list linked here
Creating a new Recipe (Training Pipeline) 🐣
In the directory called
Utility there is a file called
path_to_transcript_dicts.py. In this file you should write a function that returns a dictionary that has all the
absolute paths to each of the audio files in your dataset as strings as the keys and the textual transcriptions of the
corresponding audios as the values.
Then go to the directory
TrainingInterfaces/Recipes. In there, make a copy of the finetuning_example_simple.py file if you just want to
finetune on a single dataset or finetuning_example_multilingual.py if you want to finetune on multiple datasets,
potentially even multiple languages. We will use this copy
as reference and only make the necessary changes to use the new dataset. Find the call(s) to the prepare_tts_corpus
function. Replace the path_to_transcript_dict used there with the one(s) you just created. Then change the name of the
corresponding cache directory to something that makes sense for the dataset.
Also look out for the variable save_dir, which is where the checkpoints will be saved to. This is a default value, you
can overwrite it when calling
the pipeline later using a command line argument, in case you want to fine-tune from a checkpoint and thus save into a
different directory. Finally, change the
lang argument in the creation of the dataset and in the call to the train loop function to the ISO 639-3 language ID
that
matches your data.
The arguments that are given to the train loop in the finetuning examples are meant for the case of finetuning from a pretrained model. If you want to train from scratch, have a look at a different pipeline that has ToucanTTS in its name and look at the arguments used there.
Once this is complete, we are almost done, now we just need to make it available to the
run_training_pipeline.py file in the top level. In said file, import the
run function from the pipeline you just created and give it a meaningful name. Now in the
pipeline_dict, add your imported function as value and use as key a shorthand that makes sense.
Training a Model 🦜
Once you have a recipe built, training is super easy:
python run_training_pipeline.py <shorthand of the pipeline>
You can supply any of the following arguments, but don't have to (although for training you should definitely specify at least a GPU ID).
--gpu_id <ID of the GPU you wish to use, as displayed with nvidia-smi, default is cpu. If multiple GPUs are provided (comma separated), then distributed training will be used, but the script has to be started with torchrun.>
--resume_checkpoint <path to a checkpoint to load>
--resume (if this is present, the furthest checkpoint available will be loaded automatically)
--finetune (if this is present, the provided checkpoint will be fine-tuned on the data from this pipeline)
--model_save_dir <path to a directory where the checkpoints should be saved>
--wandb (if this is present, the logs will be synchronized to your weights&biases account, if you are logged in on the command line)
--wandb_resume_id <the id of the run you want to resume, if you are using weights&biases (you can find the id in the URL of the run)>
For multi-GPU training, you have to supply multiple GPU ids (comma separated) and start the script with torchrun. You also have to specify the number of GPUs. This has to match the number of IDs that you supply. Careful: torchrun is incompatible with nohup! Use tmux instead to keep the script running after you log out of the shell.
torchrun --standalone --nproc_per_node=4 --nnodes=1 run_training_pipeline.py <shorthand of the pipeline> --gpu_id "0,1,2,3"
After every epoch (or alternatively after certain step counts), some logs will be written to the console and to the Weights and Biases website, if you are logged in and set the flag. If you get cuda out of memory errors, you need to decrease the batchsize in the arguments of the call to the training_loop in the pipeline you are running. Try decreasing the batchsize in small steps until you get no more out of cuda memory errors.
In the directory you specified for saving, checkpoint files and spectrogram visualization data will appear. Since the checkpoints are quite big, only the five most recent ones will be kept. The amount of training steps highly depends on the data you are using and whether you're finetuning from a pretrained checkpoint or training from scratch. The fewer data you have, the fewer steps you should take to prevent a possible collapse. If you want to stop earlier, just kill the process, since everything is daemonic all the child-processes should die with it. In case there are some ghost-processes left behind, you can use the following command to find them and kill them manually.
fuser -v /dev/nvidia*
Whenever a checkpoint is saved, a compressed version that can be used for inference is also created, which is named best.py
FAQ 🐓
Here are a few points that were brought up by users:
- How can I figure out if my data has outliers or similar problems? -- There is a scorer that can find and even remove
samples from your dataset cache that have extraordinarily high loss values, have a look at
run_scorer.py. - My error message shows GPU0, even though I specified a different GPU -- The way GPU selection works is that the specified GPU is set as the only visible device, in order to avoid backend stuff running accidentally on different GPUs. So internally the program will name the device GPU0, because it is the only GPU it can see. It is actually running on the GPU you specified.
- read_to_file produces strange outputs -- Check if you're passing a list to the method or a string. Since strings can be iterated over, it might not throw an error, but a list of strings is expected.
UserWarning: Detected call of lr_scheduler.step() before optimizer.step().-- We use a custom scheduler, and torch incorrectly thinks that we call the scheduler and the optimizer in the wrong order. Just ignore this warning, it is completely meaningless.WARNING[XFORMERS]: xFormers can't load C++/CUDA extensions. [...]-- Another meaningless warning. We actually don't use xFormers ourselves, it is just part of the dependencies of one of our dependencies, but it is not used at any place.The torchaudio backend is switched to 'soundfile'. Note that 'sox_io' is not supported on Windows. [...]-- Just happens under Windows and doesn't affect anything.WARNING:phonemizer:words count mismatch on 200.0% of the lines (2/1) [...]-- We have no idea why espeak started giving out this warning, however it doesn't seem to affect anything, so it seems safe to ignore.- Loss turns to
NaN-- The default learning rates work on clean data. If your data is less clean, try using the scorer to find problematic samples, or reduce the learning rate. The most common problem is there being pauses in the speech, but nothing that hints at them in the text. That's why ASR corpora, which leave out punctuation, are usually difficult to use for TTS.
Acknowledgements 🦆
The basic PyTorch modules of FastSpeech 2 and GST are taken from ESPnet, the PyTorch modules of HiFi-GAN are taken from the ParallelWaveGAN repository. Some modules related to the ConditionalFlowMatching based PostNet as outlined in MatchaTTS are taken from the official MatchaTTS codebase and some are taken from the StableTTS codebase. For grapheme-to-phoneme conversion, we rely on the aforementioned eSpeak-NG as well as transphone. We use encodec, a neural audio codec as intermediate representation for caching the train data to save space.
Citation 🐧
Introduction of the Toolkit [associated code and models]
@inproceedings{lux2021toucan,
year = 2021,
title = {{The IMS Toucan system for the Blizzard Challenge 2021}},
author = {Florian Lux and Julia Koch and Antje Schweitzer and Ngoc Thang Vu},
booktitle = {Blizzard Challenge Workshop},
publisher = {ISCA Speech Synthesis SIG}
}
Adding Articulatory Features and Meta-Learning Pretraining [associated code and models]
@inproceedings{lux2022laml,
year = 2022,
title = {{Language-Agnostic Meta-Learning for Low-Resource Text-to-Speech with Articulatory Features}},
author = {Florian Lux and Ngoc Thang Vu},
booktitle = {ACL}
}
Adding Exact Prosody-Cloning Capabilities [associated code and models]
@inproceedings{lux2022cloning,
year = 2022,
title = {{Exact Prosody Cloning in Zero-Shot Multispeaker Text-to-Speech}},
author = {Lux, Florian and Koch, Julia and Vu, Ngoc Thang},
booktitle = {SLT},
publisher = {IEEE}
}
Adding Language Embeddings and Word Boundaries [associated code and models]
@inproceedings{lux2022lrms,
year = 2022,
title = {{Low-Resource Multilingual and Zero-Shot Multispeaker TTS}},
author = {Florian Lux and Julia Koch and Ngoc Thang Vu},
booktitle = {AACL}
}
Adding Controllable Speaker Embedding Generation [associated code and models]
@inproceedings{lux2023controllable,
year = 2023,
title = {{Low-Resource Multilingual and Zero-Shot Multispeaker TTS}},
author = {Florian Lux and Pascal Tilli and Sarina Meyer and Ngoc Thang Vu},
booktitle = {Interspeech}
publisher = {ISCA}
}
Our Contribution to the Blizzard Challenge 2023 [associated code and models]
@inproceedings{lux2023blizzard,
year = 2023,
title = {{The IMS Toucan System for the Blizzard Challenge 2023}},
author = {Florian Lux and Julia Koch and Sarina Meyer and Thomas Bott and Nadja Schauffler and Pavel Denisov and Antje Schweitzer and Ngoc Thang Vu},
booktitle = {Blizzard Challenge Workshop},
publisher = {ISCA Speech Synthesis SIG}
}
Introducing the first TTS System in over 7000 languages [associated code and models]
@inproceedings{lux2024massive,
year = 2024,
title = {{Meta Learning Text-to-Speech Synthesis in over 7000 Languages}},
author = {Florian Lux and Sarina Meyer and Lyonel Behringer and Frank Zalkow and Phat Do and Matt Coler and Emanuël A. P. Habets and Ngoc Thang Vu},
booktitle = {Interspeech}
publisher = {ISCA}
}
Introducing Text based in-context-Prompting to NAR TTS [associated code and models]
@inproceedings{bott2024prompting,
year = 2024,
title = {{Controlling Emotion in Text-to-Speech with Natural Language Prompts}},
author = {Thomas Bott and Florian Lux and Ngoc Thang Vu},
booktitle = {Interspeech}
publisher = {ISCA}
}
Investigating Stochastic Prosody Modeling [associated code and models]
@inproceedings{mayer2025stochastic,
year = 2025,
title = {{Investigating Stochastic Methods for Prosody Modeling in Speech Synthesis}},
author = {Paul Mayer and Florian Lux and Alejandro P\'erez-Gonz\'alez-de-Martos and Angelina Elizarova and Lindsey Vanderlyn and Dirk V\"ath and Ngoc Thang Vu},
booktitle = {Interspeech}
publisher = {ISCA}
}