Microsoft Azure Stack is an extension of Azure—bringing the agility and innovation of cloud computing to your on-premises environment and enabling the only hybrid cloud that allows you to build and deploy hybrid applications anywhere. We bring together the best of the edge and cloud to deliver Azure services anywhere in your environment.

Cognitive Services Python SDK Samples

These samples will show you how to get up and running using the Python SDKs for various Cognitive Services services. They'll cover a few rudimentary use cases and hopefully express best practices for interacting with the data from these APIs.

We provide several meta-packages to help you install several packages at a time. Please note that meta-packages are only recommended for development purpose. It's recommended in production to always pin specific version of individual packages.

Getting Started

Prerequisites

A cognitive services API key with which to authenticate the SDK's calls. Sign up here by navigating to the Language or Search services and acquiring an API key. You can get a trial key for free which will expire after 30 days or create a Cognitive Services account on the Azure portal through the Use with an Azure subscription button.

Subscription keys are usually per service. For example, the subscription key for Spell Check will not be the same than Custom Search. Read the previous sign up link or the Azure portal for details on subscription keys.

Set up the environment variable LUIS_SUBSCRIPTION_KEY with your key if you want to execute LUIS tests.

Set up the environment variable SPELLCHECK_SUBSCRIPTION_KEY with your key if you want to execute SpellCheck tests.

Set up the environment variable TEXTANALYTICS_SUBSCRIPTION_KEY with your key if you want to execute TextAnalytics tests. You might override too TEXTANALYTICS_LOCATION (westcentralus by default).

Set up the environment variable AUTOSUGGEST_SUBSCRIPTION_KEY with your key if you want to execute Autosuggest tests.

Set up the environment variable CUSTOMSEARCH_SUBSCRIPTION_KEY with your key if you want to execute CustomSearch tests.

Set up the environment variable ENTITYSEARCH_SUBSCRIPTION_KEY with your key if you want to execute EntitySearch tests.

Set up the environment variable IMAGESEARCH_SUBSCRIPTION_KEY with your key if you want to execute ImageSearch tests.

Set up the environment variable NEWSSEARCH_SUBSCRIPTION_KEY with your key if you want to execute NewsSearch tests.

Set up the environment variable VIDEOSEARCH_SUBSCRIPTION_KEY with your key if you want to execute VideoSearch tests.

Set up the environment variable VISUALSEARCH_SUBSCRIPTION_KEY with your key if you want to execute VideoSearch tests.

Set up the environment variable WEBSEARCH_SUBSCRIPTION_KEY with your key if you want to execute WebSearch tests.

Set up the environment variable COMPUTERVISION_SUBSCRIPTION_KEY with your key if you want to execute Computer Vision tests. You might override too COMPUTERVISION_LOCATION (westcentralus by default).

Set up the environment variable CONTENTMODERATOR_SUBSCRIPTION_KEY with your key if you want to execute Content Moderator tests. You might override too CONTENTMODERATOR_LOCATION (westcentralus by default).

Set up the environment variable CUSTOMVISION_TRAINING_KEY with your key if you want to execute CustomVision Training tests.

Set up the environment variable CUSTOMVISION_PREDICTION_KEY with your key if you want to execute CustomVision Prediction tests.

Demo

A demo app is included to show how to use the project.

To run the complete demo, execute python example.py

To run each individual demo, point directly to the file. For example (i.e. not complete list):

python samples/language/spellcheck_samples.py

python samples/search/entity_search_samples.py

python samples/search/video_search_samples.py

To see the code of each example, simply look at the examples in the Samples folder. They are written to be isolated in scope so that you can see only what you're interested in.