Blog Post

AI - Machine Learning Blog
2 MIN READ

Azure AI document translation — Batch

BalaB's avatar
BalaB
Icon for Microsoft rankMicrosoft
Nov 12, 2021

Translate document in batch with Cognitive services

  • Batch translate pdf document from one language to another

Use Case

  • The below architecture shows how to do batch document translations
  • Here i have translationinput as input container for document
  • Then i created translationoutput as output container to store the output
  • For both create SAS key with Read and write.
  • At least read for translationinput
  • Write for translationoutput

Architecture

 

Steps

  • Create a new logic app
  • Create a new workload
  • create a new connection for blob storage where you have the data
  • to trigger the flow start when a file is uploaded
  • i am reading the pdf file — this step is not necessary

 

  • Now drag HTTP to send the translation request
  • Provide Ocp-Apim-Subscription-Key key which is from cognitive services
  • then provide the URL
https://cognitivesvcname.cognitiveservices.azure.com/translator/text/batch/v1.0/batches
 
  • Next configure the input and outputs
  • Here i am converting to 2 different languages
{
"inputs": [
{
"source": {
"sourceUrl": "https://storagename.blob.core.windows.net/translateinput?sp=racwl&st=2020-10-19T21:27:53Z&se=2020-10-21T05:27:53Z&spr=https&sv=2020-08-04&sr=c&sig=xxxxxxxxxxxxxxxxxxxxxxx"
},
"targets": [
{
"language": "fr",
"targetUrl": "https://storagename.blob.core.windows.net/translateoutput?sp=racwl&st=2020-10-19T21:29:02Z&se=2020-10-21T05:29:02Z&spr=https&sv=2020-08-04&sr=c&sig=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
},
{
"language": "id",
"targetUrl": "https://storaegname.blob.core.windows.net/translateoutput?sp=racwl&st=2020-10-19T21:29:02Z&se=2020-10-21T05:29:02Z&spr=https&sv=2020-08-04&sr=c&sig=xxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
]
}
]
}
 
  • source and targets are full blob sas keys
  • the above SAS keys are fake and just for sample

 

  • Next wait for 30 seconds

 

  • Now lets get the status
  • From the above batch submission, response header will have the URL to query for status
@{outputs('HTTP')['headers']?['Operation-Location']}
 
  • Make sure send the Ocp-Apim-Subscription-Key

 

  • Now save and run the logic app.
  • Once successful then go out storage explorer and see the translationoutput container for processed pdf file.
  • Done

Original article: Samples2021/Doctranslation.md at main · balakreshnan/Samples2021 (github.com)

Updated Nov 12, 2021
Version 1.0
No CommentsBe the first to comment