Create an API key

Vérifier ma progression

/ 25

Make an entity analysis request and call Natural Language API

Vérifier ma progression

/ 25

Create a Speech API request and call Speech API

Vérifier ma progression

/ 25

Sentiment analysis with the Natural Language API

Vérifier ma progression

/ 25

Cet atelier peut intégrer des outils d'IA pour vous accompagner dans votre apprentissage.
Ce contenu n'est pas encore optimisé pour les appareils mobiles.
Pour une expérience optimale, veuillez accéder à notre site sur un ordinateur de bureau en utilisant un lien envoyé par e-mail.

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.

Avant de commencer

  1. Les ateliers créent un projet Google Cloud et des ressources pour une durée déterminée.
  2. Les ateliers doivent être effectués dans le délai imparti et ne peuvent pas être mis en pause. Si vous quittez l'atelier, vous devrez le recommencer depuis le début.
  3. En haut à gauche de l'écran, cliquez sur Démarrer l'atelier pour commencer.

Utilisez la navigation privée

  1. Copiez le nom d'utilisateur et le mot de passe fournis pour l'atelier
  2. Cliquez sur Ouvrir la console en navigation privée

Connectez-vous à la console

  1. Connectez-vous à l'aide des identifiants qui vous ont été attribués pour l'atelier. L'utilisation d'autres identifiants peut entraîner des erreurs ou des frais.
  2. Acceptez les conditions d'utilisation et ignorez la page concernant les ressources de récupération des données.
  3. Ne cliquez pas sur Terminer l'atelier, à moins que vous n'ayez terminé l'atelier ou que vous ne vouliez le recommencer, car cela effacera votre travail et supprimera le projet.

Ce contenu n'est pas disponible pour le moment

Nous pouvons vous prévenir par e-mail lorsqu'il sera disponible

Parfait !

Nous pouvons vous contacter par e-mail s'il devient disponible

Un atelier à la fois

Confirmez pour mettre fin à tous les ateliers existants et démarrer celui-ci

Utilisez la navigation privée pour effectuer l'atelier

Le meilleur moyen d'exécuter cet atelier consiste à utiliser une fenêtre de navigation privée. Vous éviterez ainsi les conflits entre votre compte personnel et le compte temporaire de participant, qui pourraient entraîner des frais supplémentaires facturés sur votre compte personnel.