Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Commit

Permalink
Update 04b-translate-text-and-speech.md
Browse files Browse the repository at this point in the history
sherzyang authored Sep 6, 2024
1 parent 9c615aa commit e99d27f
Showing 1 changed file with 1 addition and 124 deletions.
125 changes: 1 addition & 124 deletions instructions/04b-translate-text-and-speech.md
Original file line number Diff line number Diff line change
@@ -3,127 +3,4 @@ lab:
title: 'Explore translation'
---

# Explore translation

> **Note**
> To complete this lab, you will need an [Azure subscription](https://azure.microsoft.com/free?azure-portal=true) in which you have administrative access.
One of the driving forces that has enabled human civilization to develop is the ability to communicate with one another. In most human endeavors, communication is key.

Artificial Intelligence (AI) can help simplify communication by translating text or speech between languages, helping to remove barriers to communication across countries and cultures.

To test the capabilities of the Translator service, we'll use a simple command-line application that runs in the Cloud Shell. The same principles and functionality apply in real-world solutions, such as web sites or phone apps.

## Create an *Azure AI services* resource

You can use the Translator service by creating either a **Translator** resource or an **Azure AI services** resource.

If you haven't already done so, create an **Azure AI services** resource in your Azure subscription.

1. In another browser tab, open the Azure portal at [https://portal.azure.com](https://portal.azure.com?azure-portal=true), signing in with your Microsoft account.

1. Click the **+Create a resource** button and search for *Azure AI services*. Select **create** an **Azure AI services** plan. You will be taken to a page to create an Azure AI services resource. Configure it with the following settings:
- **Subscription**: *Your Azure subscription*.
- **Resource group**: *Select or create a resource group with a unique name*.
- **Region**: *Choose any available region*.
- **Name**: *Enter a unique name*.
- **Pricing tier**: Standard S0
- **By checking this box I acknowledge that I have read and understood all the terms below**: Selected.

1. Review and create the resource, and wait for deployment to complete. Then go to the deployed resource.

1. View the **Keys and Endpoint** page for your Azure AI services resource. You will need the keys and location to connect from client applications.

### Get the Key and Location for your Azure AI services resource

1. Wait for deployment to complete. Then go to your Azure AI services resource, and on the **Overview** page, select the link to manage the keys for the service. You will need the keys and location to connect to your Azure AI services resource from client applications.

1. View the **Keys and Endpoint** page for your resource. You will need the **location/region** and **key** to connect from client applications.

> **Note**
> To use the Translator service you do not need to use the Azure AI services endpoint. A global endpoint just for the Translator service is provided.
## Run Cloud Shell

To test the capabilities of the Translation service, we'll use a simple command-line application that runs in the Cloud Shell on Azure.

1. In the Azure portal, select the **[>_]** (*Cloud Shell*) button at the top of the page to the right of the search box. This opens a Cloud Shell pane at the bottom of the portal.

![Start Cloud Shell by clicking on the icon to the right of the top search box](media/translate-text-and-speech/powershell-portal-guide-1.png)

1. The first time you open the Cloud Shell, you may be prompted to choose the type of shell you want to use (*Bash* or *PowerShell*). Select **PowerShell**. If you do not see this option, skip the step.

1. If you are prompted to create storage for your Cloud Shell, ensure your subscription is specified and select **Create storage**. Then wait a minute or so for the storage to be created.

![Create storage by clicking confirm.](media/translate-text-and-speech/powershell-portal-guide-2.png)

1. Make sure the type of shell indicated on the top left of the Cloud Shell pane is switched to *PowerShell*. If it is *Bash*, switch to *PowerShell* by using the drop-down menu.

![How to find the left hand drop down menu to switch to PowerShell](media/translate-text-and-speech/powershell-portal-guide-3.png)

1. Wait for PowerShell to start. You should see the following screen in the Azure portal:

![Wait for PowerShell to start.](media/translate-text-and-speech/powershell-prompt.png)

## Configure and run a client application

Now that you have a custom model, you can run a simple client application that uses the Translation service.

1. In the command shell, enter the following command to download the sample application and save it to a folder called ai-900.

```PowerShell
git clone https://github.com/MicrosoftLearning/AI-900-AIFundamentals ai-900
```
>**Tip**
>If you already used this command in another lab to clone the *ai-900* repository, you can skip this step.
1. The files are downloaded to a folder named **ai-900**. Now we want to see all of the files in your Cloud Shell storage and work with them. Type the following command into the shell:
```PowerShell
code .
```
Notice how this opens up an editor like the one in the image below:
![The code editor.](media/translate-text-and-speech/powershell-portal-guide-4.png)
1. In the **Files** pane on the left, expand **ai-900** and select **translator.ps1**. This file contains some code that uses the Translator service:
![The editor containing code to use the Translator service](media/translate-text-and-speech/translate-code.png)
1. Don't worry too much about the details of the code, the important thing is that it needs the region/location and either of the keys for your Azure AI services resource. Copy these from the **Keys and Endpoints** page for your resource from the Azure portal and paste them into the code editor, replacing the **YOUR_KEY** and **YOUR_LOCATION** placeholder values respectively.
After pasting the key and location values, the first lines of code should look similar to this:
```PowerShell
$key="1a2b3c4d5e6f7g8h9i0j...."
$location="somelocation"
```
1. At the top right of the editor pane, use the **...** button to open the menu and select **Save** to save your changes. Then open the menu again and select **Close Editor**.
The sample client application will use the Translator service to do several tasks:
- Translate text from English into French, Italian, and Chinese.
- Translate audio from English into text in French
Use the video player below to hear the input audio the application will process:
<div class="embeddedvideo"><iframe src="https://www.microsoft.com/videoplayer/embed/RWORN0" frameborder="0" allowfullscreen="true" data-linktype="external"></iframe></div>
> **Note**
> A real application could accept the input from a microphone and send the response to a speaker, but in this simple example, we'll use pre-recorded input in an audio file.
1. In the Cloud Shell pane, enter the following command to run the code:
```PowerShell
cd ai-900
./translator.ps1
```
1. Review the output. Did you see the translation from text in English to French, Italian, and Chinese? Did you see the English audio "hello" translated into text in French?
## Learn more
This simple app shows only some of the capabilities of the Translator service. To learn more about what you can do with this service, see the [Translator page](https://docs.microsoft.com/azure/cognitive-services/translator/translator-overview).
> **Note**: This lab has been deprecated and will be replaced with a new one soon.

0 comments on commit e99d27f

Please sign in to comment.