Example #1
0
        private async void Button_Click_Sun(object sender, RoutedEventArgs e)
        {
            MediaElement mediaElement = new MediaElement();// This creates a speech synthesis object, voicing the description
            var          synth        = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync("The sun is the star at the centre of our solar system. It is a sphere of hot plasma (mostly hydrogen) that radiates an incredible amount of heat. The temperature of its core is " +
                                                                                                                 "about 15 million degrees Celsius. Life on Earth depends on the sun for energy and heat.");

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();

            DisplayPlanet.Source = new BitmapImage(new Uri(base.BaseUri, "Assets/Sun.jpg")); //Changes the image displayed at top of screen

            // Below is the code for changing the text displayed on screen
            PName.Text        = "Name: Sun";
            PDesignation.Text = "Designation: Star";
            PType.Text        = "Type: G-type main-sequence star (G2V)";
            PRadius.Text      = "Radius: 695700km";
            PVolume.Text      = "Volume: 1.41×10^18 km3";
            PMass.Text        = "Mass: 1.989 × 10^30 kg";
            PGravity.Text     = "Surface Gravity: 274 m/s2";
            PDescription.Text = "Description: The sun is the star at the centre of our Solar System.\n" +
                                "It is a sphere of hot plasma (mostly hydrogen) that radiates heat.\n" +
                                "The temperature of its core is about 15 million degrees Celsius.\n" +
                                "Life on Earth depends on the sun for energy and heat.\n";
        }
        // Based on Microsoft Documentation @ https://docs.microsoft.com/en-us/visualstudio/get-started/csharp/tutorial-uwp?view=vs-2019
        private async void TextToSpeech(object sender, RoutedEventArgs e)
        {
            // get the text from the input-field
            TalkToMeInput.Document.GetText(Windows.UI.Text.TextGetOptions.AdjustCrlf, out TextToSpeak);

            if (TextToSpeak == string.Empty)
            {
                TextToSpeak = "Hello World";
            }

            if (mediaElement == null)
            {
                mediaElement = new MediaElement();
            }
            if (synth == null)
            {
                synth = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();
            }

            // pass the text into the windows SpeechSynthesis and play
            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync(TextToSpeak);

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();

            Debug.WriteLine(string.Format("Trying to SpeechSynthesis {0}.", TextToSpeak));
        }
Example #3
0
        private async void Button_Click_Neptune(object sender, RoutedEventArgs e)
        {
            MediaElement mediaElement = new MediaElement();
            var          synth        = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync("Neptune is the eighth and farthest known planet from the sun in the Solar System.\n" +
                                                                                                                 " It is similar in composition to its twin, Uranus.\n" +
                                                                                                                 " It is named after the Roman god of the sea.\n" +
                                                                                                                 " It is not visible to the naked eye, and was the only planet in the Solar System discovered through mathematical prediction rather than empirical observation.\n");

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();

            DisplayPlanet.Source = new BitmapImage(new Uri(base.BaseUri, "Assets/Neptune.jpg"));
            PName.Text           = "Name: Neptune";
            PDesignation.Text    = "Designation: Eight planet in the Solar System";
            PType.Text           = "Type: Ice Giant";
            PRadius.Text         = "Radius: 24622km";
            PVolume.Text         = "Volume: 6.254 × 10^13 km3";
            PMass.Text           = "Mass: 1.0243 × 10^26 kg";
            PGravity.Text        = "Surface Gravity: 11.15 m/s2";
            PDescription.Text    = "Description: Neptune is the eighth and farthest known planet from the sun in the \nSolar System.\n" +
                                   "It is similar in composition to its twin, Uranus.\n" +
                                   "It is named after the Roman god of the sea.\n" +
                                   "It is not visible to the naked eye, and was the only planet \nin the Solar System discovered through mathematical prediction rather than \nempirical observation.\n";
        }
Example #4
0
        public async void InitSpeechCueScenario()
        {
            var synthesizer = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            // Enable word marker generation (false by default).
            synthesizer.Options.IncludeWordBoundaryMetadata     = true;
            synthesizer.Options.IncludeSentenceBoundaryMetadata = true;

            var stream = await synthesizer.SynthesizeTextToStreamAsync(inputText);

            // Create a media source from the stream, which also implements ITimedMetadataTrackProvider:
            var mediaSource = MediaSource.CreateFromStream(stream, "");

            //Create a Media Playback Item  
            var mediaPlaybackItem = new MediaPlaybackItem(mediaSource);

            // Ensure that the app is notified for cues. 
            RegisterForWordBoundaryEvents(mediaPlaybackItem);

            // Set the source of the MediaElement or MediaPlayerElement to the MediaPlaybackItem
            // and start playing the synthesized audio stream.
            _mediaPlayer = new MediaPlayer();
            mediaPlayerElement.SetMediaPlayer(_mediaPlayer);
            _mediaPlayer.Source = mediaPlaybackItem;
            _mediaPlayer.Play();
        }
Example #5
0
        private async void Button_Click_Earth(object sender, RoutedEventArgs e)
        {
            MediaElement mediaElement = new MediaElement();
            var          synth        = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync("Earth is the third planet from the sun.\n" +
                                                                                                                 " It is the only place in the Universe known to harbor life.\n" +
                                                                                                                 " It is orbited by the Moon, Earth's only natural satellite.\n" +
                                                                                                                 " It is the largest of the four terrestrial planets.\n");

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();

            DisplayPlanet.Source = new BitmapImage(new Uri(base.BaseUri, "Assets/Earth.jpg"));
            PName.Text           = "Name: Earth";
            PDesignation.Text    = "Designation: Third Planet in the Solar System";
            PType.Text           = "Type: Terrestrial Planet";
            PRadius.Text         = "Radius: 6371km";
            PVolume.Text         = "Volume: ‎1.08321 ×10^12 km3";
            PMass.Text           = "Mass: 5.972 × 10^24 kg";
            PGravity.Text        = "Surface Gravity: 9.807 m/s2";
            PDescription.Text    = "Description: Earth is the third planet from the sun.\n" +
                                   "It is the only place in the Universe known to harbor life.\n" +
                                   "It is orbited by the Moon, Earth's only natural satellite.\n" +
                                   "It is the largest of the four terrestrial planets.\n";
        }
		/// <summary>
		/// Invoked when this page is about to be displayed in a Frame.
		/// </summary>
		/// <param name="e">Event data that describes how this page was reached.
		/// This parameter is typically used to configure the page.</param>
		protected override async void OnNavigatedTo(NavigationEventArgs e)
		{
			if (e.NavigationMode == NavigationMode.New)
			{
				SuspensionManager.SessionState["ShowASectionPage"] = e.Parameter.ToString();
			}

			string[] parameters = SuspensionManager.SessionState["ShowASectionPage"].ToString().Split('|');

			if (parameters.Length > 1)
			{
				newspaperSectionTextBlock.Text = parameters[1];
				string feedback = string.Format("VoiceCommandsQuickstart has launched and has navigated to the {0} newspaper section.", newspaperSectionTextBlock.Text);
				feedbackTextBlock.Text = feedback;

				// Only give audible feedback if the commandMode key in the SpeechRecognitionResult's SemanticInterpretation
				// collection is not "text". If the app was launched by typing, rather than voice, then we should give silent
				// feedback as a courtesy.
				if (parameters[0] != "text" && e.NavigationMode == NavigationMode.New)
				{
					var speechSynthesizer = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();
					var stream = await speechSynthesizer.SynthesizeTextToStreamAsync(feedback);
					feedbackMediaElement.SetSource(stream, stream.ContentType);
					feedbackMediaElement.Play();
				}
			}
		}
Example #7
0
        private async void Button_Click_Mars(object sender, RoutedEventArgs e)
        {
            MediaElement mediaElement = new MediaElement();
            var          synth        = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync("Mars is the fourth planet from the sun.\n" +
                                                                                                                 " It is a cold, barren world named after the Roman god of war.\n" +
                                                                                                                 " Known as the Red Planet due to the presence of iron oxide, giving it a reddish tint.\n" +
                                                                                                                 " Scientists believe Mars might once have been able to support life, and may possibly harbor extant life beneath its surface.\n");

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();

            DisplayPlanet.Source = new BitmapImage(new Uri(base.BaseUri, "Assets/Mars.jpg"));
            PName.Text           = "Name: Mars";
            PDesignation.Text    = "Designation: Fourth planet in the Solar System";
            PType.Text           = "Type: Terrestrial Planet";
            PRadius.Text         = "Radius: 3390km";
            PVolume.Text         = "Volume: 6.4171 × 10^23 km3";
            PMass.Text           = "Mass: 6.39 × 10^23 kg";
            PGravity.Text        = "Surface Gravity: 3.711 m/s2";
            PDescription.Text    = "Description: Mars is the fourth planet from the sun.\n" +
                                   "It is a cold, barren world named after the Roman god of war.\n" +
                                   "Known as the Red Planet due to the presence of iron oxide, giving it a \nreddish tint.\n" +
                                   "Scientists believe Mars might once have been able to support life, and \nmay possibly harbor extant life beneath its surface.\n";
        }
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.NavigationMode == NavigationMode.New)
            {
                SuspensionManager.SessionState["ShowASectionPage"] = e.Parameter.ToString();
            }

            string[] parameters = SuspensionManager.SessionState["ShowASectionPage"].ToString().Split('|');

            if (parameters.Length > 1)
            {
                newspaperSectionTextBlock.Text = parameters[1];
                string feedback = string.Format("VoiceCommandsQuickstart has launched and has navigated to the {0} newspaper section.", newspaperSectionTextBlock.Text);
                feedbackTextBlock.Text = feedback;

                // Only give audible feedback if the commandMode key in the SpeechRecognitionResult's SemanticInterpretation
                // collection is not "text". If the app was launched by typing, rather than voice, then we should give silent
                // feedback as a courtesy.
                if (parameters[0] != "text" && e.NavigationMode == NavigationMode.New)
                {
                    var speechSynthesizer = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();
                    var stream            = await speechSynthesizer.SynthesizeTextToStreamAsync(feedback);

                    feedbackMediaElement.SetSource(stream, stream.ContentType);
                    feedbackMediaElement.Play();
                }
            }
        }
Example #9
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.Parameter is string && !string.IsNullOrWhiteSpace((string)e.Parameter))
            {
                greeting.Text = $"Hi, {e.Parameter}";
            }
            else
            {
                greeting.Text = "Hi!";
            }

            if (e.NavigationMode == NavigationMode.Back)
            {
                goto F1;
            }

            MediaElement mediaElement = new MediaElement();
            var          synth        = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync(greeting.Text);

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();
F1:
            this.BackButton.Visibility = this.Frame.CanGoBack ? Visibility.Visible : Visibility.Collapsed;
            base.OnNavigatedTo(e);
        }
        public async void Speak(string text)
        {
            var mediaElement = new MediaElement();
            var synth        = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();
            var stream       = await synth.SynthesizeTextToStreamAsync(text);

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();
        }
        private async Task SpeakAsync(string text)
        {
            MediaElement mediaElement = new MediaElement();
            var          synth        = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync(text);

            mediaElement.SetSource(stream, stream.ContentType);
        }
Example #12
0
        private async void Test_Button_Click(object sender, RoutedEventArgs e)
        {
            MediaElement mediaElement = new MediaElement();
            var          synth        = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync("War Gear Calculator");

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();
        }
        /***********************************************************************
        *  Build a voice reader to repeat the out put to the user.
        * *********************************************************************/
        private async void VoiceMessage(string voice)
        {
            MediaElement mediaElement = new MediaElement();
            var          synth        = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync(voice);

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();
        }
Example #14
0
        private async void Next_1_0(object sender, RoutedEventArgs e)
        {
            MediaElement mediaElement = new MediaElement();
            var          talk         = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await talk.SynthesizeTextToStreamAsync("Horses jump over fences.");

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();
        }
Example #15
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            MediaElement voice = new MediaElement();
            var          synth = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync("I Like Potatoes");

            voice.SetSource(stream, stream.ContentType);
            voice.Play();
        }
Example #16
0
        public async void SayWord(string word)
        {
            MediaElement mediaElement = new MediaElement();
            var          synth        = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync(word);

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();
        }
        private async void btLer_Click(object sender, RoutedEventArgs e)
        {
            MediaElement media = new MediaElement();
            var          synth = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync(edConteudo.Text);

            media.SetSource(stream, stream.ContentType);
            media.Play();
        }
Example #18
0
        private async void button_Click(object sender, RoutedEventArgs e)
        {
            MediaElement boomButton = new MediaElement();
            var          synth      = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync("Pied Piper is a middle-out compression solution, making data storage problems smaller.");

            boomButton.SetSource(stream, stream.ContentType);
            boomButton.Play();
        }
//this part will be very important for our app. in fact, this is an event that occur each time the button is pressed
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            MediaElement mediaElement = new MediaElement();
            var          audio        = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await audio.SynthesizeTextToStreamAsync("Hello m**********r world! XD");

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();
        }
Example #20
0
        private async void Sentence1(object sender, RoutedEventArgs e)
        {
            MediaElement mediaElement = new MediaElement();
            var          talk         = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await talk.SynthesizeTextToStreamAsync("Dogs are humans best friend. Cats love to sleep.");

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();
        }
Example #21
0
        private async void SpeakButton_Click(object sender, RoutedEventArgs e)
        {
            MediaElement mediaElement = new MediaElement();
            var          synth        = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync(ConvertedValueTextBox.Text);

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();
        }
Example #22
0
        private async void button_Click(object sender, RoutedEventArgs e)
        {
            MediaElement mediaElement = new MediaElement();
            var          synth        = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync("To be, or not to be: that is the question: Whether 'tis nobler in the mind to suffer The slings and arrows of outrageous fortune, Or to take arms against a sea of troubles, And by opposing end them ? To die: to sleep; No more; and by a sleep to say we end");

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();
        }
Example #23
0
        private async void playAudio()
        {
            MediaElement mediaElement = new MediaElement();
            var          synth        = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync(timerStartSpeech + time.ToString() + " minutes");

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();
        }
Example #24
0
        private async void PrintButton(object sender, RoutedEventArgs e)
        {
            MediaElement mediaElement = new MediaElement();
            var          synth        = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync("printing ... ... ... not");

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();
        }
Example #25
0
        private async void Next_0_1(object sender, RoutedEventArgs e)
        {
            MediaElement mediaElement = new MediaElement();
            var          talk         = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await talk.SynthesizeTextToStreamAsync("Cats play with string.");

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();
        }
Example #26
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var mediaElement = new MediaElement();
            var synth        = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync("Hello, World!");

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();
        }
Example #27
0
        private async void Tapped_1_1(object sender, RoutedEventArgs e)
        {
            MediaElement mediaElement = new MediaElement();
            var          talk         = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await talk.SynthesizeTextToStreamAsync("DONKEY, D O N K E Y");

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();
        }
Example #28
0
        public static async System.Threading.Tasks.Task <int> SynSpeechPlayAsyncServiceAsync(byte[] bytes, System.Collections.Generic.Dictionary <string, string> apiArgs)
        {
            using (Windows.Media.SpeechSynthesis.SpeechSynthesizer synth = new Windows.Media.SpeechSynthesis.SpeechSynthesizer())
            {
                Windows.Media.SpeechSynthesis.SpeechSynthesisStream synthStream = await synth.SynthesizeTextToStreamAsyncServiceAsync(text, apiArgs); // doesn't handle special characters such as quotes

                await Audio.PlayFileAsync(synthStream, synthStream.ContentType);
            }
            return(0);
        }
Example #29
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            MediaElement mediaElement = new MediaElement();
            var          talk         = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await talk.SynthesizeTextToStreamAsync("Learn animals and spelling!");

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();
        }
Example #30
0
        public async Task speachAsync(string texte)
        {
            MediaElement mediaElement = new MediaElement();
            var          synth        = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync(texte);

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();
        }
Example #31
0
        private async void button_Click(object sender, RoutedEventArgs e)
        {
            MediaElement mediaElement = new MediaElement();
            var          synth        = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync("Welcome on Holodesk, thanks!");

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();
        }
		/// <summary>
		/// Invoked when this page is about to be displayed in a Frame.
		/// </summary>
		/// <param name="e">Event data that describes how this page was reached.
		/// This parameter is typically used to configure the page.</param>
		protected override void OnNavigatedTo(NavigationEventArgs e)
		{
			try
			{
				this.installedVoicesListBox.ItemsSource = from voiceInformation in Windows.Media.SpeechSynthesis.SpeechSynthesizer.AllVoices select voiceInformation;

				this.speechSynthesizer = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();
			}
			catch (Exception exception)
			{
				var messageDialog = new Windows.UI.Popups.MessageDialog(exception.Message, "Exception");
				messageDialog.ShowAsync().GetResults();
			}
		}
		private async void SayMessage(string message)
		{
			if (!string.IsNullOrWhiteSpace(message)
				 && timeToMessage.TotalSeconds <= Offset)
			{
				if(lastMessage == message)
					return;
				try
				{
					using (var speech = new Windows.Media.SpeechSynthesis.SpeechSynthesizer())
					{
						lastMessage = message;
						var voiceStream = await speech.SynthesizeTextToStreamAsync(ReplaceAbbreviations(message));
						player.SetSource(voiceStream, voiceStream.ContentType);
						player.Play();
					}
				}
				catch { }
			}
		}