Bing Speech API- Cognitive Services

What is cognition?

The mental action or process of acquiring knowledge and understanding through thought, experience, and the senses.

What are Cognitive Services?

Cognitive services are a set of APIs that are designed to democratize artificial intelligence by enabling systems to see, hear, speak, understand and interpret our needs using natural methods of communication.
What these services generally do is bring structured semantic data to human knowledge I/O with a degree of confidence.

Vision Speech Language Knowledge Search
Computer Vision

Content Moderator




Bing Speech

Custom Speech Service

Speaker Recognition

Bing Spell Check

Language Understanding

Linguistic Analysis

Text Analytics




Entity Linking

Knowledge Exploration

QnA Maker


Bing Autosuggest

Bing Image Search

Bing News Search

Bing Video Search

Bing Web Search

Source Credit

Microsoft / Technical Community Content


Visual Studio 2017 – (community Edition / free to download)  – Activate Account for Cognitive Service

In this tutorial we will cover Bing speech Api for speech to text (STT) using wpf application in visual studio 2017. First we will start from how to get keys for Bing speech Api.

To register for Bing speech Api perform the following steps.

  1. Navigate to
  2. Navigate to speech tab and select Bing speech api and press get api key.Api
  3. Select I agree and Your region as shown in imageregion
  4. Login With Microsoft account to get your api keysign_in
  5. Save your key  Key

Now It’s time to create wpf application using visual studio 2017. Please follow the steps describe below,

  1. Open Visual studio 2017 ,In my case I am using community Edition .
  2. go to file menu,Click New then project
  3. Select WPF App (.Net Framework) from ,expand Installed > Templates > Visual C# > Windows Classic Desktop > and select WPF App (.NET Framework).CreateApp
  4. Then inside Solution explorer, right click your project and click manage nuget packages,Screenshot (30).png
  5. Inside the NuGet Package manger window navigate to browse tab and search for Microsoft.ProjectOxford.Speech and install both x-86 and x-64 version.nugetPackage
  6. In Solution Explorer check your references Speech Client will be added.references
  7. Now almost all set up is done ,let’s dive to app design, copy following code to your MainWindow.xaml file and replace the code between <Grid></Grid>.
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="3*"></ColumnDefinition>
<TextBlock FontSize="24" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" Margin="4">Bing Speech API Demo</TextBlock>
<Button x:Name="button" HorizontalAlignment="Center" VerticalAlignment="Center" Width="75" Click="button_Click"
Grid.Row="1" Grid.Column="0" Grid.RowSpan="3" Margin="4" Height="75">
<StackPanel Orientation="Vertical">
<TextBlock FontSize="16">Speak</TextBlock>
<TextBlock x:Name="status" TextWrapping="Wrap" Text="Not Listening" VerticalAlignment="Center" FontSize="16" Visibility="Collapsed"
Grid.Row="1" Grid.Column="1" HorizontalAlignment="Center" Margin="4"/>
<StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2">
<TextBlock x:Name="MySpeechResponse" FontSize="20" Margin="4" TextWrapping="Wrap" VerticalAlignment="Center" />
<TextBlock x:Name="MySpeechResponseConfidence" FontSize="12" Margin="4" TextWrapping="Wrap" VerticalAlignment="Center" />
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="RecordingBar" Visibility="Collapsed"
Grid.Row="0" Grid.Column="0" Grid.RowSpan="5" Grid.ColumnSpan="3">
<ProgressBar HorizontalAlignment="Left" Width="207" Margin="0,16,0,0" IsIndeterminate="True" />
view raw MainWindow.xaml hosted with ❤ by GitHub

8. Paste following code to MainWindow.xaml.cs

namespace BingSpeechApp
using System.Media;
using System.Threading;
using System.Windows.Threading;
using CognitiveServicesTTS;
using Microsoft.CognitiveServices.SpeechRecognition;
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
private MicrophoneRecognitionClient micClient;
public MainWindow()
this.micClient = SpeechRecognitionServiceFactory.CreateMicrophoneClient(
this.micClient.OnMicrophoneStatus += MicClient_OnMicrophoneStatus;
this.micClient.OnResponseReceived += MicClient_OnResponseReceived;
private void button_Click(object sender, RoutedEventArgs e)
this.MySpeechResponse.Text = string.Empty;
this.MySpeechResponseConfidence.Text = string.Empty;
private void MicClient_OnMicrophoneStatus(object sender, MicrophoneEventArgs e)
new Action(
() =>
if (e.Recording)
this.status.Text = "Listening";
this.RecordingBar.Visibility = Visibility.Visible;
this.status.Text = "Not Listening";
this.RecordingBar.Visibility = Visibility.Collapsed;
private async void MicClient_OnResponseReceived(object sender, SpeechResponseEventArgs e)
if (e.PhraseResponse.Results.Length > 0)
await Application.Current.Dispatcher.BeginInvoke(
DispatcherPriority.Normal, new Action(() =>
this.MySpeechResponse.Text = $"'{e.PhraseResponse.Results[0].DisplayText}',";
this.MySpeechResponseConfidence.Text = $"confidence: { e.PhraseResponse.Results[0].Confidence}";
view raw MainWindow.xaml.cs hosted with ❤ by GitHub

Download Demo Here


4 thoughts on “Bing Speech API- Cognitive Services

  1. […] 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. […]


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s