Announcements
This site is in read only until July 22 as we migrate to a new platform; refer to this community post for more details.
Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Google Cloud Batch document translation Asynchronously

am planning to do the batch document translation using java

while am doing it getting below error

 

{
"name": "projects/xxxxx/locations/us-central1/operations/071725548825-66d8a805-0000-2c24-afb4-883d24f96254",
"metadata": {
"@type": "type.googleapis.com/google.cloud.translation.v3beta1.BatchTranslateDocumentMetadata",
"state": "FAILED",
"submitTime": "2024-09-05T15:07:07Z"
},
"done": true,
"error": {
"code": 13,
"message": "Error: INTERNAL. Job state: FAILED.",
"details": [
{
"@type": "type.googleapis.com/google.rpc.DebugInfo",
"detail": "[ORIGINAL ERROR] generic::internal: Unexpected number of split document received. [type.googleapis.com/caip_orchestration.FailedTaskDetails='\\x08\\xb3\\xcc\\xde\\x02\\x12\\x0c\\x45XTRACT_TEXT\\x1a\\x8a\\x04\\nCtype.googleapis.com/cloud.ai.translation_hub.ExtractTextTaskPayload\\x12\\xc2\\x03\\n\\xb7\\x01/cns/tk-d/home/cloud-translation-hub-doc-processing/async_extraction/e=1/kid=75811/mkey=lro-data/ttl=7d/1066188461524/20240905-081000-66d52137-0000-252b-a991-089e08248498/split_output\\x12\\xbc\\x01/cns/tk-d/home/cloud-translation-hub-doc-processing/async_extraction/e=1/kid=75811/mkey=lro-data/ttl=7d/xxx/1000-66d52137-0000-252b-a991-089e08248498/extraction_output\\x1a\\x41\\x61pplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet\\\"\\x02\\x65n(\\x01']"
}
]
}
}

using below code

 

BatchTranslateDocumentResponse response = this.translationServiceClient

.batchTranslateDocumentAsync(parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig).get();

 

0 2 456
2 REPLIES 2

hi @ganeshp ,

I'd be glad to help you troubleshoot the batch document translation error in your Java code.

Error Analysis:

The error response indicates:

  • Code: 13 (INTERNAL)
  • Message: "Error: INTERNAL. Job state: FAILED."
  • Details: "Unexpected number of split document received."

This suggests an internal issue during document splitting for translation. Here are potential causes and solutions:

1. Document Format and Splitting:

  • Supported Formats: Ensure your documents are in a format supported by Cloud Translation API (e.g., PDF, DOCX, TXT).
  • Document Size: Large documents might be split for efficient processing. The error likely indicates the number of split document parts received by the translation service doesn't match its expectations.
  • Complex Layouts: Complex document layouts with nested structures might cause unexpected splitting behavior.

Solutions:

  • Check Document Size: If possible, reduce document size or try translating them individually.
  • Simplify Layout: If feasible, simplify document layouts to avoid unexpected splitting issues. Consider using tools like document converters to prepare files for translation.
  • Consider Chunking: If splitting is necessary, explore chunking your documents into smaller, predictable parts before submitting them to the API.

2. API Usage and Configuration:

  • Code Implementation: Double-check your code for any issues creating inputConfigs or outputConfig objects. Ensure they are correctly configured with the desired source and target languages.
  • Dependencies: Verify that you're using the latest version of the Cloud Translation API client library. Outdated libraries might have known bugs or compatibility issues.

Solutions:

  • Review Code: Carefully examine your code for mistakes in configuring the request.
  • Update Library: Update the Cloud Translation API client library to the latest version if necessary. Refer to the official documentation for instructions.

Further Troubleshooting:

  • Check Logs: Examine Google Cloud logs for further details that might help narrow down the issue.
  • Sample Code: If possible, provide a minimal reproducible code snippet demonstrating the error for more specific guidance.

Thank you,

 

Hi quangtrunghuynh,

Thanks for your reply,

I am getting below error , while am trying to do translate the below mentioned excel documentExcel.JPG

 even i tried by changing from .xls to .xlsx and also by removing empty sheets sheet2 and sheet3, same error repeating only for the above mentioned excel file,

code:  am using below code

public void translateBatchFromGoogleCloud(List<String> gsInputUriList, String gsOutputUri, String sourceLanguageCode, String targetLanguageCode) {

if (gsInputUriList != null && !gsInputUriList.isEmpty() && gsOutputUri != null && !gsOutputUri.equals("")) {

try {

// Set the parent location of the translation request
LocationName parent = LocationName.of(this.projectId, this.location);

// Define the input documents to translate
List<BatchDocumentInputConfig> inputConfigs = new ArrayList<>();
for (String gsInputUri : gsInputUriList) {
BatchDocumentInputConfig inputConfig = BatchDocumentInputConfig.newBuilder()
.setGcsSource(GcsSource.newBuilder().setInputUri(gsInputUri).build()).build();
inputConfigs.add(inputConfig);
}

BatchDocumentOutputConfig outputConfig = BatchDocumentOutputConfig.newBuilder()
.setGcsDestination(GcsDestination.newBuilder().setOutputUriPrefix(gsOutputUri).build()).build();

// Perform batch document translation
List<String> targetLanguageCodes = new ArrayList<String>();
targetLanguageCodes.add(targetLanguageCode);

BatchTranslateDocumentResponse response = this.translationServiceClient
.batchTranslateDocumentAsync(parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig).get();

// Print the response
System.out.println("Batch translation operation name:************************ " + response);

} catch (Exception e) {
// Handle execution errors
e.printStackTrace();
System.err.println("Error executing request: " + e.getMessage());

}


}
}

 

Please help me out, in resolving the above issue,

thanks & Regards,

Ganesh P