Help Center> > SDK Reference > Using TTSC SDK (Java) >Initializing Client

Initializing Client

Initializing Client

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
      // Define authInfo. The ak, sk, region, and projectId parameters are mandatory. The endpoint parameter is optional.
      AuthInfo authInfo = new AuthInfo(ak, sk, ttsRegion, projectId);
 
      // Define config. All parameters are optional.
      CustomTtsConfig config = new CustomTtsConfig();
      // Set the connection timeout interval. The default value is 5,000 ms.
      config.setConnectionTimeout(CustomTtsConstant.DEFAULT_CONNECTION_TIMEOUT);
      // Set the request timeout interval. The default value is 1,000 ms.
      config.setRequestTimeout(CustomTtsConstant.DEFAULT_CONNECTION_REQUEST_TIMEOUT);
     // Set the socket timeout interval. The default value is 5,000 ms.
      config.setSocketTimeout(CustomTtsConstant.DEFAULT_SOCKET_TIMEOUT);
   

      //  Construct TtsCustomClient based on authInfo and config.
      CustomTtsClient tts = new CustomTtsClient(authInfo, config);
  • By invoking CustomTtsClient, you can call the TTSC SDK. Initialization parameters include the AuthInfo and CustomTtsConfig classes.
  • Table AuthInfo class initialization lists the initialization parameters of the AuthInfo class. Mandatory parameters include ak, sk, ttsRegion, and projectId. The endpoint parameter is optional.
  • Table CustomTtsConfig class initialization lists the initialization parameters of the CustomTtsConfig class. All the parameters are optional.
Table 1 AuthInfo class initialization

Name

Mandatory

Description

ak

Yes

User AK, string

sk

Yes

User SK, string

ttsRegion

Yes

Region, such as cn-north-4, string

projectId

Yes

Tenant ID. The value is a string and corresponds to the region. You can view it on the My Credentials page.

endpoint

No

Optional configuration, string. Generally, the default value is used.

For example, the endpoint of CN North-Beijing4 is https:// sis-ext.cn-north-4.myhuaweicloud.com.

Table 2 CustomTtsConfig class initialization

Name

Mandatory

Description

socketTimeout

No

Socket timeout interval, int. The default value is 5,000 ms.

connectionTimeout

No

Connection timeout interval, int. The default value is 5,000 ms.

requestTimeout

No

Request timeout interval, int. The default value is 1,000 ms.