Overview
This document describes how to use API 3.0 Explorer to debug ASR APIs online and quickly integrate the Tencent Cloud SDK corresponding to the APIs into your local project.
Directions
Activate ASR Service
Before calling ASR APIs, you should access the ASR console to complete identity verification. Then, read the User agreement, select I have read and agree to the "User Agreement", and click Activate now to activate APIs for real-time speech recognition. If you need to activate the business license verification or VAT invoice verification feature, you can go to the service overview page to apply for activation, and the service can be used after approval. After the service is successfully activated, API calls will be billed in the pay-as-you-go mode and settled daily. For billing details, see Billing Overview. Debugging ASR APIs
After the ASR service is successfully activated, go to the ASR API 3.0 Explorer online API debugging page, select the API to be called, and enter the input parameters. You can view the specific descriptions of input parameters in the Parameter Description tab on the API 3.0 Explorer UI. Note:
The platform will provide a temporary Access Key to the logged-in user for debugging.
After entering the Input Parameters, select the Code Generation tab, and you can see the automatically generated code in different programming languages (Java, Python, Node.js, PHP, Go, .NET, and C++), and some fields in the generated code are related to the entered content. If you need to adjust the input parameters, you can regenerate the code after modifying the parameter values on the left.
Select the Online Call tab and click Send Request to make a real request for your debugging and reference.
Integrating ASR SDK
Confirm that your local dependent environment meets the following requirements:
|
| |
| |
| |
| Go 1.9 or later (or Go 1.14 if go.mod is used) |
| .NET Framework 4.5+ or .NET Core 2.1 |
| |
| Compiler for C++ 11 or later, i.e., GCC 4.8 or later (currently, only the Linux installation environment is supported, while Windows is not) |
| |
Install the Tencent Cloud ASR SDK corresponding to the local dependent environment. The following takes Node.js as an example to describe the SDK installation and use methods. For SDKs in other languages, go to the SDK Center. Installing through npm (recommended)
Installation through npm is the recommended way to use the SDK for Node.js. npm is a dependency manager for Node.js that supports the dependencies your project requires and installs them into your project. For more information, visit npm's official website. 1. Run the following installation command:
npm install tencentcloud-sdk-nodejs --save
2. Import the applicable module code in your code. For more information, see the sample code.
3. The above reference method will download the SDKs for all Tencent Cloud products to your local machine. You can replace tencentcloud-sdk-nodejs
with tencentcloud-sdk-nodejs-cvm/cbs/vpc
, etc., to reference the SDK for a specific product. In the code, you can change require("tencentcloud-sdk-nodejs")
to require("tencentcloud-sdk-nodejs-cvm/cbs/vpc")
, without other changes. Refer to examples, which can greatly save storage space.
Installation through source package
2. Decompress the source package to an appropriate location in your project.
3. Import the applicable module code in your code. For more information, see the sample code.
Demo
After the SDK installation is completed, you can import the code automatically generated by API 3.0 Explorer into your project. Taking Node.js as an example, a simple demo is as follows:
const tencentcloud = require("tencentcloud-sdk-nodejs")
// Import the client models of the corresponding product module.
const CvmClient = tencentcloud.cvm.v20170312.Client
const clientConfig = {
// Tencent Cloud authentication information
credential: {
secretId: "secretId",
secretKey: "secretKey",
},
// Product region
region: "ap-shanghai",
// Optional configuration instance
profile: {
signMethod: "HmacSHA256", // Signature algorithm
httpProfile: {
reqMethod: "POST", // Request method
reqTimeout: 30, // Specify the request timeout value in seconds. The default value is 60s
},
},
}
// Instantiate the client object of the requested product (with CVM as an example)
const client = new CvmClient(clientConfig)
// Call the API you want to access through the client object; you need to pass in the request object and the response callback function
client.DescribeZones().then(
(data) => {
console.log(data)
},
(err) => {
console.error("error", err)
}
)
In projects that support typescript, use the following method to call:
import * as tencentcloud from "tencentcloud-sdk-nodejs"
// Import the client models of the corresponding product module.
const CvmClient = tencentcloud.cvm.v20170312.Client
const clientConfig = {
// Tencent Cloud authentication information
credential: {
secretId: "secretId",
secretKey: "secretKey",
},
// Product region
region: "ap-shanghai",
// Optional configuration instance
profile: {
signMethod: "HmacSHA256", // Signature algorithm
httpProfile: {
reqMethod: "POST", // Request method
reqTimeout: 30, // Specify the request timeout value in seconds. The default value is 60s
},
},
}
// Instantiate the client object of the requested product (with CVM as an example)
const client = new CvmClient(clientConfig)
// Call the API you want to access through the client object; you need to pass in the request object and the response callback function
client.DescribeZones().then(
(data) => {
console.log(data)
},
(err) => {
console.error("error", err)
}
)
The input parameters for instantiating Client support the clientConfig data structure. For more information, see ClientConfig.
Was this page helpful?