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();
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:
This suggests an internal issue during document splitting for translation. Here are potential causes and solutions:
1. Document Format and Splitting:
Solutions:
2. API Usage and Configuration:
Solutions:
Further Troubleshooting:
Thank you,
Hi quangtrunghuynh,
Thanks for your reply,
I am getting below error , while am trying to do translate the below mentioned excel document
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