Scenarios
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.
Operation Steps
Enabling Speech Recognition Service
Before calling ASR APIs, you need to access the Speech Recognition Console for authentication. After completing authentication, read the "User Agreement", check "I have read and agree to the User Agreement", then click Activate Now to enable real-time speech recognition APIs with one click. If you need to enable business license verification or VTIV features, go to the service introduction page on the official website to apply. The service will be available 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.
Fill in the input parameters, then select the "Code Generation" tab to see automatically generated code in different programming languages (supported languages include Java, Python, Node.js, PHP, GO, .NET, C++). Some field information in the generated code is associated with the filled content. If adjustments are needed, modify the parameter values on the left side and regenerate the code.
Select the Online invocation tab, click send request to perform a real request for debug and reference.
Integrating ASR SDK
Confirm that your local dependent environment meets the following requirements:
|
Node.js | Node.js 10.0.0 or later |
Python | Python 2.7 or 3.6–3.9 |
Java | JDK 7 or later |
Go | Go 1.9 or later (or Go 1.14 if go.mod is used) |
.NET | .NET Framework 4.5+ or .NET Core 2.1 |
PHP | PHP 5.6.0 or later |
C++ | 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) |
Ruby | Ruby 2.3 or later |
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 Via Npm (Recommended)
To install via npm is the recommended method for using the Node.js SDK. npm is the package management tool for Node.js. For details about npm, refer to npm official website. 1. Execute 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 import method will download SDKs of all Tencent Cloud products to local. You can change tencentcloud-sdk-nodejs to tencentcloud-sdk-nodejs-cvm/cbs/vpc to import SDKs for specific products. In your code, change require("tencentcloud-sdk-nodejs") to require("tencentcloud-sdk-nodejs-cvm/cbs/vpc"). The rest remains unchanged. See the sample for reference. This can save very large 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 client models for the corresponding product module.
const CvmClient = tencentcloud.cvm.v20170312.Client
const clientConfig = {
// Tencent Cloud Certification info
credential: {
secretId: "secretId",
secretKey: "secretKey",
},
// product region
region: "ap-shanghai",
// optional configuration instance
profile: {
signMethod: "HmacSHA256", // signature method
httpProfile: {
reqMethod: "POST", // Request method
reqTimeout: 30, // Request timeout, default 60s
},
},
}
// Instantiate a client object for the request product (for example, cvm)
const client = new CvmClient(clientConfig)
// Call the desired API through the client object, require the input of request object and 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 client models for the corresponding product module.
const CvmClient = tencentcloud.cvm.v20170312.Client
const clientConfig = {
// Tencent Cloud Certification info
credential: {
secretId: "secretId",
secretKey: "secretKey",
},
// Product region
region: "ap-shanghai",
// Optional configuration instance
profile: {
signMethod: "HmacSHA256", // Signature method
httpProfile: {
reqMethod: "POST", // Request method
reqTimeout: 30, // Request timeout, default 60s
},
},
}
// Instantiate a client object for the request product (for example, cvm)
const client = new CvmClient(clientConfig)
// Call the desired API through the client object, require the input of request object and 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.