Translation Callback Information (TranslatorResult)
Data Structure
INTLTranslatorResult: Inherits from INTLBaseResult, and contains basic information
caution
- The translation callback returns
"Invalid param, openid or token empty"because the openid or token was not provided.You need to log in again and obtain the correct OpenID and token from the authResult login state to pass to the interface. - The translation callback returns
"msg":"invalid config","ret:91002"because there is a missing backend configuration. You can contact the Player Network assistant for separate configuration.
translatorResp Text Translation
| Parameters | Type | Explanation |
|---|---|---|
| translatorResp | String | Processing results returned by the translation service, text translation needs to be handled independently by the Project side. See translatorResp for details |
Code Example:
// Handle translation result
// Demo of TranslatorResp content returned by INTLTranslatorResult:
{
"ret": 0,
"sub_ret": -1,
"msg": "success",
"method_id": 2303,
"ret_code": 0,
"ret_msg": "Success",
"extra_json": "{}",
"translator_rsp": {
"debugInfo": null,
"message": "Success",
"result": [
{
"id": "c5b2802a287f58c9ce250f8c77fc6029",
"output": "Translated Text",
"text": "Original Text"
}
],
"retCode": "0",
"traceId": "trace"
},
"asr_rsp": ""
}
translatorResp
| retCode | message | Explanation |
|---|---|---|
| 0 | Success | Success |
| 1001 | ParamsError | Parameter Error |
| 1002 | ServiceInternalError | Internal Service Error |
| 1003 | PermissionError | Permission error, the entered appId may not exist or the token is invalid |
| 1007 | rate limit reached | Daily PV or QPM exceeded limit |
asrRsp Speech-to-Text
| Parameters | Type | Description |
|---|---|---|
| asrRsp | string | Processing results returned by the Service, ASR speech-to-text translation must be handled independently by the Project side. See asr_rsp for details |
Example code:
// Handle translation result
// Demo of asrRsp content returned by INTLTranslatorResult:
{
"ret": 0,
"sub_ret": -1,
"msg": "success",
"method_id": 2304,
"ret_code": 0,
"ret_msg": "Success",
"extra_json": "{}",
"translator_rsp": "",
"asr_rsp": {
"message": "Success",
"result": {
"duration": 1234,
"voiceTextStr": "Hello World!"
},
"retCode": "0",
"traceId": "traceId"
}
}
asr_rsp
| Name | Type | Description |
|---|---|---|
| traceId | string | A unique request id can be set to track requests |
| message | string | translator result message |
| result | result object | An object of type result |
| retCode | string | The Service return code, possible values are: "0" - success, "1001" - parameter error, "1002" - internal Service error |
result
| Parameters | Type | Description |
|---|---|---|
| voiceTextStr | string | ASR speech-to-text result |
asrRsp Speech-to-Text (V2)
| Parameters | Type | Description |
|---|---|---|
| asrRsp | string | Processing results returned by the Service, ASR speech-to-text translation V2 must be handled independently by the Project side. See asr_rsp (v2) for details |
Example code:
// Handle translation result
// INTLTranslatorResult's asr_rsp content demo is as follows:
{
"ret": 0,
"sub_ret": -1,
"msg": "success",
"method_id": 2306,
"ret_code": 0,
"ret_msg": "Success",
"extra_json": "{}",
"translator_rsp": "",
"asr_rsp": {
"message": "success",
"result": {
"end": 0,
"start": 0,
"text": "Hello World!",
"words": null
},
"retCode": 0,
"traceId": "traceId"
}
}
asr_rsp (V2)
| Name | Type | Description |
|---|---|---|
| traceId | string | A unique request id can be set to track requests |
| message | string | translator result message |
| result | result object | An object of Result type |
| retCode | string | The Service return code, possible values are: "0" - success, "1001" - parameter error, "1002" - internal Service error |
result (V2)
| Parameters | Type | Description |
|---|---|---|
| text | string | ASR speech-to-text result |
| start | float64 | Only used for streaming platforms |
| end | float64 | Only used for streaming platforms |
| words | string | Only used for streaming platforms |