Google Cloud
Text-to-speech
Google Cloud offers a number of robust text-to-speech voice models. SignalWire supports all Google Cloud voices in both General Availability and Preview launch stages, except for the Studio model.
Models
Google Cloud offers multiple TTS model types with varying quality and pricing:
The model type is encoded in the voice name (e.g., en-US-Neural2-A, es-ES-Wavenet-B).
- Standard is a basic, reliable, and budget-friendly text-to-speech model. The Standard model is less natural-sounding than WaveNet and Neural2, but more cost-effective.
- WaveNet is powered by deep learning technology and offers more natural and lifelike speech output.
- Neural2 is based on the same technology used to create Custom Voices and prioritizes natural and human-like pronunciation and intonation.
- Polyglot
voices have variants in multiple languages. For example, at time of writing,
the
polyglot-1voice has variants for English (Australia), English (US), French, German, Spanish (Spain), and Spanish (US).
Voices
Press play to audition any Google Cloud voice, then copy config to grab the value for SWML or your SDK.
Billing
Google Cloud TTS usage on SignalWire is billed according to the following SKU codes:
The billing SKU is automatically determined by the voice model type. Neural2 and Polyglot voices use the gcloud_cog SKU, while Standard and WaveNet voices use the gcloud SKU.
Consult the Voice API Pricing page for current rates.
Usage
Copy the voice name in whole from the Voice name column of Google’s table of
supported voices — that is the voice half of
the string, not a complete voice string on its own.
Google Cloud voice IDs encode language and model information,
so no modification is needed to make these selections.
Prepend gcloud. and the string is ready for use.
For example: gcloud.en-GB-Wavenet-A
Google Cloud voice IDs conform to the following format:
Where <voice> is the complete voice name from Google’s supported voices table.
Voice name pattern:
Google Cloud voice names follow: <language>-<model>-<variant>
language: Language code (e.g.,en-US,es-ES,ja-JP)model: Model type (e.g.,Standard,Wavenet,Neural2,Polyglot)variant: Voice variant letter (e.g.,A,B,C)
Examples:
Case insensitivity:
Voice IDs are case-insensitive. These are equivalent:
Note: Google Cloud voice IDs already encode language and model information.
Languages
Sample all available voices with
Google’s supported voices and languages reference.
Copy the voice identifier string in whole from the Voice name column, then prepend gcloud. to
get the string SignalWire accepts — the voice name on its own resolves against a default engine that
can change.
Unlike the other supported engines, Google Cloud voice identifier strings include both voice and language keys,
following the pattern <language>-<model>-<variant>.
Prefixed with the engine, complete voice strings look like this:
- English (UK) WaveNet female voice:
gcloud.en-GB-Wavenet-A - Spanish (Spain) Neural2 male voice:
gcloud.es-ES-Neural2-B - Mandarin Chinese Standard female voice:
gcloud.cmn-CN-Standard-D
Use Google Cloud voices on a call
A Google Cloud voice string such as gcloud.en-US-Neural2-A works in each of these places: an AI
agent’s languages, the say_voice of SWML’s play, and a tts media item sent with Relay or
the REST Calling API. The examples below all use gcloud.en-US-Neural2-A. To control speech while it plays, see
Speak text on a call.
Replace these values in the samples:
Give an AI agent a Google Cloud voice via SWML
The languages list of the SWML
ai method sets the voice an AI agent speaks in. The
Server SDKs build the document and serve it at /swml on port 3000, only to
requests that carry the username signalwire and your password.
To send calls from your phone number to the server, follow Answer a call via SWML. Call the number, and the agent greets you in the Google Cloud voice. If you hear a different voice, the voice string isn’t in SignalWire’s catalog, so the call falls back to a default voice. See Custom and cloned voices.
Speak text in a Google Cloud voice via SWML
The SWML builder’s say() writes a play with a say: URL
and the voice in say_voice. This server speaks one sentence in the Google Cloud voice, then hangs up.
Serve it and point your number at it the same way as the AI agent above.
Speak text in a Google Cloud voice via WebSocket (Relay)
A Relay client in the Server SDKs passes the voice string in a tts media
item. This handler answers calls on the default topic, speaks in the Google Cloud voice, and hangs
up when the speech ends.
To route calls from your phone number to the handler, assign the number to a Relay Application
on the default topic, as described in
Answer a call via WebSocket (Relay).
Call the number to hear the sentence. If you hear a different voice, SignalWire couldn’t use the
voice string and played a fallback voice. If the play is rejected as a bad request, check the voice
string for characters a tts item doesn’t accept, such as spaces, parentheses, or /.
Speak text in a Google Cloud voice on a call in progress via REST
To speak on a call that’s already up, such as from a backend job, send
calling.play with the call’s ID and the same tts media
item. control_id names the playback so later commands can stop or pause it.
The command returns once SignalWire accepts it, and the call hears the sentence in the Google Cloud
voice.
If the call hears a different voice, SignalWire couldn’t use the voice string and played a fallback
voice. If the call hears nothing, check the voice string for characters a tts item doesn’t
accept, such as spaces, parentheses, or /. The request can return success
even when the voice string is rejected.
Create a SWML Script that uses a Google Cloud voice
A SWML Script hosted in SignalWire runs the Google Cloud-voiced AI agent above without a server of your own.
- In the Dashboard, open My Resources, select + Add, then Script, then SWML Script.
- Name the script and leave Used For set to Calling.
- Under Handle Calls Using, choose Hosted Script and paste this document into Primary Script.
- Select Create.
Assign the script to your phone number as in Answer a call via SWML, then call the number. The agent answers in the Google Cloud voice.