TensorflowTTS C++ Inference
This contains code (and libs) necessary to make portable programs for inference with FastSpeech2 (MFA-aligned phonetic) and MB-MelGAN on desktop, along with a simple example.
The program requires two things:
An exported and packed TTS model (FS2 + MB-MelGAN). Colab notebook linked below will show
A G2P-RNN model. See here for details.
If you want to convert your model to the format that this program expects, you can check out the notebook:
It includes a set of easily understandable and modular classes including a simple English text preprocessor, so you can easily copy and integrate them into your program.
Inference is even easier than in Python. First you need a Phonemizer, then the voice.
Using the demo
The demo program is available for download to use for Windows and Linux (Ubuntu 18.04), both x64. It can take command line arguments (see code for details), but defaults should be fine for mere LJSpeech testing.
To use it, do the following depending on platform:
Using the precompiled demo for Windows
Download the Windows x64 binary and LJSpeech model
Extract to whatever directory you like
Run
Using the precompiled demo for Linux
Tested in Ubuntu 18.04 LTS
Download the Linux x64 binary and LJSpeech model
Extract to whatever directory you like
Navigate with terminal
LD_LIBRARY_PATH=lib ./TensorflowTTSCppInference
For compiling it yourself, see Compiling below
Compiling
Compiling the demo depends on what platform. Currently two have been tested:
Windows 10 x64; MSVC 2019
Linux(Ubuntu) x64: GCC 7.5.0
Note that to test out your shiny new build afterwards you'll have to download the LJSpeech model (or make one yourself), it's bundled in any of the above precompiled demo download links.
Dependencies
Download the dependencies (hint: it's just Tensorflow C API) and drop the deps folder into the same place as the .sln and .pro; it has both Linux and Windows versions.
The rest (such as CppFlow and AudioFile) are included in the source code
Windows
Use the Visual Studio solution file.
Ubuntu
Tested with compiler gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) .
sudo apt install qt5-defaultqmake TensorflowTTSCppInference.promake
Notes when compiling
Tensorflow library malfunctions in debug builds, so only build release.
Externals (and thanks)
Tensorflow C API: https://www.tensorflow.org/install/lang_c
CppFlow (TF C API -> C++ wrapper): https://github.com/serizba/cppflow
AudioFile (for WAV export): https://github.com/adamstark/AudioFile
jarro2783/cxxopts: Lightweight C++ command line option parser)