Help Center/ Cognitive Engagement Center/ API Reference/ Chatbot Management Interface Reference/ Interface for Generating TTS Voices Based on Texts
Updated on 2023-09-27 GMT+08:00

Interface for Generating TTS Voices Based on Texts

Description

This interface, provide by the OIAP, is invoked by third-party systems to generate TTS voices.

If the text to be converted is long, the interface response time increases accordingly.

Interface Method

POST

URI

https://IP:PORT/oifde/rest/api/tts/texttovoice

Message Header

Content-Type:application/json; charset=UTF-8

Request

Table 1 Parameters in the request body

No.

Parameter

Type

Mandatory

Description

1

tenantId

String

Yes

Tenant ID.

2

authToken

String

Yes

Authentication token.

For details, see C3 OIAP Interface Authentication.

3

text

String

Yes

Text to be synthesized, which must be encoded using UTF-8.

4

config

Object

Yes

TTS configuration information.

For details about the parameters of this object, see Table 2.

Table 2 config

No.

Parameter

Type

Mandatory

Description

4.1

voiceName

String

Yes

Model feature string, which is used by the server to invoke different models.

The options are as follows:

  • cn_chengshuxing_common: mature
  • cn_kefuman_common: graceful
  • cn_roumeiqian_common: soft
  • cn_tianmeiru_common: sweet
  • cn_ziranzhen_common: natural

4.2

pitch

String

No

Fundamental frequency, which is used to adjust the pitch.

The value ranges from –500 to 500. The default value is 0.

4.3

volume

String

No

Volume, which is used to adjust the volume.

The value ranges from 0 to 100. The default value is 50.

4.4

speed

String

No

Speed, which is used to adjust the speech speed.

The value ranges from –500 to 500. The default value is 0.

Response

  • Status code: 200
    Table 3 Parameters in the response body

    No.

    Parameter

    Type

    Description

    1

    retCode

    String

    Result code. The value 0 indicates success and other values indicates failure.

    2

    retMsg

    String

    Description of a failure cause.

    3

    data

    Object

    Return result.

    For details about the parameters of this object, see Table 4.

    Table 4 data

    No.

    Parameter

    Type

    Description

    3.1

    format

    String

    Audio encoding format.

    3.2

    sampleRate

    Integer

    Audio sampling rate.

    3.3

    voiceData

    String

    Base64-encoded voice data.

    3.4

    sentences

    List

    Output sentence information.

    For details about the parameters of this object, see Table 5.

    Table 5 sentences

    No.

    Parameter

    Type

    Description

    3.4.1

    st

    Integer

    Start timestamp of a sentence, in milliseconds.

    3.4.2

    et

    Integer

    End timestamp of a sentence, in milliseconds.

    3.4.3

    offset

    Integer

    Start position of a sentence in the original text, in bytes.

    3.4.4

    len

    Integer

    Length of a sentence in the original text, in bytes.

  • Status code: 400

    Incorrect request. Check the request path and parameters.

  • Status code: 401

    Unauthorized operation. 1. Check whether you have purchased related services. 2. Contact customer service to check the status of your account.

  • Status code: 404

    The requested content is not found. Check the request path.

  • Status code: 500

    Business failure. Check the values of parameters in the request.

Error code.

None

Example

Request header

Content-Type:application/json; charset=UTF-8

Request body message

{
    "config": {
       "voiceName":"cn_tianmeiru_common"		
    },
    "text":"Hello, test the TTS interface.",
    "authToken": "********************",
    "tenantId":"********************"
}

Response body message

{
  "data": {
    "sentences": [
      {
        "st": 0,
        "offset": 0,
        "len": 48,
        "et": 2790
      }
    ],
    "voiceData": "UklGRuRsAQBXQVZFZm10IBA",
    "format": "wav",
    "sampleRate": "16000"
  },
  "retCode": "0"
}