Leveraging Azure Cognitive Services to make intelligent Apps

Azure Cognitive Services is a collection of pre-built APIs, SDKs, and services that is available in Azure platform. These services are designed to enable developers to easily add intelligent features to their applications without having to build complex algorithms or models from scratch.

Azure Cognitive Services can be integrated with a wide range of development tools and platforms, including Visual Studio, .NET, Java, Python, Node.js, and many more.

Here are a few examples of the different services offered through Azure Cognitive Services:

1. Computer Vision

The computer Vision API uses machine learning algorithms to analyze and extract information from images, including object detection and recognition, text extraction, image analysis, and more.

  1. Object detection and recognition: The API can detect and identify objects in images, including people, vehicles, animals, and more.
  2. Optical character recognition (OCR): The API can extract text from images, including printed and handwritten text.
  3. Image analysis: The API can analyze images to determine their contents, including colors, shapes, and other visual features.
  4. Image tagging: The API can automatically assign descriptive tags to images based on their contents, making it easier to search and categorize images.
  5. Face detection and recognition: The API can detect and identify human faces in images and can even identify emotions and other facial expressions.

The other Azure Vision services include custom vision and Face API.

Let’s suppose you want to use Azure Computer Vision API in your .NET app. Let’s see below how we can achieve this requirement.

Step 1- Sign in into your Azure subscription. If you do not have one already, you can sign up for a free account at https://azure.com/free

Step 2- Head over the search bar and look for Azure Cognitive Services.

Step 3- Search for Computer Vision and click on ‘create’.

Step 4- Fill in the required information such as subscription, resource group, name, location and pricing tier. Click on the “Review + Create” button, review the details and then click on “Create” to create the resource.

Step 5- Once the resource is created, navigate to the “Keys and Endpoint” page for the resource, where you can obtain the API endpoint and keys needed to authenticate your application.

Step 6- Next, go ahead and create a Web App to implement Azure Computer Vision into the app. For this purpose, I have now created an app- AspNetCoreWebApp. Next, I would need to install the Microsoft.Azure.CognitiveServices.Vision.ComputerVision NuGet package using the NuGet package manager.

Step 7- Now add following using statements on your .Net code.

using Microsoft.Azure.CognitiveServices.Vision.ComputerVision;
using Microsoft.Azure.CognitiveServices.Vision.ComputerVision.Models;

Step 8- Next, create an instance of the ComputerVisionClient class using your API endpoint and subscription key as shown below:

var endpoint = "<your API endpoint>";
var subscriptionKey = "<your subscription key>";

var client = new ComputerVisionClient(new ApiKeyServiceClientCredentials(subscriptionKey))
{
    Endpoint = endpoint
};

Step 9- Use the AnalyzeImageAsync method to analyze an image using the API. For example, the following code analyzes an image stored in a byte array:

var imageBytes = File.ReadAllBytes("path/to/image.jpg");
var features = new List<VisualFeatureTypes>
{
    VisualFeatureTypes.Categories, VisualFeatureTypes.Description, VisualFeatureTypes.Tags
};

var result = await client.AnalyzeImageInStreamAsync(new MemoryStream(imageBytes), features);

Step 10- The result variable contains the analysis results returned by the API. You can access information such as the image caption, categories, and tags using the Description, Categories, and Tags properties of the ImageAnalysis object.

That’s it! You can use the Azure Computer Vision API to analyze images in your .NET application using these steps. Make sure to refer to the API documentation for more details on the available methods and options.

Additionally, there are other Azure Cognitive Services that you can choose from based on your use cases-

2. Speech

The Speech API uses advanced machine learning algorithms to accurately transcribe speech into text, and to generate spoken output from text.

Common scenarios for speech include:

  • Captioning: Learn how to synchronize captions with your input audio, apply profanity filters, get partial results, apply customizations, and identify spoken languages for multilingual scenarios.
  • Audio Content Creation: You can use neural voices to make interactions with chatbots and voice assistants more natural and engaging, convert digital texts such as e-books into audiobooks and enhance in-car navigation systems.
  • Call Center: Transcribe calls in real-time or process a batch of calls, redact personally identifying information, and extract insights such as sentiment to help with your call center use case.
  • Language learning: Provide pronunciation assessment feedback to language learners, support real-time transcription for remote learning conversations, and read aloud teaching materials with neural voices.
  • Voice assistants: Create natural, humanlike conversational interfaces for their applications and experiences. The voice assistant feature provides fast, reliable interaction between a device and an assistant implementation.

3. Language

There are multiple Language based Azure Cognitive Services. This includes-

3.1 Azure Cognitive Service for Language Service

3.2 Translator

3.3 Language Understanding (Classic)

3.4 QnA Maker (Classic)

4. Additional Cognitive Services

4.1 Anomaly Detection

The Anomaly Detection service in Azure can be used for various use cases such as detecting anomalies in IoT sensor data, financial data, and network traffic. One or more parameters can be set to be measured and Azure can detect and flag anomalies.

Hope, this blog post was helpful to you. If you have any questions or feedback, do let me know in the comment section and I shall get back to you. Thanks for a wonderful reader!

Public Cloud Consultant | Microsoft MVP | Solutions Specialist (Azure) | Azure Certified | Microsoft Certified Trainer A decade more experience working across various Microsoft products, programs, projects & technologies. Experience leading CoE (Centers of Excellence) for Azure, Microsoft 365, Dynamics 365 & Power Platform among others. Enabler in customer's hybrid cloud, cloud assessment, migration and modernization journey.

Leave a Reply

Your email address will not be published. Required fields are marked *