July 19, 2013 by Anuraj Estimated read time : 5 mins
.NetWindows FormsWindows Phone
In WP8, Microsoft introduced libraries for both Text to Speech and Speech to Text without an active internet connection. But this feature is not available in WP7. I found some article implementing Text to Speech using BING API, but seems it is no more working. Here is one implementation using BING REST API, which helps to integrate text to speech in in you WP7 applications.
The following code requires Client Id and Client Secret, which you can get from https://datamarket.azure.com/account, Customer ID is the Client Id, Primary Account Key is Client Secret. The Text to Speech work flow is like this.
The Auth token will expire after 10 minutes, so you need to renew it on every 10 minutes.
And here is code snippet.
And here is the Access Token class.
And you can consume the code like this in WP7.
You can use this code in Winforms/Console application also, but you may need to change WebClientOpenReadCompleted() method. You may need to use the SoundPlayer class instead of using XNA Framework classes.