Esempio n. 1
0
        // Speaks the content of a standalone SSML file.
        private async void SpeakSsmlFromFile_Click(object sender, RoutedEventArgs e)
        {
            try // error handling
            {
                // Disable the ListBoxes to prevent exceptions
                VoicesListBox.IsEnabled    = false;
                LanguagesListBox.IsEnabled = false;

                // Stop playing any Synthesized speech
                _speechSynthesizer.CancelAll();

                // Set the path to the SSML-compliant XML file.
                string path       = Package.Current.InstalledLocation.Path + "\\SSMLExample.xml";
                Uri    fileToRead = new Uri(path, UriKind.Absolute);

                // Speak the SSML prompt.
                await _speechSynthesizer.SpeakSsmlFromUriAsync(fileToRead);

                MessageBox.Show("SSML file read.");

                // Re-enable the ListBoxes
                VoicesListBox.IsEnabled    = true;
                LanguagesListBox.IsEnabled = true;
            }
            catch (Exception ex) // Catch exception and call function to handle it.
            {
                HandleSpeechSynthesisError(ex);
            }
        }