The content of this page has been automatically translated by AI. If you encounter any problems while reading, you can view the corresponding content in Chinese.
Help & Documentation>Automatic Speech Recognition>Quick Start>Quick Server API Connection In One Minute

Quick Server API Connection In One Minute

Last updated: 2025-04-03 15:44:14

Overview

This document describes how to use API 3.0 Explorer to debug ASR APIs online and quickly integrate the corresponding Tencent Cloud SDK into your local project.

Directions

Activate ASR Service

Before calling the Speech Recognition related APIs, you need to enter the Speech Recognition Console to complete real-name authentication and face authentication. After authentication, read the "User Agreement" and check "I have read and agree to the User Agreement," then click [Activate Now] to activate recording file recognition, real-time speech recognition, single-sentence recognition, recording file recognition express edition, and asynchronous stream recognition service APIs with one click. If you need to activate the business license verification or Value-Added Tax Invoice Verification (VTIV) feature, you can apply on the official website service introduction page. Once approved, you can use the service.


After the service is successfully activated, you will get the free tiers of calls for each service, which can be viewed on the Resource Pack Management page. In addition, you can also purchase resource packages for various speech recognition services on the Speech Recognition Purchase page. After the free tiers and number of resource package calls are used up, API calls will be billed in the pay-as-you-go mode and settled monthly/daily. For billing details, see the Billing Overview of speech recognition.

Debugging ASR APIs

After the ASR service is successfully activated, enter the ASR API 3.0 Explorer online interface debugging page, select the interface you need to call, and fill in the input parameters. The specific meanings of the corresponding interface input parameters can be found in the "Parameter Description" tab of the API 3.0 Explorer interface.
Description
The platform will provide a Temporary Access Key for the logged-in user for debugging purposes.



After filling in the Input Parameters, select the "Code Generation" tab to see the automatically generated code in different programming languages (supporting Java, Python, Node.js, PHP, GO, .NET, C++). Some field information and filled content in the generated code are related. If you need to adjust the input parameters, you can modify the parameter values on the left and regenerate the code.

Select the "Online Calling" tab and click [Send Request] to make a real request for debugging and reference.



Integrate ASR SDK

Make sure the local dependency environment meets the following conditions:
Programming Environment
SDK Integration Requirements
Node.js
Requires NODEJS version 10.0.0 or above
Python
Requires Python versions 2.7, 3.6 to 3.9
Java
JDK 7 or above is required
Go
Go 1.9 or above is required (if using go mod, Go 1.14 or above is needed)
.Net
.NET Framework 4.5+ or .NET Core 2.1 is required
PHP
PHP 5.6.0 or later is required
C++
The compiler for C++ v11 or above is required, i.e., GCC v4.8 or above. Currently, only the Linux installation environment is supported, while Windows is not
Ruby
Ruby 2.3 or later is required
Install the Tencent Cloud ASR SDK corresponding to the local dependency environment. Below, Node.js is used as an example to illustrate the SDK installation and usage methods. For SDK usage methods in other languages, please refer to the Tencent Cloud SDK User Manual.

Installing through npm (recommended)

Using npm to install is the recommended method for using the NODEJS SDK, as npm is a package manager for NODEJS. For detailed information about npm, please visit the npm official website.
1. Run the following installation command:
npm install tencentcloud-sdk-nodejs --save
2. Refer to the corresponding module code in your code. For more information, please see the sample code.
3. The above import method downloads the SDKs of all Tencent Cloud services to your local system. You can replace tencentcloud-sdk-nodejs with tencentcloud-sdk-nodejs-cvm/cbs/vpc to import the SDK of the specific product. In the code, change require("tencentcloud-sdk-nodejs") to require("tencentcloud-sdk-nodejs-cvm/cbs/vpc"), and the rest remains unchanged. For more information, see the samples. This can greatly save storage space.

Installing through source package

1. Go to the GitHub repository URL or the quick download URL to download the source code zip file.
2. Decompress the source package to an appropriate location in your project.
3. Refer to the corresponding module code in your code. For more information, please see the sample code.

Example

After the SDK installation is completed, you can reference the code automatically generated by API 3.0 Explorer in your project code. Taking Node.js as an example, the following is a simple demo:
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 a TypeScript-supported project, call as follows:
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 instantiation parameters of the Client support the clientConfig data structure and description. For details, please refer to ClientConfig.