Skip to content

Google Cloud Text To Speech API

bmorrison4 edited this page Jul 20, 2019 · 5 revisions

The Google Cloud TTS API offers high fidelity, ultra realistic speech synthesis. A demo is avaialbe on its website, https://cloud.google.com/text-to-speech.

This is not a free service. Prices may vary, but as of the time of this writing, a free one year trial is available with $300 credit towards all Google Cloud Platform services.

Features

  • Multilingual
    • 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 less than the default output.
  • Volume Gain Control
    • Increase the volume of the output 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.

Pricing

  1. Standard (Non-WaveNet) voices: up to 4 million characters free; then USD$4.00 per 1 million characters.
  2. WaveNet voices: Up to 1 million characters free, then USD$16.00 per 1 million characters.

Setting up

Before you begin

  1. Select or create a GCP Project.
  2. Make sure that billing is enabled for your project.
  3. Enable the Cloud Text-to-Speech API
  4. Set up authentication:
  5. In the CGP console, go to the Create service account key page.
  6. From the Service Account drop-down list, select New service account.
  7. Don't select a role from the Role drop-down list. No role is required to access this service.
  8. Click Create. A note appears, warning that this service account has no role.
  9. Click Create without role. A JSON file that contains your key downloads to your computer. (this needs to go onto 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

python -m pip install --upgrade google-cloud-texttospeech

Using it With the Robot

  1. In controller.conf, set your tts type to google_cloud.
  2. Choose a voice from this list. Make the following changes in the [google_cloud] section of controller.conf.
  3. Set key_file to the full path of your key file. (i.e. /home/pi/googlecloudkey.json)
  4. Set voice to the name of the voice you want to use. It needs to have a matching language code on the front. (i.e. en-US-Wavenet-A)

Here's a list of all the options

Variable Default Value Description
ssml_enabled False 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 readily abused.
key_file The JSON key needed to authorize the robot to use the API.
voice en-US-Wavenet-A What voice you want to use. A script to show the list of supported voices is available in the optional directory.
voice_pitch 0.0 Pitch changes the pitch of the voice. It can be between -20.0 and 20.0.
voice_speaking_rate 1.0 Speaking rate changes the speed at which the voice talks at. It can be between 0.25 and 4.0.
Clone this wiki locally