Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • AI
    • Cloud
Labs

Setting Up Google Cloud Text-to-Speech

Although there are many tools to communicate, there are two basic types of communication: written and spoken. Machine learning has made it possible to convert one to the other, resulting in speech that is very close to that of a human voice. In this hands-on lab, you'll step through the process for utilizing the Google Cloud Text-to-Speech API, transforming text in a JSON format to an audio-ready MP3 file.

Lab platform
Lab Info
Level
Beginner
Last updated
Sep 16, 2025
Duration
45m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    Enable the Cloud Text-to-Speech API
    1. From the Google Cloud console's main navigation, choose APIs & Services > Library.
    2. Search for "text", and select Cloud Text-to-Speech API.
    3. If necessary, click Enable.
  2. Challenge

    Set Up Service Account
    1. Click Launch Editor.

    2. In the Shell Editor, expand the ai-conversations folder.

    3. Choose File > New File and name the file key.json.

    4. From this Hands-On Lab Credentials, copy the Service Account Credentials.

    5. Paste the clipboard contents into the new file, and choose File > Save.

    6. Switch to the Terminal enter the following command:

      export GOOGLE_APPLICATION_CREDENTIALS=key.json
      
  3. Challenge

    Retrieve Working Files
    1. Activate the Cloud Shell.

    2. Retrieve the working files:

      git clone https://github.com/linuxacademy/content-gc-ai-services-deepdive
      
    3. In the Cloud Shell, change directories:

      cd content-gc-ai-services-deepdive/ai-conversations/
      
  4. Challenge

    Send Request to Cloud Text-to-Speech API
    1. Call the Cloud Text-to-Speech API:

      curl -X POST 
      -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) 
      -H "Content-Type: application/json; charset=utf-8" 
      -d @text-to-speech-request.json 
      https://texttospeech.googleapis.com/v1/text:synthesize 
      > synthesize-text.txt 
      
    2. In the Shell Editor, open synthesize-text.txt.

    3. Remove the following from the beginning of the file:

      {
        "audioContent": "
      
    4. From the end of the file, remove the following:

      "
      }
      
    5. Save the file.

  5. Challenge

    Convert Response to MP3
    1. In the Cloud Shell, enter the following command:

      base64 synthesize-text.txt -d > synthesized-audio.mp3
      
    2. Download the MP3 file to your system:

      cloudshell download synthesized-audio.mp3
      
    3. Click Download.

    4. Open the downloaded MP3 file to hear the results.

About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight