from azure.identity import DefaultAzureCredential from azure.ai.translation.document import DocumentTranslationClient credential = DefaultAzureCredential () document_translation_client = DocumentTranslationClient ( endpoint = ", credential = credential ) Key concepts Once completed, set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables:ĪZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET. Translator resource by assigning the "Cognitive Services User" role to your service principal. You will also need to register a new AAD application and grant access to your With the Azure SDK, please install the azure-identity package: To use the DefaultAzureCredential type shown below, or other credential types provided from import AzureKe圜redential from azure.ai.translation.document import DocumentTranslationClient endpoint = " credential = AzureKe圜redential ( "" ) document_translation_client = DocumentTranslationClient ( endpoint, credential ) Create the client with an Azure Active Directory credentialĪzureKe圜redential authentication is used in the examples in this getting started guide, but you can alsoĪuthenticate with Azure Active Directory using the azure-identity library. Pass the key as a string into an instance of AzureKe圜redential. To use an API key as the credential parameter, The API key can be found in the Azure Portal or by running the following Azure CLI command:Īz cognitiveservices account keys list -name "resource-name" -resource-group "resource-group-name" Create the client with AzureKe圜redential Follow the instructions in the above link to format your endpoint: Note that the service requires a custom domain endpoint. You can find the endpoint for your Translator resource using the In order to interact with the Document Translation feature service, you will need to create an instance of a client.Īn endpoint and credential are necessary to instantiate the client object. custom-domain document-translation-resource \ To access the service, create a Translator resource.īelow is an example of how you can create a Translator resource using the CLI: # Create a new resource group to hold the Translator resource - # if using an existing resource group, skip this stepĪz group create -name my-resource-group -location westus2 The Document Translation feature supports single-service access only. Note: This version of the client library defaults to the v1.0 version of the service Create a Translator resource Install the Azure Document Translation client library for Python with pip: pip install azure-ai-translation-document You must have an Azure subscription and a.Python 3.6 or later is required to use this package.For more information and questions, please refer to Getting started Prerequisites Source code | Package (PyPI) | API reference documentation | Product documentation | Samples DisclaimerĪzure SDK Python packages support for Python 2.7 has ended 01 January 2022. Apply a custom translation model or glossaries to tailor translation to your specific case.Check the translation status and progress of each document in the translation operation.Translate numerous, large files from an Azure Blob Storage container to a target container in your language of choice.Use the client library for Document Translation to: Azure Document Translation client library for PythonĪzure Cognitive Services Document Translation is a cloud service that can be used to translate multiple and complex documents across languages and dialects while preserving original document structure and data format.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |