Skip to main content

Translation Callback Information (TranslatorResult)

AndroidiOSPC

If you are using the Unity engine, refer to TranslatorResult in the Unity SDK.

Data Structure​

FINTLTranslatorResult: Inherited from FINTLBaseResult, contains basic information

caution
  • The translation callback returns "Invalid param, openid or token empty", which is caused by not passing in openid or token.Login again and obtain the correct openid and token from the authResult login state, then pass them into the interface.
  • The translation callback returns "msg":"invalid config","ret:91002", which is caused by missing backend configuration. You can contact the Player Network Assistant for individual configuration.

translatorResp Text Translation​

ParametersTypeExplanation
translatorRespstringProcessing 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 results
// Example demo of TranslatorResp content returned by FINTLTranslatorResult:
{
"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​

retCodemessageExplanation
0SuccessSuccess
1001ParamsErrorParameter Error
1002ServiceInternalErrorInternal Service Error
1003PermissionErrorPermission error, the entered appId may not exist or the token is invalid
1007Rate limit reachedDaily PV or QPM exceeded limit

asrRsp Speech-to-Text​

ParametersTypeExplanation
asrRspstringProcessing result returned by the translation service. The ASR speech-to-text translation needs to be handled on the Project side. See asr_rsp for details.

Code Example:

// Handle translation results
// Example demo of asrRsp content returned by FINTLTranslatorResult:
{
"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​

NameTypeExplanation
traceIdstringA unique request ID can be set for tracking requests.
messagestringTranslator result message
resultresult objectAn object of Result type
retCodestringThe Service return code. Valid values include: "0" - success, "1001" - parameter error, "1002" - internal Service error.

result​

ParametersTypeExplanation
voiceTextStrstringASR speech text result

asrRsp Speech-to-Text (V2)​

ParametersTypeExplanation
asrRspstringProcessing 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

Code Example:

// Handle translation results
// Example demo of asrRsp content returned by FINTLTranslatorResult:
{
"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)​

NameTypeExplanation
traceIdstringA unique request ID can be set for tracking requests.
messagestringTranslator result message
resultresult objectAn object of Result type
retCodestringThe Service return code. Valid values include: "0" - success, "1001" - parameter error, "1002" - internal Service error.

result (V2)​

ParametersTypeExplanation
textstringASR speech text result
startfloat64Only used for streaming platforms
endfloat64Only used for streaming platforms
wordsstringOnly used for streaming platforms