Book Image

Learning Microsoft Cognitive Services

By : Leif Larsen
Book Image

Learning Microsoft Cognitive Services

By: Leif Larsen

Overview of this book

Take your app development to the next level with Learning Microsoft Cognitive Services. Using Leif's knowledge of each of the powerful APIs, you'll learn how to create smarter apps with more human-like capabilities. ? Discover what each API has to offer and learn how to add it to your app ? Study each AI using theory and practical examples ? Learn current API best practices
Table of Contents (20 chapters)
Learning Microsoft Cognitive Services
About the Author
About the Reviewer
Customer Feedback
Additional Information on Linguistic Analysis


Artificial intelligence and machine learning are complex topics, and adding such features to applications has historically required a lot of processing power, not to mention tremendous amounts of learning. The introduction of Microsoft Cognitive Service gives developers the possibility to add these features with ease. It allows us to make smarter and more human-like applications.

This book aims to teach you how to utilize the APIs from Microsoft Cognitive Services. You will learn what each API has to offer and how you can add it to your application. We will see what the different API calls expect in terms of input data and what you can expect in return. Most of the APIs in this book are covered with both theory and practical examples.

This book has been written to help you get started. It focuses on showing how to use Microsoft Cognitive Service, keeping current best practices in mind. It is not intended to show advanced use cases, but to give you a starting point to start playing with the APIs yourself.

What this book covers

Chapter 1, Getting Started with Microsoft Cognitive Services, introduces Microsoft Cognitive Services by describing what it offers and providing some basic examples.

Chapter 2, Analyzing Images to Recognize a Face, covers most of the image APIs, introducing face recognition and identification, image analysis, optical character recognition, and more.

Chapter 3, Analyzing Videos, introduces emotion analysis and a variety of video operations.

Chapter 4, Letting Applications Understand Commands, goes deep into setting up Language Understanding Intelligent Service (LUIS) to allow your application to understand the end users' intents.

Chapter 5,Speak with Your Application, dives into different speech APIs, covering text-to-speech and speech-to-text conversions, speaker recognition and identification, and recognizing custom speaking styles and environments.

Chapter 6, Understanding Text, covers a different way to analyze text, utilizing powerful linguistic analysis tools, web language models and much more.

Chapter 7, Extending Knowledge Based on Context, introduces entity linking based on the context. In addition, it moves more into e-commerce, where it covers the Recommendation API.

Chapter 8, Querying Structured Data in a Natural Way, deals with the exploration of academic papers and journals. Through this chapter, we look into how to use the Academic API and set up a similar service ourselves.

Chapter 9, Adding Specialized Search, takes a deep dive into the different search APIs from Bing. This includes news, web, image, and video search as well as auto suggestions.

Chapter 10, Connecting the Pieces, ties several APIs together and concludes the book by looking at some natural steps from here.

Appendix A, LUIS Entities and Intents, presents a complete list of all pre-built LUIS entities and intents.

Appendix B, Additional Information on Linguistic Analysis, presents a complete list of part-of-speech tags and phrase types.

Appendix C, License Information, presents relevant license information for all third-party libraries used in the example code.

What you need for this book

To follow the examples in this book you will need Visual Studio 2015 Community Edition or later. You will also need a working Internet connection and a subscription to Microsoft Azure; a trial subscriptions is OK too.

To get the full experience of the examples, you should have access to a web camera and have speakers and a microphone connected to the computer; however, neither is mandatory.

Who this book is for

This book is for .NET developers with some programming experience. It is assumed that you know how to do basic programming tasks as well as how to navigate in Visual Studio. No prior knowledge of artificial intelligence or machine learning is required to follow this book.

It is beneficial, but not required, to understand how web requests work.


In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "With the top emotion score selected, we go through a switch statement, to find the correct emotion."

A block of code is set as follows:

     public BitmapImage ImageSource
         get { return _imageSource; }
             _imageSource = value;

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

     private BitmapImage _imageSource;
     public BitmapImage ImageSource
             _imageSource = value;

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "In order to download new modules, we will go to FilesSettings | Project Name | Project Interpreter."


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.

  2. Hover the mouse pointer on the SUPPORT tab at the top.

  3. Click on Code Downloads & Errata.

  4. Enter the name of the book in the Search box.

  5. Select the book for which you're looking to download the code files.

  6. Choose from the drop-down menu where you purchased this book from.

  7. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows

  • Zipeg / iZip / UnRarX for Mac

  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at We also have other code bundles from our rich catalog of books and videos available at Check them out!

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to and enter the name of the book in the search field. The required information will appear under the Errata section.


Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at [email protected] with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.


If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.