Over a million developers have joined DZone.

Windows Phone 8 Text To Speech (TTS)

DZone's Guide to

Windows Phone 8 Text To Speech (TTS)

· Java Zone ·
Free Resource

The CMS developers love. Open Source, API-first and Enterprise-grade. Try BloomReach CMS for free.

In this article, we will see how to integrate the Text-To-Speech engine with Windows Phone 8.

In Windows Phone 8, it is easy to integrate Text-To-Speech to get the voice for a given input string.

Create a new Windows Phone 8 project and enable the speech recognition capabilities “ID_CAP_SPEECH_RECOGNITION” in the WMAppManifest.xml file as shown below. 

Figure 1: Create one Button and TextBlock to do the Text-To-Speech operation.


  1. <phone:PhoneApplicationPage
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
     <!--LayoutRoot is the root grid where all page content is placed-->
     <TextBlockText="MY APPLICATION"Style="{StaticResource PhoneTextNormalStyle}"Margin="12,0"/>
     <TextBlockText="page name"Margin="9,-7,0,0"Style="{StaticResource PhoneTextTitle1Style}"/>
     <!--ContentPanel - place additional content here-->

Write the following code in the Speech button's click event.

C# Code
Add the namespace:

  1. private async void getOutputBtn_Click(object sender, RoutedEventArgs e) 
     var speech = new SpeechSynthesizer(); 
     await speech.SpeakTextAsync(inputStringBox.Text.ToString()); 

The SpeakTextAsync() method is asynchronous. So we need to use the await keyword to do the operation.

Now build and run your application. Enter the text into the input box as you wish. Here I write “Welcome to C# corner”. Click the Speech button and listen to the voice.

Figure 2: Windows Phone 8

It works depending on your default settings that you set in your phone. You can change the voice format as male or female and the language is as shown in the following screen.

Go to Settings > Speech. Select the voice format.

BloomReach CMS: the API-first CMS of the future. Open-source & enterprise-grade. - As a Java developer, you will feel at home using Maven builds and your favorite IDE (e.g. Eclipse or IntelliJ) and continuous integration server (e.g. Jenkins). Manage your Java objects using Spring Framework, write your templates in JSP or Freemarker. Try for free.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}