Namespaces
Variants
Actions
(Difference between revisions)

Using SSML for advanced text-to-speech on Windows Phone 8

Jump to: navigation, search
(Cadlg -)
m (Hamishwillee - Bot update - Fix metadata)
Line 1: Line 1:
[[Category:Draft]][[Category:Windows Phone 8]][[Category:Windows Phone]][[Category:Code Examples]][[Category:Code Snippet]][[Category:Silverlight]]
+
[[Category:Draft]][[Category:Windows Phone 8]][[Category:Windows Phone]][[Category:Code Snippet]][[Category:Code Snippet]][[Category:Silverlight]]
 
''Delete instructional text in italic''
 
''Delete instructional text in italic''
  
Line 11: Line 11:
 
|platform= <!--Windows Phone 8 -->
 
|platform= <!--Windows Phone 8 -->
 
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->  
+
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
|signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
+
|signing= <!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
|capabilities= <!-- ID_CAP_SPEECH_RECOGNITION  -->
+
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 
|keywords= <!-- TTS, text-to-speech,SpeechSynthesizer,SSML,voice -->
 
|keywords= <!-- TTS, text-to-speech,SpeechSynthesizer,SSML,voice -->
 
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 
|translated-by= <!-- [[User:XXXX]] -->
 
|translated-by= <!-- [[User:XXXX]] -->
|translated-from-title= <!-- Title only -->  
+
|translated-from-title= <!-- Title only -->
 
|translated-from-id= <!-- Id of translated revision -->
 
|translated-from-id= <!-- Id of translated revision -->
|review-by=<!-- After re-review: [[User:username]] -->
+
|review-by= <!-- After re-review: [[User:username]] -->
 
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 
|update-by= <!-- After significant update: [[User:username]]-->
 
|update-by= <!-- After significant update: [[User:username]]-->
 
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 
|update-timestamp= <!-- After significant update: YYYYMMDD -->
|creationdate= <!-- 20121204 -->
+
|creationdate= 20121205
|author= <!--[[User:cadlg]] -->
+
|author= [[User:Cadlg]]
 
}}
 
}}
  

Revision as of 08:31, 5 December 2012

Delete instructional text in italic

This article demonstrates how the Synthesis Markup Language (SSML) can be used to provide advanced text-to-speech (TTS) functionality on Windows Phone 8 applications.

MultiMediaTile.png
WP Metro Icon Multimedia.png
Article Metadata

Article
Created: cadlg (05 Dec 2012)
Last edited: hamishwillee (05 Dec 2012)
Note.png
Note: This is a community entry in the Windows Phone 8 Wiki Competition 2012Q4.

Contents

Introduction

Microsoft introduced a number of interesting APIs and features in the field of speech in Windows Phone 8, which include voice commands, speech recognition and text-to-speech (TTS).

Although this article explains how to add basic TTS functionality to an application, it mainly focuses on the use of the Speech Synthesis Markup Language (SSML) that is supported by Windows Phone 8, to allow a more advanced use of the text-to-speech engine.

Prerequisites

This article assumes a basic knowledge of the Visual Studio IDE, which includes knowledge on how to create, compile and run applications, how to add subdirectories and create and/or add new or existing items to them, and a basic knowledge of the C# language and object oriented programming in general

TTS on Windows Phone 8

Warning.png
Warning: To use TTS, the ID_CAP_SPEECH_RECOGNITION capability must be set in the app manifest. If this capability is not set, the app might not work correctly or might raise runtime errors

The first thing that needs to be done is to include a using statement for the speech synthesis namespace. This is necessary in any application with TTS functionality:

using Windows.Phone.Speech.Synthesis;

Then a new object of the SpeechSynthesizer class must be instantiated

SpeechSynthesizer synth = new SpeechSynthesizer();

And finally, the SpeakTextAsync method must be called, to speak the text.

await synth.SpeakTextAsync("Testing WP8 TTS");
Tip.png
Tip: The await operator is used in conjunction with asynchronous methods to make sure applications remain responsive. A detailed explanation of this functionality is out of the scope of this article

This basic use of the TTS engine might be enough for some applications, but Windows Phone 8 provides additional mechanisms and methods to add more advanced TTS functionality, by utilizing SSML.

Speech Synthesis Markup Language (SSML)

SSML is an XML-based markup language for speech synthesis applications, and is a recommendation of the W3C's voice browser working group. It allows application developers to control various characteristics of synthesized speech, such as voice, language, pronunciation, etc.

The Microsoft implementation of SSML is based on World Wide Web Consortium Speech Synthesis Markup Language (SSML) Version 1.0.

The SpeechSynthesizer class provides 2 methods to speak text that includes SSML markup. The first one, SpeakSsmlAsync, receives the text to speak as a parameter, and the second one, SpeakSsmlFromUriAsync, speaks text from a standalone SSML document. The first one will be used to show the different speech characteristics that can be controlled by using SSML, and then a short explanation of how to speak the contents of a standalone document will be included.

Each SSML document or string requires a speak element. It is the root element of the document, and can be used without any other elements. The speak element also specifies the language to be used.

This is the syntax:

<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="string"> </speak>

The "platform categories" will be displayed here in preview only - Copy paste relevant categories into text here


Add categories below using category selector.

653 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved