Azure Cognitive Services

Azure Cognitive Services

In this article, we’ll learn about the Azure Cognitive Services, how it integrates into various other tools provided by Azure and Microsoft AI ecosystem. We’ll explore the multitudes of domains of artificial intelligence and machine learning that are thoroughly supported by the Azure Cognitive Services and then also learn the ways to call the cognitive services through REST APIs and SDK. This will be a wholesome article on Azure Cognitive Services. The following articles, How to Create Cognitive Services in Azure and Image Captioning using Azure Cognitive Services expand on this and provide a real-life hands-on experience for using the services of cognitive services for a wide range of applications. Moreover, the Microsoft Azure AI Fundamentals articles explore the overall AI-enabled by Microsoft, and the Exam AI – 900 is your guide to prepare for Microsoft Certification.

First of all, let us understand what Azure Cognitive Services is and how it plays role in the Microsoft AI Platform.

Microsoft Azure 

Azure is a cloud computing service developed by Microsoft which enables organizations and individuals to build, test, deploy and manage their applications in high availability and rapidly scalable platform with unparalleled security offerings and benefits in comparison to the traditional on-premises infrastructure. 

Microsoft AI Platform 

The Azure Cognitive Services is only a small fraction of the AI capabilities supported by Microsoft. A plethora of infrastructure, frameworks, and tools as well as services are provided to develop AI applications and connect with the SQL Server and Power BI. 

Some organizations cannot afford a dedicated team of developers and a special one that is fully focused on AI alone. This shortcoming is taken care of with tools such as the Microsoft Power Platform that enables low-code development using Microsoft Flow, PowerApps, and Power BI. Using these tools data can be analyzed and custom applications that are necessary for the businesses can be easily built. Integration to the Azure Cognitive Services and a wide range of tools for machine learning are integrated into this system. Moreover, Power BI especially consists of the functionalities required for Machine Learning which covers the A to Z of the workflow from Data Preparation to event automated machine learning. Besides, it allows the analysts to train and validate models while the system is also capable enough to detect relevant features in the model, choose appropriate algorithms, and hyper tuning of the parameters.  

Azure Cognitive Services 

Azure Cognitive Services is one of the services offered by Microsoft Azure that enables a wide range of organizations to build cognitive intelligence for applications with client library SDKs and REST APIs. Azure Cognitive Services allows developers to integrate cognitive features into applications with no prior knowledge of Machine Learning, Data Science, and Artificial Intelligence skillset. From Computer Vision to Natural Language Processing and Conversational AI, Azure Cognitive Services provides the support for a diverse prospect of applications. Numerous articles on Creating Cognitive Services in AzureFace Detection and Recognition with Azure Cognitive ServicesImage Captioning with Azure Cognitive Services with hands-on tutorial guidelines to apply the cognitive service of Azure for different types of applications can be learned here on C-SharpCorner itself. Currently, there are over 20 Cognitive Services in Azure and are divided into the following categories. 


Source: Microsoft Azure Face Identification

The articles, Face Detection and Recognition with Azure Cognitive Services and Image Captioning with Azure Cognitive Services provide the overlook of what vision tools are capable of. If you want to analyze an image or a video, vision in Azure Cognitive Services provides the tools for the extractions of data from images. Face Recognition, Object Detection, Text detection are mere some basic features enabled by the power of Cognitive Service in Azure. These capabilities are the outcome of the deep learning image recognition models that are fully trained which can also be customized for the recognition of particular objects in images and videos. The Azure Cognitive Services provides these services under the names of Computer Vision, Custom Vision, and Face API.  


Source: Microsoft Azure Cognitive Service - Speech

The Speech service in Azure Cognitive Services can translate speech-to-text, text-to-speech as well as real-time translation in numerous languages. The speech models can be customized as per the need for particular acoustic environments, factory floor and even training the service to recognize and pronounce unique cant. All of the services provided under Speech are Speech to Text, Text to Speech, Speech Translation, and Speaker Recognition. Can you imagine, the Azure Cognitive Service can help you build an application to recognize people through speaking based on audio? 


Source: Microsoft Azure Translator

Texts can now be understood, analyzed, and even translated using the Language service in Azure Cognitive Services. The tedious mundane tasks of QnA now be automated with the simple conversation of the FAQ to the interactive chatbot. Sentiments can now be extracted and the key phrases can be used for text analytics all the while understanding the meaning of the comment of the user through the Language Understanding Service. The meaning from the unstructured text can be extracted with the services such as Language Understanding, QnA Maker, Text Analytics and Translator in Azure Cognitive Services (ACS).  


Source: Anomaly Detection: Microsoft Cognitive Service

Faster Decisions for users – individuals to business can be supported with the Decision Service in Azure Cognitive Services. Applications that provide informed recommendations with efficient decision making can now be easily built. With the personalized service, the engaging, relevant, and peculiar experience can be tailored to every user thus increasing the satisfaction and usability of the app. Moreover, through the Anomaly Detector, problems in the time series data can be identified. With the Decision service in ACS, Anomaly Detection, Personification, and Content Moderation are easier than ever before.   

Web Search

Through the Bing Search API provided by the Azure Cognitive Services, images can be searched or searches can be done using images. The power of the Microsoft Bing search engine is available through the Bing Search API for any apps you develop.  

Source: Building Intelligent Apps with Cognitive APIs

Calling Cognitive Services API 

The Azure Cognitive Services allows multiple ways to access it. From SDKs to REST APIs, there are different methods of access and use for convenience, environment, and setup. The SDKs support programming languages such as Python, C#, Java, Go, and Javascript and the APIs can be called straight away from the code through standard methods from the library. Furthermore, the cognitive services can also be accessed via REST API URL. The REST APIs make it extremely convenient to call the Cognitive Services no matter what environment you are irrespective of the programming language being used.  

To learn about how this API call can be used in the application, you can check out the hands-on article for Face Detection and Object Recognition with Image Captioning in Face Detection and Recognition with Azure Cognitive Services and Image Captioning with Azure Cognitive Services respectively.  

While using the vision features in Azure Cognitive Services for face detection in Python, the following statements would be required to load the libraries.  

from import FaceClient 

For the vision features for applications such as Image Captioning, the computer vision library would require to be imported.  

from import ComputerVisionClient 

Similarly, we used the C# SDK and want to import the libraries of vision face detection, this would be the required statement.  

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

Similarly, for the Text Analytics API, the statement to import libraries would look like this.  

using Microsoft.Azure.CognitiveServices.Language.TextAnalytics;  
using Microsoft.Azure.CognitiveServices.Language .TextAnalytics.Models; 

If you want to learn more about using Azure Cognitive Services with Power BI tools and many others, watch this video from our Azure Summit 2021.

Moreover, the requests will also be required to be authenticated using the subscription key or authentication token or through the use of Azure Active Directory.  

While deploying applications in production, the keys should be properly secured through the use of features such as Azure Key Vault.   

The URL of the endpoint will be in the following format. 

https://{Resource Name}

Through the use of the key and endpoint, the Azure Cognitive Service can be used with ease in applications from simple notebooks to production-grade software.  

Synthesizing Text into Speech 

One of the most beautiful implementations of AI in day-to-day life today is speech-to-text capability. A lot of blind people benefit from it making it a high impact feature in numerous apps. Let us learn how we can apply this in C# using the C# SDK for Azure Cognitive Services.   

First of all, the configuration for Speech credentials is required – the subscription key and service region.  

var configuration = SpeechConfig.FromSubscription( "Subscription Key of Azure", "Service Region you select eg. centralus" ); 

Next, the speaker must be accessed for us which is done through the speechsynthesizer.  

var synthesizer = new SpeechSynthesizer(configuration); 

Now, for the Text to Speech functionality, we would require some text. This can be obtained from console input for instance.  

string read_text = Console.ReadLine(); 

Let us now call the API and then synthesize the text into speech.  

var result = await synthesizer.SpeakTextAsync(read_text); 


Thus, in this article, we learned about Microsoft Azure, the Microsoft AI Platform, and then dived deeper into Azure Cognitive Services. We explored the various domains of AI that are supported by Azure Cognitive Services such as Vision, Speech, Language, Decision, and Web Search. We then went on the process to call the cognitive services using APIs and also using the SDK through some sample codes for different service use cases and scenarios. Later we also learned a simple way to integrate text-to-speech in an application using C# SDK.  


Similar Articles