Skip to content

Text-to-speech

Google Cloud TTS Logo

The cxcli tool has various commands that allow you to interact with Google Cloud's Text to Speech service using the Cloud Text-to-Speech API!

Is this your first time using this feature?

Before you start using this functionality, please, read the authentication page.

Usage

You can find the text-to-speech functionality within the cxcli tts subcommand. You can read the documentation about this command here.

The cxcli tts command has a synthesize subcommand. You can find the usage of this command here.

Parameters

These are the relevant parameters that you can use to interact with Google Cloud TTS:

  1. locale: this parameter accepts all of the locales that are available in the Google Cloud Text-to-speech API. You can find all the locales available here.
  2. output-file: MP3 audio file where we are going to output the synthesized text.

Output

It is important to know that the output audio will have the following format:

  1. A sample rate of 16000 Hertz
  2. The audio encoding will be Linear16. Linear16 is a 16-bit linear pulse-code modulation (PCM) encoding.

Example

Here is a simple example of the cxcli tts synthesize command:

cxcli tts synthesize hi --locale en-US --output-file hi.mp3

The above command will give you an audio file similar to the following:

You can download the audio file here.