Introduction
In Windows Phone we have a Text To Speech API that delivers an automated voice of what you really want her to say. In short, the TTS API is synthesized speech that can read the user input or paragraph.
Requirement
Since this project needs a special privilege capability, first assign ID_CAP_SPEECH_RECOGNIZATION.
Make sure to open WMAppManifest.xml in Designer View. Right-click on WMAppManifest.xml then seelct "Capability" then select (check) ID_CAP_SPEECH_RECOGNITION.
Code
Step 1
First, you need to include the namespace.
- using Windows.Phone.Speech.Synthesis;
Step 2
There is an asynchronous method called
SpeechTecAsunc() that does your job. And this method belongs to the
SpeechSynthesizer class. So, first we initiate it.
- private async void btnTalk_Click(object sender, RoutedEventArgs e)
- {
-
- SpeechSynthesizer speech = new SpeechSynthesizer();
- await speech.SpeakTextAsync(myInputTextBox.Text.ToString());
- }
Explanation
Every text that you want soken must be placed inside SpeechTextAsync().
Just like that, SpeechTextAsync(“Hello World”) will say Hello World. This is not a complete article but good to start with. In MSDN: T
ext-to-speech (TTS) for Windows Phone 8'.
Conclusion
It's not the most descriptive one, but I tried to provide a small article on the TTS API. For any issue, try to solve it from the solution file.