Create an API key

Controlla i miei progressi

/ 25

Make an entity analysis request and call Natural Language API

Controlla i miei progressi

/ 25

Create a Speech API request and call Speech API

Controlla i miei progressi

/ 25

Sentiment analysis with the Natural Language API

Controlla i miei progressi

/ 25

Questo lab potrebbe incorporare strumenti di AI a supporto del tuo apprendimento.
Questi contenuti non sono ancora ottimizzati per i dispositivi mobili.
Per un'esperienza ottimale, visualizza il sito su un computer utilizzando un link inviato via email.

ARC114

Google Cloud self-paced labs

Overview

In a challenge lab you’re given a scenario and a set of tasks. Instead of following step-by-step instructions, you will use the skills learned from the labs in the course to figure out how to complete the tasks on your own! An automated scoring system (shown on this page) will provide feedback on whether you have completed your tasks correctly.

When you take a challenge lab, you will not be taught new Google Cloud concepts. You are expected to extend your learned skills, like changing default values and reading and researching error messages to fix your own mistakes.

To score 100% you must successfully complete all tasks within the time period!

Setup and requirements

Before you click the Start Lab button

Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.

This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.

To complete this lab, you need:

  • Access to a standard internet browser (Chrome browser recommended).
Note: Use an Incognito (recommended) or private browser window to run this lab. This prevents conflicts between your personal account and the student account, which may cause extra charges incurred to your personal account.
  • Time to complete the lab—remember, once you start, you cannot pause a lab.
Note: Use only the student account for this lab. If you use a different Google Cloud account, you may incur charges to that account.

Challenge scenario

You are starting your career as a junior cloud architect. In this role, you have been assigned to work on a team project that requires you to use the Cloud Natural Language API and Cloud Speech API services in Google Cloud.

You are expected to have the skills and knowledge to complete the tasks that follow.

Your challenge

For this challenge, you are asked to analyze text and speech using the Cloud Natural Language API and Cloud Speech-to-Text API, respectively. You also need to perform sentiment analysis on a text document using Python in Google Cloud Shell.

You need to:

  • Create an API key
  • Make an entity analysis request and call the Natural Language API
  • Create a speech analysis request and call the Speech API
  • Analyze sentiment with the Natural Language API

Each task is described in detail below. Good luck!

Task 1. Create an API key

  1. In the Google Cloud console, navigate to Navigation menu > APIs & Services > Credentials.

  2. Click Create Credentials at the top of the screen and select API key.

  3. Save the generated API key to an environment variable in Cloud Shell:

    export API_KEY="<YOUR_API_KEY>"

Click Check my progress to verify the objective. Create an API key

Task 2. Make an entity analysis request and call the Natural Language API

  1. In the Google Cloud console, click Activate Cloud Shell (>_).

  2. Set your Google Cloud Project ID and Storage bucket environment variables:

    export GOOGLE_CLOUD_PROJECT=$(gcloud config get-value project) export BUCKET_NAME="${GOOGLE_CLOUD_PROJECT}-speech-nlp"
  3. Next, create a JSON file named nl_request.json which you will pass to the Natural Language API for analysis. You can add the following code to your JSON file to analyze text about the city of Boston or, alternatively, add text of your own choosing to the content object to perform entity analysis on that instead.

{ "document":{ "type":"PLAIN_TEXT", "content":"With approximately 8.2 million people residing in Boston, the capital city of Massachusetts is one of the largest in the United States." }, "encodingType":"UTF8" }
  1. You can now pass your request body, along with the API key environment variable you saved earlier, to the Natural Language API using the curl command:
curl "https://language.googleapis.com/v1/documents:analyzeEntities?key=${API_KEY}" \ -s -X POST -H "Content-Type: application/json" --data-binary @nl_request.json > nl_response.json
  1. Upload the request and response files to your Cloud Storage bucket to verify your progress:
gcloud storage cp nl_request.json gs://${BUCKET_NAME}/nl_request.json gcloud storage cp nl_response.json gs://${BUCKET_NAME}/nl_response.json

Click Check my progress to verify the objective. Make an entity analysis request and call the Natural Language API

Task 3. Create a speech analysis request and call the Speech API

Note: For this task, you will use a pre-recorded file that's available on Cloud Storage: gs://cloud-samples-tests/speech/brooklyn.flac. Listen to the audio file before sending it to the Speech API.
  1. In Cloud Shell, create another JSON file named speech_request.json for this task, and configure it with the URI of the sample audio file in Cloud Storage:
{ "config": { "encoding":"FLAC", "languageCode": "en-US" }, "audio": { "uri":"gs://cloud-samples-tests/speech/brooklyn.flac" } }
  1. Pass your request body, along with the API key environment variable, to the Speech-to-Text API using curl:
curl "https://speech.googleapis.com/v1/speech:recognize?key=${API_KEY}" \ -s -X POST -H "Content-Type: application/json" --data-binary @speech_request.json > speech_response.json
  1. Upload the request and response files to your Cloud Storage bucket to verify your progress:
gcloud storage cp speech_request.json gs://${BUCKET_NAME}/speech_request.json gcloud storage cp speech_response.json gs://${BUCKET_NAME}/speech_response.json

Click Check my progress to verify the objective. Create a speech analysis request and call the Speech API

Task 4. Analyze sentiment with the Natural Language API

For this task, you need to analyze text sentiment using the Google Cloud Natural Language API client library in Python, which determines the overall attitude (positive or negative) of a content sample such as a movie review.

  1. In Cloud Shell, copy the starter Python application script sentiment_analysis.py from your Cloud Storage bucket:

    gcloud storage cp gs://${BUCKET_NAME}/sentiment_analysis.py .
  2. Download the fictitious movie review samples from Google Cloud Storage and extract the archive:

    gcloud storage cp gs://cloud-samples-tests/natural-language/sentiment-samples.tgz . tar -xzvf sentiment-samples.tgz
  3. Open sentiment_analysis.py in your preferred editor (or Cloud Shell Editor) and complete the analyze(movie_review_filename) function using Python:

    • Instantiate a LanguageServiceClient instance.
    • Read the review file into a variable.
    • Instantiate a Document object with the file's text content.
    • Call client.analyze_sentiment with the document and print the results with print_result(response).
  4. Run your sentiment analysis on reviews/bladerunner-pos.txt and save the output:

    python3 sentiment_analysis.py reviews/bladerunner-pos.txt > sentiment_response.txt
  5. Upload the sentiment analysis response to your Cloud Storage bucket:

    gcloud storage cp sentiment_response.txt gs://${BUCKET_NAME}/sentiment_response.txt

Click Check my progress to verify the objective. Analyze sentiment with the Natural Language API

Congratulations!

Analyze Speech & Language with Google APIs skill badge

You have successfully performed entity and sentiment analysis on text as well as speech using the Natural Language and Speech APIs.

Google Cloud training and certification

...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.

Manual Last Updated October 19, 2026

Lab Last Tested October 19, 2026

Copyright 2026 Google LLC. All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.

Prima di iniziare

  1. I lab creano un progetto e risorse Google Cloud per un periodo di tempo prestabilito
  2. I lab hanno un limite di tempo e non possono essere messi in pausa. Se termini il lab, dovrai ricominciare dall'inizio.
  3. In alto a sinistra dello schermo, fai clic su Inizia il lab per iniziare

Utilizza la navigazione privata

  1. Copia il nome utente e la password forniti per il lab
  2. Fai clic su Apri console in modalità privata

Accedi alla console

  1. Accedi utilizzando le tue credenziali del lab. L'utilizzo di altre credenziali potrebbe causare errori oppure l'addebito di costi.
  2. Accetta i termini e salta la pagina di ripristino delle risorse
  3. Non fare clic su Termina lab a meno che tu non abbia terminato il lab o non voglia riavviarlo, perché il tuo lavoro verrà eliminato e il progetto verrà rimosso

Questi contenuti non sono al momento disponibili

Possiamo inviarti una notifica via email quando sarà disponibile

Bene.

Ti contatteremo via email non appena sarà disponibile

Un lab alla volta

Conferma per terminare tutti i lab esistenti e iniziare questo

Utilizza la navigazione privata per eseguire il lab

Il modo migliore per eseguire questo lab è utilizzare una finestra del browser in incognito o privata. Ciò evita eventuali conflitti tra il tuo account personale e l'account studente, che potrebbero causare addebiti aggiuntivi sul tuo account personale.