In this tutorial we will learn how to use Bing Image Search API , Remember in our First Example of cognitive services we had created a demo Bing Speech API , In this tutorial we will extend the same demo to search image i.e. we will pass the text result of Bing Speech API to Bing Image Search API, yes and we will call the cognitive service using https REST like we are calling normal https web services , In our first example of Bing Speech API we had used .net Client Library to make REST call of API for the ease in .net. As all the cognitive services are https REST API that can be called using any language which makes an https call. If you had missed part1 of this series you can find it here.
To register for Bing Image Search API follow the steps.
- Navigate to https://azure.microsoft.com/en-us/try/cognitive-services/
- Navigate to Search tab and select Bing Search API and press get api key.
- Select I agree and Your region as shown in image
- Login with your account to get key
- Save your key
Now It’s time to recall the part-1, In which we had covered Speech to Text (STT) using Bing Speech API, We will simply use It’s result as input for Bing Image Search API.
Here onResponseReceived method we will get text of what we had speak, now will use that text as input for Bing Image Search API, As show in below method,
In Above method will simply making https REST request to API (that means it is not necessary that one can use cognitive services only in WPF application or using C# language, one can use it with any other language) and it will result json response.
Now let’s perform following steps to implement Bing Image Search API. first download part1 from here.
- First add Image tag in MainWindow.xaml or simply change the code between <Grid></Grid> with given code below.
- Then inside Solution explorer, right click your project and click manage nuget packages,
- Inside NuGet Package manger window navigate to browse tab and search for Newtonsoft.Json
- Also right click on reference and reference of System.Web
- Create a class or data structure to store the json Result as per your need (optional)
- Finally Add Search Image Method and it’s call to MainWindow.xaml.cs