Hands-on Configuration of GCP Text-to-Speech


In recent years, machine learning and deep learning have become much more popular than before. However, we have to pay much afford if we want to study machine learning and deep learning by ourselves. Thus, cloud provider like AWS, GCP and Azure provide an API service to let us use their well developed service easily. In this article, we will use GCP Text-to-Speech as our demonstration.

Enable Cloud Text-to-Speech API

By default, Text-to-Speech API is disabled, we have to search for the Text-to-Speech API and then enable it like above figure.

Setup Environment and Account

In console, we choose Cloud Shell and then click the editor mode such that we could easily review our code.

The we have to setup our environment e.g. define project, zone and region:

gcloud config set project <you-project-id>
gcloud config set compute/zone us-central1-a
gcloud config set compute/region us-central1

To download our prepared file first:

git clone https://github.com/manbobo2002/Text-to-Speech-demo.git
cd ./Text-to-Speech-demo

Go to the root of our prepared folder, then run:

sh setup.sh

It will help to setup all the required environment and account.


Run below command to test the API:

sh test.sh

Click “Preview on port 8080” on the right top corner.

Then we are able to see the audio output of the test-text file.

If we want to change the text content, please feel free to edit the input in test-text.json.


I also prepare a script to clean up the service account we created before. Just type:

sh clean.sh

Leave a Reply