The library follows the well known async/await pattern, so its usage is very simple:

SpeechSynthesizer speech = new SpeechSynthesizer(CLIENT_ID, CLIENT_SECRET);

string text = "Have a nice day!";
string language = "en";

// Gets the audio stream.
var stream = await speech.GetSpeakStreamAsync(text, language);

// Reproduces the audio stream using a MediaElement.
SpeechMediaElement.SetSource(stream, speech.MimeContentType);

We first obtain a stream that contains the speech, then we use a MediaElement to reproduce it.

The text is automatically translated in the specified language before speaking. This behaivour is controlled by the AutomaticTranslation property, that is set to true by default. If you don't need to translate the text, because you 're already passing it in the language you want to use (as in this example), you can speed-up the library setting the AutomaticTranslation property to false. In this way, the specified text is passed as is to the other methods, without performing any translation.

Last edited Nov 1, 2012 at 6:57 PM by marcom, version 2

Comments

marcom Jun 25, 2013 at 10:11 PM 
Make sure you have set the Client ID and Client Secret of the application, not the account.

yilmazalican Mar 31, 2013 at 8:45 PM 
It does not work, even i fill my client id and secret correctcly the http request does not work
it turns 400 - bad request error...