Google Cloud Text to Speech API¶
The Google CLoud TTS API offers high didelity, ultra realistic speech synthesis. A demo is available on its website, https://cloud.google.com/text-to-speech.
This is not a free service. Prices may vary, but at the time of this writing, a free one year trial is available with $300 credit towards all Google Cloud Platform services.
- Supports 30+ voices in 13 languages and variants
- WaveNet Voices
- Exclusive Multilingual access to DeepMind WaveNet voices that provide the most natural sounding speech.
- Text and SSML support
- Customize your speech with SSML tags that allow you to add pauses, numbers, date & time formatting, and other pronunciation instructions.
- Speaking rate tuning
- Customize your speaking rate to be 4x faster or slower than normal rate.
- Pitch tuning
- Customize the pitch of your selected voice, up to 20 semitones more or more or less than the default output.
- Volume gain control
- Increase the volume by up to 16dB or decrease the volume up to -96dB.
- Audio Format Flexibility
- Choose from a number of audio formats including mp3, Linear16, Ogg Opus.
- Audio Profiles (BETA)
- Optimize for the type of speaker from which your speech is intended to play, such as headphones or phone lines.
- Standard (non-WaveNet) voices: up to 4 million characters free; then USD$4.00 per 1 million characters.
- WaveNet voices: Up to 1 million characters free, then USD$16.00 per 1 million characters.
Before you Begin¶
- Select or greate a GCP Project.
- Make sure that Billing is enabled for your project.
- Enable the Cloud Text-to-Speech API.
- From the Service Account drop-down list, select New service account.
- Don’t select a role from the Role drop-down list. No role is required to access this service.
- Click Create. A note appears, warning that this service account has no role.
- Click Create without role. A JSON file that contains your key downloads to your computer (this needs to go to your robot).
Copy your JSON file to your robot. All of the following steps need to be run on your robot.
Install the client library¶
pi@raspberry:~$ python -m pip Install --upgrade google-cloud-texttospeech
Using it with the robot¶
- In controller.conf, set your tts
- Choose a voice from this list.
Make the following changes in the
key_fileto the full path of your key file. (i.e.
voiceto the name of the voice you want to use (i.e.,
Here’s a list of all the options
||SSML, or Speech Synthesis Markup Language gives you more control over how the text is said, bleep things, or inject audio into the text. It’s set to false by default because it can be readilly abused.|
||The JSON key needed to authorize the robot to use the API.|
||What voice you want to use. A
script to show the list of
supported voices is available in
||Changes the pitch of the voice. It
can be between
||Speaking rate changes the speed at
which the voice talks at. It can be