In this tutorial we will learn how to use Bing Emotion API ,In our previous example of cognitive demo we had combine two cognitive services Bing Speech API and Bing Emotion API using that we are finding images using speech to text(STT). To Extend this demo we will be using Bing Emotion API which will detect the emotion of person from the image that we had searched using Bing Image Search API. I would highly recommend you to go through previous to parts before starting with this demo.
To register for Bing Emotion API follow the steps.
- Navigate to https://azure.microsoft.com/en-us/try/cognitive-services/
- Navigate to Vision tab and select Bing Emotion api and press get api key.
- Select I agree and Your region as shown in image
- Login With Microsoft account to get your api key
- Save your key
Now from Part2 ,we already had the url of the searched image using Bing Image Search API, So will use the same url to get the emotion of person Using Bing Emotion API. We will simply create one method named as GetEmotion which takes String Url of image.( which we already have in part2)
This Method will make post call to Bing Emotion API with required parameters and API will return the json result. To store this json result we will create one class and named it EmotionResponse again it is an optional ,one can directly bind the json result.
First download the part2 from here, then follow the steps.
- Replace Design MainWindow.xaml with this
- Replace MainWindow.xaml.cs with below
- Also add two classes to store Json Response of Emotion API EmotionRequest and EmotionResponse