24. private SpeechSynthesizer synthesizer = new SpeechSynthesizer();
private async void button_Click(object sender, RoutedEventArgs e)
{
SpeechSynthesisStream speechStream =
await synthesizer.SynthesizeTextToStreamAsync(textBox1.Text);
mediaElement1.SetSource(speechStream, speechStream.ContentType);
mediaElement1.Play();
}
Dim synthesizer As SpeechSynthesizer = New SpeechSynthesizer()
Private Async Sub button_Click(sender As Object,
e As RoutedEventArgs) Handles button.Click
Dim speechStream As SpeechSynthesisStream =
Await synthesizer.SynthesizeTextToStreamAsync(textBox1.Text)
mediaElement1.SetSource(speechStream, speechStream.ContentType)
mediaElement1.Play()
End Sub
30. var recognizer =
new SpeechRecognizer(SpeechRecognizer.SystemSpeechLanguage);
await recognizer.CompileConstraintsAsync();
SpeechRecognitionResult recognitionResult =
await recognizer.RecognizeAsync();
if (recognitionResult.Status == SpeechRecognitionResultStatus.Success)
textBlock1.Text = recognitionResult.Text;
Dim recognizer =
New SpeechRecognizer(SpeechRecognizer.SystemSpeechLanguage)
Await recognizer.CompileConstraintsAsync()
Dim recognitionResult As SpeechRecognitionResult =
Await recognizer.RecognizeAsync()
If recognitionResult.Status = SpeechRecognitionResultStatus.Success
Then
textBlock1.Text = recognitionResult.Text
End If