Help Center/ Speech Interaction Service/ Getting Started/ Calling an API to Use Short Sentence Recognition
Updated on 2024-03-05 GMT+08:00

Calling an API to Use Short Sentence Recognition

This section describes how to use Postman to call the Short Sentence Recognition API. The procedure is similar for other SIS APIs. The procedure is as follows:

Step 1: Configuring the Environment

Step 2: Performing Token Authentication

Step 3: Calling Short Sentence Recognition

Prerequisites

You have registered a Huawei ID and enabled Huawei Cloud services. Your account cannot be in arrears or frozen.

Subscribing to the Service

The Short Sentence Recognition service is now commercially available. You do not need to apply for OBT.

Maximum QPS: 3

Step 1: Configuring the Environment

  1. Download and install Postman 7.24.0.
  2. Download the Postman configuration file of SIS from the following path:

    sis-english.json

    If the browser displays the file content, right-click the file and save it in JSON format.

  3. Import the configuration file.
    1. Open and log in to Postman.
    2. Choose File > Import > Import File > Choose Files to import the configuration file.
      Figure 1 Importing the configuration file

      After the configuration file is imported, it is displayed in the left navigation pane.

Step 2: Performing Token Authentication

When a token is used for API authentication, the token is carried in API requests.
  1. On the Postman page, click get-token in the navigation tree on the left.
  2. Select the Body configuration item and add the Huawei Cloud username, password, and account name. You can obtain the information on the My Credentials page.
    • username: IAM username
    • password: password of the IAM user
    • domainname: account name
    • project name: the name of the region where the service is deployed. In this example, the region is ap-southeast-3. For details about regions, see Endpoints.
      Figure 2 Token-based authentication
  3. Click Send to send a request, and obtain and copy the token.

    In Headers, obtain the value of X-Subject-Token, which is the token. The token is valid for 24 hours.

    Figure 3 Obtaining a token

Step 3: Calling Short Sentence Recognition

  1. On the Postman page, click Short Sentence Recognition in the navigation tree on the left.
  2. Click Headers and replace the value of X-Auth-Token with the obtained token value.
  3. Replace {{ap3-project_id}} with the project ID. You can obtain the project ID on the My Credentials page.
  4. Click body and copy the Base64 code of the audio to the data parameter (the sample audio has been added to the configuration file).
  5. Click send to send the request, and then view the returned result.