Setup The Plugin
This section covers how to setup the plugin. It assumes you already have a standard Google Account.
1. Enable the Google Text-To-Speech API.
- If you don't have a Google Cloud Platform account, sign up here.
- Go to the Google Cloud Console and create a new project, or select an existing one.
- Open the
API & Services
library.
- Search for
Text to speech
and selectCloud Text-to-Speech API
.
- Click on
Enable
to enable the Google Text-to-Speech API for the project.
You need to enable billing for the account.
2. Get an API Key
- Go to the Google Cloud API Credentials page and click on
Create Credentials
>API key
.
- Once the API key is created, copy the key and click on
Edit API key
.
- Enter a unique name for your API key.
- Select
Restrict Key
. In the combo box, selectCloud Text-to-Speech API
. - Click
Save
.
3. Use the API Key
The last step is to use the API key to allow the plugin to synthesize text.
There are three ways to setup the API key.
3.1. Use an Environment Variable
The plugin automatically checks for an environment variable named UE_GTTS_APIKEY
. If it is set, its value will be used.
Using this method will only work on devices where the variable is set. If you package the game and run it on another device, it won't be able to read the API key.
3.2. Use the Plugin's Configuration
Open the project's settings, and paste your API key under API Key.
Doing that will package the API key in a config file. Make sure you correctly restricted its use.
3.3. Set the API Key Programmatically
You can set the API key by calling the SetAPIKey
function:
// Header for the function.
#include "GoogleTTS/GoogleTTS.h"
// In some function called at the beginning of your app.
GoogleTTS::SetAPIKey(TEXT("YOUR_API_KEY"));

Doing that will package the API key. Make sure you correctly restricted its use.
4. (Optional) Setup Plugin for C++ Use
An additional setup must be done to use the plugin from C++. You can skip this step if you don't intend to use the plugin using C++.
4.1. Add the GoogleTTS
Module
Open the <ModuleName>.Build.cs
file and add the following line in the constructor:
PrivateDependencyModuleNames.Add("GoogleTTS");
You need to regenerate project files for the includes to work.
4.2. Include the Files
At the top of the file where you want to use the API, add the following line:
#include "GoogleTTS/GoogleTTS.h"